PREDICT THE OUTPUT’s QUESTION
1. n1 = (1, 2, 3) 16. a = (8,’A’,5)
n2 = (3, 4) b = (2,”python”)
s = n1 + n2 c=a+b
print(s) print(c)
2. a = {} 17. a1 = {}
a [(1, 2, 4)] = 8 a1 [(1, 2, 3)] = 4
a [(4, 2, 1)] = 10 a1 [(3, 2, 1)] = 5
a [(1, 2)] = 24 a1 [(1, 2)] = 6
sum = 0 p=1
for i in a : for num in a1 :
sum = sum + a[i] p = p * dic[num]
print (sum) print (p)
3. 18. list = [‘P’,’Y’,’T’,’H’,’O’,’N’]
print(list[0:3])
print(list[3:]
print(list[:])
print(list[1:-2])
4. 19. Considering the content stored in
file “WORLDCUP.TXT”, write the
output
“India won the Cricket world cup
of 1983”
f = open(“WORLDCUP.TXT”)
print(f.read(2))
print(f.read(2))
print(f.read(4))
5. 20. Identify one mutable object and one immutable
object from the following:
(1,2), [1,2], {1:1,2:2}, ‘123’
6. 21. Consider the following Python code
and complete the missing
statement:
import pickle
myfile = open("test.dat","rb")
d= #statement to
load dictionary data from file to „d‟
print(d)
myfile.close()
7. 22. d = {"apple": 15, "banana": 7, "cherry": 9}
str1 = ""
8.
for key in d:
str1 = str1 + str(d[key]) + "@" + “\n”
str2 = str1[:-1]
print(str2)
9. 23.
10. 24.
11. 25.
12. 26. line=[4,9,12,6,20]
for I in line:
for j in range(1,I%5):
print(j,’#’,end=””)
print()
13. 27.
14. 28.
15. 29.