What will be the output of the following Python code?
numberGames = {}
numberGames[(1,2,4)] = 8
numberGames[(4,2,1)] = 10
numberGames[(1,2)] = 12
sum = 0
for k in numberGames:
sum += numberGames[k]
print len(numberGames) + sum
s={1, 2, 3}
s.update(4)
s
. What will be the output of the following Python code?
s1={3, 4}
s2={1, 2} s3=set() i=0 j=0 for i in s1: for j in s2: s3.add((i,j)) i+=1 j+=1
print(s3)
What will be the output of the following Python code snippet?
d1 = {"john":40, "peter":45}
d2 = {"john":466, "peter":45}
d1 > d2
print([if i%2==0: i; else: i+1; for i in range(4)])
>>> a=(2,3,1,5)
>>> a.sort()
>>> a
>>>t=(1,2,4,3)
>>>t[1:-1]
d = {"john":40, "peter":45}
print(list(d.keys()))
a={1:"A",2:"B",3:"C"}
for i,j in a.items():
print(i,j,end=" ")
s=set()
type(s)
a = [1, 5, 7, 9, 9, 1] <br class="blank" />b=a[0] <br class="blank" />x= 0 for x in range(1, len(a)): if a[x] > b: b = a[x] b= x print(b)
Is the following Python code valid?
>>> a=(1,2,3,4) >>> del a
A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] B = [[3, 3, 3], [4, 4, 4], [5, 5, 5]] zip(A, B)
>>> a={1,2,3}
>>> b=a.add(4)
>>> b
What will be the output of the following Python code, if s1= {1, 2, 3}?
s1.issubset(s1)
a = [5,5,6,7,7,7]
b = set(a) def test(lst): if lst in b: return 1 else: return 0 for i in filter(test, a):
print(i,end=" ")
>>> a.intersection_update({2,3,4,5})
print([[i+j for i in "abc"] for j in "def"])
>>> b=frozenset([3,4,5])
>>> a-b