ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(float('1e3') == 1000, float('1E-2') * 100, float(' .5 '), float('5.'))- A. True 0.01 0.5 5.0
- B. True 1.0 0.25 5.0
- C. True 1.0 0.5 5.0
- D. True 1.0 0.5 5
Correct answer: C. True 1.0 0.5 5.0
float accepts a bare leading dot, a trailing dot, an upper-case E and surrounding spaces. 0.01 * 100 happens to round to exactly 1.0 in binary.
More Python Programming questions
- What is printed? python print('{0:.2%}'.format(0.12345), '{:,}'.format(1234), '{:e}'.format(0), '{:.0f}'.format(0.5))
- What is printed? python print(0.1 + 0.2 == 0.3 or 'no', 0.5 + 0.25 == 0.75 and 'yes')
- What is printed? python print(divmod(-7, 3), divmod(7, -3), divmod(-8.5, 4))
- What is printed? python print(abs(-7) // 2 -1, -abs(-7) // 2, -(abs(-7) // 2))
- What is printed? python x = 255 print(f'{x:08b}', f'{x:o}', f'{x:X}', f'{x:#010x}')
- What is printed? python print(int('11', 2) + int('11', 8) + int('11', 16))