ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(1 < 2 < 3 != 4, (1 < 2) < 3, 2 ** -1, 2 ** 0.5 ** 2)
- A. True True 0.5 2.0000000000000004
- B. False True 0.5 1.189207115002721
- C. True True 0.5 1.5
- D. True True 0.5 1.189207115002721
Correct answer: D. True True 0.5 1.189207115002721
Comparisons chain, so 1 < 2 < 3 != 4 is True. ** is right-associative, so 2 ** 0.5 ** 2 is 2 ** 0.25. Parsing it as (2 ** 0.5) ** 2 gives 2.0000000000000004.
More Python Programming questions
- What is printed? python print(int(1e22) == 1022, int(1e23) == 1023, 1e23 == 1023, float(1023) == 1e23)
- What is printed? python print(0.1 + 0.7, 0.1 7, round(0.1 7 10), 3 0.1 == 0.30000000000000004)
- What is printed? python print((-1) 0.5, (-1) 2, (-8) (1 / 3), -1 0.5)
- Which three lines are printed? python import sys print(sys.getintmaxstrdigits()) try: int('1' 5000) print('parsed') except ValueError…
- What is printed? python import math print(math.isclose(0.1 + 0.2, 0.3), math.isclose(1e-12, 0), math.isclose(1e-12, 0, abstol=1e-9))
- What is printed? python print(int('١٢٣') + 1, 'ß'.upper(), 'Dž'.lower(), len('ß'.upper()))