ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(1 == 1.0 == True, 2 == 2.0 != 3.0)
- A. True False
- B. True True
- C. False True
- D. False False
Correct answer: B. True True
Chained comparisons test each adjacent pair. 1 == 1.0 and 1.0 == True both hold, and 2 == 2.0 and 2.0 != 3.0 both hold.
More Python Programming questions
- What is printed? python print(3 -2 9, (3 -2) 9 == 1.0, 3 -2 9 == 1)
- What is printed? python print(1000000 1000000 == 1012, 106 2 == 1012, 23 2 == 64)
- What is printed? python print(7 & -7, 7 | -7, 7 ^ -7, ~7 & 0xF)
- What is printed? python print(bin(5 & -5), (5).bitcount(), (-5).bitcount(), (-5).bitlength())
- What is printed? python print(0b1 << 100 > 299, (1 << 100).bitlength(), len(bin(1 << 100)) - 2)
- What is printed? python print(float(3) / 2 == 1.5, 3 // 2.0, 3 / 2.0 // 1)