ProgrammingModerateProduct-company MCQ pattern
What is printed?
What is printed?
print(float('inf') > 2**1000, -float('inf') < -(2**1000), float('inf') == float('inf') + 1)- A. True True True
- B. True True False
- C. False True True
- D. True False True
Correct answer: A. True True True
Infinity compares greater than any int, even one with a thousand digits. Adding 1 to infinity leaves it infinite, so it equals infinity.
More Python Programming questions
- What is printed? python print(repr(0.1), repr(1 / 3), repr(2 / 3), repr(1e-7), repr(100.0))
- What is printed? python print(0.1 3 != 0.3, abs(0.1 3 - 0.3) < 2-52, abs(0.1 3 - 0.3) < 2-54)
- What is printed? python print(bin(255)[2:].rjust(10, '0'), int('0b' + '1' 8, 2) == 255, int('11111111', 2) + 0 == 255)
- What is printed? python s = 'hello world' print(s.count('o'), s.index('o', 5), s.title().split()[1][::-1])
- What is printed? python print(list(reversed(range(3))), list(range(3))[::-1] == list(reversed(range(3))), list(range(3, 0, -1)))
- What is printed? python print('Python'[::2], 'Python'[1::2], 'Python'[-2::-2])