ProgrammingVery hardJEE Advanced · CAT placement
What is printed?
What is printed?
from math import inf print(inf - 1 == inf, 2 * inf, -inf < -10 ** 400, inf > 10 ** 400)
- A. False inf True True
- B. True -inf False True
- C. True inf True True
- D. True inf True False
Correct answer: C. True inf True True
Subtracting 1 from infinity leaves infinity, so the first check is True. Multiplying by 2 keeps infinity, and infinity compares larger than any int, even 10**400.
More Python Programming questions
- What is printed? python print(sum(1 for c in 'a1 b2' if c.isalpha()), sum(1 for c in 'a1 b2' if c.isdigit()), sum(c.isspace() for c in 'a1…
- What is printed? python print(round(2.675, 2), round(2.665, 2), round(1.0049999999999999, 3), round(-2.5, 0))
- What is printed? python print(max('apple', 'banana', key=len), max(['x', 'yy', 'zz'], key=len), min([3, 1, 1.0], key=abs), max([1, 1.0]…
- What is printed? python print(float('0.1') + float('0.2') == 0.3, float('0.30000000000000004') == 0.1 + 0.2…
- What is printed? python s = 'hello' print(s.index('l'), s.rindex('l'), s.find('z'), s.count('l'))
- What is printed? python print(int(str(264) 0 + '7') 2, len(str(7 100)), 7 100 % 10)