1 What Will Be The Output of Following Code-: A (1:"A",2:"B",3:"C") Foriina: Print (I, End " ")
1 What Will Be The Output of Following Code-: A (1:"A",2:"B",3:"C") Foriina: Print (I, End " ")
a={1:"A",2:"B",3:"C"}
for i in a:
print(i,end=" ")
Ans: 1 2 3
Ans:{0:1,1:1,2:1}
4 What will be the output of following code-
a={i: i*i for i in range(6)} a
Ans:{0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
Ans:
2
Ans:ERROR
8 What will be the output of following program: dict1
= {"key1":1, "key2":2}
dict2 = {"key2":2, "key1":1}
print(dict1 == dict2)
Ans:TRUE
Ans:{'Virat':
1, 'Rohit': 2,
'Rahul': 2}
Ans:ERROR
11 What will be the output of following program: a={}
a.fromkeys([1,2,3],"check")
Ans:{}
count += a[i]
print(count)
Ans: 4
6
14 What will be the output of following program: test =
{1:'A', 2:'B', 3:'C'}
del test[1]
test[1] = 'D' del
test[2]
print(len(test)
Ans:2
Ans:0
Ans:>>>
Ans:1 2 3
18 What will be the output of following program:
a={1:5,2:3,3:4}
a.pop(3)
print(a)
Ans:{1: 5, 2: 3}
Ans: 9
Ans: C
22 What will be the output of following program:
a={1:"A",2:"B",3:"C"}
b=a.copy()
b[2]="D"
print(a)
Ans: 2
4
Ans:96
98
97
Ans: FALSE
Ans: TRUE
28 What will be the output of following program:
my_dict = {}
my_dict[(1,2,4)] = 8
my_dict[(4,2,1)] = 10
my_dict[(1,2)] = 12
sum = 0
for k in my_dict: sum
+= my_dict[k]
print (sum)
print(my_dict)
Ans: 6
30 What will be the output of following program: arr =
{}
arr[1] = 1
arr['1'] = 2
arr[1] += 1
sum = 0
for k in arr: sum
+= arr[k]
print (sum)
Ans: 4
Ans: ERROR
Ans 1:
33 What will be the output of following program: a={
1:'a', 2:'b', 3:'c'}
for i,j in a.items(): print(i,j,end="#")
Ans: {1:3,2:1,3:1,5:2,6:2}
Ans:Sharma
Ishant
Rohit
{1: 'Rohit', 2: 'Sharma', 'name': 'Ishant', 4: 'Sharma'}
print({**dict_1, **dict_2})
39 Write a Python program to get the maximum and minimum value in a dictionary.
print(result)
Ans:
42 Write a Python program to sum all the items in a dictionary.
print(sum(my_dict.values()))