ProgrammingVery hardProduct-company MCQ pattern
What is printed?
What is printed?
print(int(0.1 * 10) == 1, int(0.7 * 10), int(4.35 * 100), round(4.35 * 100))
- A. True 7 435 435
- B. True 7 434 435
- C. False 7 434 435
- D. True 6 434 435
Correct answer: B. True 7 434 435
int truncates toward zero, and 4.35 * 100 is stored just under 435, so int gives 434 while round gives 435. The multiplications by 10 are exact enough here to give 1 and 7.
More Python Programming questions
- What is printed? python print(len(str(264)), 264 // 1019, 264 % 1019, len(str(264 - 1)))
- What is printed? python print(-7 // 2 2 + -7 % 2 == -7, 7 // -2 -2 + 7 % -2 == 7, -(-7 // 2))
- What is printed? python x = 0b1011 print(bin(x << 3), bin(x >> 1), x << 3 >> 3 == x, bin(~x & 0b1111))
- What is printed? python print(3 'ab' == 'ab' 3, 'ab' 3 == 'aba' + 'bab', [0] 3 == [0, 0, 0], ['a'] 2 == 'aa')
- What is printed? python s = 'The Quick' print(s.lower().split(), s.split('Q')[0].strip(), s[s.index(' ') + 1:], s.title().swapcase())
- What is printed? python print('%d items at %.1f%%' % (3, 12.345), '%5.2f|' % -1.005, '%08.3f' % -3.14159)