ProgrammingVery hardProduct-company MCQ pattern
What is printed?
What is printed?
import math print(math.floor(1e300) == 10**300, math.floor(1e300) == int(1e300), round(1e300) == 10**300)
- A. False True False
- B. True True False
- C. False False False
- D. False True True
Correct answer: A. False True False
1e300 is not exactly 10**300 as a double, so the int values differ. floor and int both give the exact value of the double, so they agree, while round gives the same non-matching integer.
More Python Programming questions
- What is printed? python print(0.1 + 0.2 != 0.3, (0.1 + 0.2) - 0.3 < 1e-16, abs((0.1 + 0.2) - 0.3) <= 5e-17)
- What is printed? python print(max('zebra', 'Zebra'), min('a', 'B'), sorted('bA', key=ord)[0], 'bA' > 'Ab')
- What is printed? python print([1, 2] < [1, 2, 0], [1, 2] < [1, 3, 0], (1, 2) < (1, 2, 0), 'ab' < 'abc')
- What is printed? python print(hex(255), hex(-255), oct(-8), bin(0), int('-ff', 16), int('0xFF', 0))
- What is printed? python print(int('8' 3) % 7, int('8' 3, 16) % 7, pow(10, 3, 7), 888 % 7)
- What is printed? python print(0.1 0.1, 0.1 0.1 == 0.01, round(0.1 0.1, 2) == 0.01, 10 0.1 0.1 10 == 1)