Assignment - 1 Class 12 - Gargee - 2020-21
Assignment - 1 Class 12 - Gargee - 2020-21
a,b,c=2,8,9
print(a,b,c)
c,b,a=a,b,c
print(a,b,c)
(ii)
else = 21-5
3. What will be the output produced by following code
fragment(s) ?
first = 2
Page | 1
second = 3
third = first + second
print(first,second,third)
first=first+second+third
third = second + first
print(first,second,third)
4. What is the problem with the following code fragment?
a=3
s=a+10
a="New"
q=a/10
5. Predict the output :
x,y=20,60
y,x,y=x,y-10,x+10
print(x,y)
6. Consider the following code :
name = input("What is your name?")
print('Hi',name,',')
print("How are you doing?")
Hi <name>,
How are you doing?
7. What will be the output produced by the code :
(i) str(print())+"One"
(ii) str(print("hello"))+"One"
8. Write a short program that asks for your height in
centimetres and then converts your height to feet and
inches. (1 𝑓𝑜𝑜𝑡 = 12 𝑖𝑛𝑐ℎ𝑒𝑠, 1 𝑖𝑛𝑐ℎ = 2.54 𝑐𝑚)
9. Prepare a small cheat sheet showing the precedence of all
the python operators. (Refer to Chapter – Data Handling)
10. Write the following expressions in Python :
1 2
(i) 𝑏 ℎ
3
(ii) 𝑑 = √(𝑥2 − 𝑥1 )2 + (𝑦2 − 𝑦1 )2
Page | 2
−𝑥±√𝑏2 −4𝑎𝑐
(iii) 𝑥=
2𝑎
Page | 3
19. Write a program to take an n-digit number and print its
reverse.
20. Write a program that reads a number of seconds and
prints it in form : mins and seconds, e.g., 200 seconds are
printed as 3 mins and 20 seconds.
Page | 4