ProgrammingVery hardProduct-company MCQ pattern
What is printed?
What is printed?
print(1 in {1.0: 'a'}, '1' in {1: 'a'}, 1.0 in {True: 1}, {1, True, 1.0})- A. True False True {1, True}
- B. False False True {1}
- C. True False True {1}
- D. True True True {1}
Correct answer: C. True False True {1}
1 and 1.0 hash and compare equal, so the set and dict tests match. '1' is a different type from 1, so it is not found, and the set keeps only one of 1, True and 1.0.
More Python Programming questions
- What is printed? python d = {} d[1.0] = 'x' d[1] = 'y' print(d, len(d), d[True])
- What is printed? python print(sorted(['b', 'a', 'c'], key=lambda s: -ord(s)))
- What is printed? python print(sorted([0.5, -0.5, 0, True, False], key=abs))
- What is printed? python print(str(2100)[:5], len(str(2100)), str(2100).count('0'))
- What is printed? python print(int('9' 5) 2 // 109, (109 - 1) 2 // 109)
- What is printed? python x = 0 for i in range(1, 101): x += i print(x, x // 2 2 == x, x % 2)