ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
values = [2.0, 2, '2'] print(len(set(values[:2])), len(set(values)), values[0] == values[1] == 2)
- A. 2 2 True
- B. 1 2 True
- C. 1 3 True
- D. 1 2 False
Correct answer: B. 1 2 True
2.0 and 2 are the same set element, but the string '2' is different. The chained comparison checks 2.0 == 2 and 2 == 2, both True.
More Python Programming questions
- What is printed? python t = 3 print(t // 2 if t % 2 else t / 2, 1 if t else 0, t and 0, t or 0, not t)
- What is printed? python print(int(0.999999999999999999999), round(0.4999999999999999), round(-0.4999999999999999), int(-0.9))
- What is printed? python print(f'{12.0:g}', f'{12.5:g}', f'{0.00001234:g}', f'{123456789:g}', f'{1.5e300:g}')
- What is printed? python print(10 18 10 18 // 10 35, 2 64 // 2 32, 2 64 % 2 32)
- What is printed? python x = 1 << 200 print(x.bitlength(), len(str(x)), x % 1000, (x >> 190) & 0xFF)
- What is printed? python print(f'{210:,}', f'{210:x}', f'{210:b}', f'{-210:>8}'.strip())