Practice Paper 2
Practice Paper 2
Find error, underline them and rewrite the same after correcting the following
code:
d1 = dict[]
i=1
n = input("Enter number of entries :")
while i<n:
a = input("Enter name:")
b = input("Enter age:")
d1(a) = b
i=i+1
L = d1.key[ ]
For I in L:
print int(i, ‘\t’ , ‘d1 [i]’)
3. A tuple is declared as
>>> T = (2, 5, 6, 9, 8)
>>> sum(T)
4. Write a statement in Python to declare a dictionary whose keys are 1, 2, 3 and the
values are Monday, Tuesday and Wednesday respectively.
5. A tuple is declared as
T = (23, 8.6, 'hello', 41, 'x')
What will be the value of T[:1:-1]?
7. Write a statement in python to declare a dictionary D with 100 keys 0, 1, .., 99 each
having values as 200.
12. Name the Python Library modules which need to be imported to invoke the
following functions:
a) ceil() b) randrange()
17. A tuple is declared as T = (1, 2), (1, 2, 4), (5, 3) What will be the value of min(T) ?