ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(3 in {1: 'a', 3: 'b'}, '3' in {1: 'a', 3: 'b'}, 3 in [1, 3], 3 in range(3, 4))- A. True False False True
- B. True False True True
- C. False False True True
- D. True True True True
Correct answer: B. True False True True
Membership in a dict checks keys, and 3 is a key but '3' is not. Lists check values, and range checks whether the number falls in its arithmetic sequence.
More Python Programming questions
- What is printed? python print(list(zip('ab', 'cd', 'ef'))[1], dict(zip('ab', [1])))
- What is printed? python print(len('héllo'), len('héllo'.encode('utf-8')), 'é'.encode('utf-8'))
- What is printed? python import math print(math.floor(7 / 2) 2 + 7 % 2, 7 // 2 2 + 7 % 2)
- What is printed? python x = [0] 3 x[0] += 1 x = x 2 x[3] += 5 print(x)
- What is printed? python from collections import Counter c = Counter('aab') c.subtract('ab') print(c['a'], c['b'], sorted((+c).items()))
- What is printed? python n = 100 z, p = 0, 5 while p <= n: z += n // p p = 5 print(z, len(str(import('math').factorial(n)))…