ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
inf = float('inf')
print(inf > 10**400, inf - inf == 0, -inf < -10**400, inf == inf)- A. True True True True
- B. True False True True
- C. False False True True
- D. True False False True
Correct answer: B. True False True True
Comparisons between floats and huge ints work in Python, so inf is greater than 10**400. inf - inf is NaN, which is not equal to 0, and -inf is below any finite number, while inf == inf holds.
More Python Programming questions
- What is printed? python print(len(str(21000)), sum(int(d) for d in str(2100)))
- What is printed? python import math print(math.gcd(0, -6), math.lcm(4, 6), -7 % -3, math.lcm(0, 5))
- What is printed? python x = 6 print(x & (x - 1), x & -x, (x ^ (x >> 1)) & 1, x.bitlength(), (-x).bitlength())
- What is printed? python print(bin(10 ^ 6), 10 ^ 6 ^ 6, 3 ^ 5 ^ 3 ^ 5, ~-1, -~1)
- What is printed? python a = 1 if 3 > 2 else 0 print(a << 3 | 1, a << (3 | 1), 2 + 3 4 2 // 8 % 5)
- What is printed? python print(1 < 2 < 3 != 4, (1 < 2) < 3, 2 -1, 2 0.5 2)