ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
x = 10**20 print(x // 3, x / 3 == x // 3, x % 3)
- A. 33333333333333333333 True 1
- B. 3.3333333333333333e+19 False 1
- C. 33333333333333333334 False 2
- D. 33333333333333333333 False 1
Correct answer: D. 33333333333333333333 False 1
// on ints stays exact, and 10**20 mod 3 is 1 because 10 is congruent to 1. / produces a float, and comparing a float with an int in Python is exact, so the float 3.33e19 does not equal the true integer quotient.
More Python Programming questions
- What is printed? python n = int('9' 30) print(len(str(n + 1)), (n + 1) - 1030)
- What is printed? python print(5 & 3, 5 | 3, 5 ^ 3, ~5, 5 << 2, -5 >> 1)
- What is printed? python print(-1 & 0xFF, -8 >> 1, -1 >> 100, -9 & 7)
- What is printed? python print(1 << 64 == 264, (1 << 64) - 1 & 0xFFFF)
- What is printed? python print(0.1 + 0.2 == 0.3, round(0.1 + 0.2, 10) == 0.3, 0.1 + 0.2)
- What is printed? python print(round(2.5), round(3.5), round(-0.5), round(2.675, 2), round(1.005, 2))