Revision
Revision
He has been asked by his teacher to write the code for the following tasks:-
L3=L2.extend(L1)
print(L3)
rec=[‘Thomas’,’C-25’,[56,98,99,72,69],78.8]
iv)To delete the item from the dictionary corresponding to the key ‘B’
Consider the following dictionary:
i) Alpha[“M”]=”Monkey”
ii) print(Alpha[“K”])
iii) print(len(Alpha))
name={1:”India”,2:‟australia‟,3:‟Japan‟,4:‟America‟,5:‟China‟}
dictionary:
for i in name:
print(i)
print(name.values())
iii) Write command to add new element having key 6 and values as
“Ireland”
name[6]=”Ireland”
Zealand”
name[3]=”New Zealand”
del name[3]
consider the following dictionary: states={‘D’: ‘Delhi’ , ‘K’ : ‘Kerala’ , ‘T’ :
d) To delete the item from the dictionary corresponding to the key ‘K’
d={1:‟One‟,3:‟Three‟,5,‟Five‟,7:‟Seven‟,9:‟N
in the dictionary:
(a) Write command traverse a dictionary and print key & values
dictionary.
33 and value 23
Predict the output based on the list, cod = [98, 45, 62, 14, 1007]
a) print(len(cod))
Ans :5
b) print(cod * 2)
Ans: [98, 45, 62, 14, 1007, 98, 45, 62, 14, 1007]
c) print(1007 in cod)
Ans: True
d)print(cod[:2]+cod[2:])
print(cod. pop(1))
Write Python statements to retrieve the following information from the list, RecordList
● Percentage obtained
Ans :RecordList[0]
RecordList[2][0]
RecordList[-1]
RecordList[0]=”Kunal”
Predict the output based on the list, cod = [98, 45, 62, 14, 1007]
1. print(len(cod+cod))
2. print(cod[2:4] * 3)
4. print(50-5 in cod)
5. print(cod[::-1]+cod[0:1])
Ans : a.10
d. True
“PTM”
a. To remove the key ‘s3’ and its corresponding values from the dictionary
a. PTM. clear()
b. len(PTM)
c. PTM[‘s5’]=99
d. min(PTM)