ProgrammingVery hardJEE Advanced · CAT placement
What is printed?
What is printed?
print(int(1e22) == 10**22, int(1e23) == 10**23, float(10**22) == 1e22)
- A. True True True
- B. True False True
- C. False False True
- D. True False False
Correct answer: B. True False True
10**22 is exactly representable as a double, so the float and the int agree. 10**23 is not, and the literal 1e23 rounds to a slightly different integer.
More Python Programming questions
- What is printed? python print('{:+}'.format(-0.0), '{:+}'.format(0), '{:+.1f}'.format(-0.04), '{:+}'.format(5))
- What is printed? python print(hex(255).upper(), int('FF', 16) == 0xff, '%X' % 255 == hex(255)[2:].upper(), oct(64))
- What is printed? python print(0.1 + 0.2 != 0.3, 1 if 0.1 + 0.2 else 0, 0.0 or -0.0 or 'x', 0 and 1 or 2)
- What is printed? python print(len('u0301'), len('au0301'), 'au0301'.upper() == 'Au0301')
- What is printed? python words = 'the quick the lazy'.split() counts = {} for w in words: counts[w] = counts.get(w, 0) + 1 print(counts…
- What is printed? python print(sorted(['B', 'a', 'C'], key=str.casefold) == ['a', 'B', 'C'], sorted(['B', 'a', 'C']) == ['B', 'C', 'a']…