ProgrammingVery hardProduct-company MCQ pattern
What is printed?
What is printed?
a = 10 b = 3 print(a / b * b == a, a // b * b + a % b == a, a % b / b == (a / b) % 1)
- A. True False False
- B. True True True
- C. True True False
- D. False True False
Correct answer: C. True True False
10 / 3 * 3 rounds back to exactly 10.0, and the integer identity always holds. a % b / b is 1/3 computed directly, while (a / b) % 1 is 10/3 rounded before taking the fraction, so they differ in the last bits.
More Python Programming questions
- What is printed? python print(7 % 3 2, (7 % 3) 2, -7 % 3 2, 2 3 2 % 4)
- What is printed? python print(len(' a b '.split()), len(' a b '.split(' ')), len('anbn'.splitlines()), len('anbn'.split('n')))
- What is printed? python print(list('abc'.encode()), 'abc'.encode()[0] + 1, bytes('hi', 'ascii') == b'hi')
- What is printed? python x = 17 print(x.bitlength(), (x & -x).bitlength(), x.bitcount(), bin(x)[2:].zfill(8))
- What is printed? python print(int(2.5 4) // 3, int(10 / 4 2), 10 // 4 2, 10 / 4 // 2)
- What is printed? python print(float(1) / 3 + float(2) / 3 == 1.0, 0.1 0.1 100 == 1.0, 1 - 0.1 9 == 0.1)