Answer: set()
a={1,2,3}
a.intersection_update({2,3,4,5})
a
Answer: {2,3}
Article and Schedule Quiz | Start Test! |
s=set([1, 2, 3])
s.union([4, 5])
s|([4, 5])
Answer: {1, 2, 3, 4, 5} Error
s1.issubset(s1)
Answer: True
a=("Check")*3
a
Answer: (‘CheckCheckCheck’)
>>>t=(1,2,4,3)
>>>t[1:3]
Answer: (2, 4)
>>>t=(1,2,4,3)
>>>t[1:-1]
Answer: (2, 4)
>>>t = (1, 2, 4, 3, 8, 9)
>>>[t[i] for i in range(0, len(t), 2)]
Answer: [1, 4, 8]
d = {"john":40, "peter":45}
d["john"]
Answer: 40
>>>t = (1, 2)
>>>2 * t
Answer:(1, 2, 1, 2)
>>>t1 = (1, 2, 4, 3)
>>>t2 = (1, 2, 3, 4)
>>>t1 < t2
Answer: False
>>>my_tuple = (1, 2, 3, 4)
>>>my_tuple.append( (5, 6, 7) )
>>>print len(my_tuple)
Answer: Error
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
Answer: 33