ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(int(0.999999999999999999999), round(0.4999999999999999), round(-0.4999999999999999), int(-0.9))
- A. 0 0 0 0
- B. 1 1 -1 0
- C. 1 0 -1 0
- D. 1 0 0 0
Correct answer: D. 1 0 0 0
The literal 0.999999999999999999999 is the double 1.0, so int gives 1. Values just under one half round to zero, and int truncates -0.9 toward zero.
More Python Programming questions
- What is printed? python print(f'{12.0:g}', f'{12.5:g}', f'{0.00001234:g}', f'{123456789:g}', f'{1.5e300:g}')
- What is printed? python print(10 18 10 18 // 10 35, 2 64 // 2 32, 2 64 % 2 32)
- What is printed? python x = 1 << 200 print(x.bitlength(), len(str(x)), x % 1000, (x >> 190) & 0xFF)
- What is printed? python print(f'{210:,}', f'{210:x}', f'{210:b}', f'{-210:>8}'.strip())
- What is printed? python print(str(round(2.5)), str(round(3.5)), round(2.5 + 0.0001), round(-2.5 - 0.0001))
- What is printed? python s = 'ab' 2 + 'c' print(s.endswith('bc'), s.startswith('ab', 2), s.find('ab', 1), s.count('ab'))