ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(1 == 1.0 == True, {1: 'a'}.get(True))- A. False a
- B. True None
- C. False None
- D. True a
Correct answer: D. True a
1, 1.0 and True compare equal, so the chained comparison is True. True hashes like 1, so the dict lookup with key True finds the value 'a'.
More Python Programming questions
- What is printed? python print([i j for i, j in zip(range(3), range(3, 0, -1))])
- What is printed? python print(''.join(chr(ord('a') + (ord(c) - ord('a') + 3) % 26) for c in 'xyz'))
- What is printed? python import math print(len(str(math.factorial(200))))
- What is printed? python import bisect print(bisect.bisectleft([1, 1, 1], 1), bisect.bisectright([1, 1, 1], 1))
- What is printed? python print(0.1 0.1 == 0.01, round(0.1 0.1, 2) == 0.01)
- What is printed? python print(list(filter(None, [0, 1, '', 'a', None, [], [0]])))