ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print(str(1e-4), str(1e-5), str(123456789.0), str(1234567890123456789.0))
- A. 0.0001 1e-05 123456789.0 1.2345678901234568e+18
- B. 0.0001 1e-5 123456789.0 1.2345678901234568e+18
- C. 0.0001 1e-05 123456789 1.2345678901234568e+18
- D. 0.0001 1e-05 123456789.0 1.2345678901234567e+18
Correct answer: A. 0.0001 1e-05 123456789.0 1.2345678901234568e+18
str() of a float uses scientific notation below 1e-4 with at least two exponent digits. A float with no fraction still shows .0, and a value of 1.2e18 uses the shortest round-trip digits.
More Python Programming questions
- What is printed? python print(18 // 4 if False else 'na', 'na' 2 + 'ba')
- What is printed? python print(all(c.islower() for c in 'abc'), any(c.isdigit() for c in 'abc'), 'abc'.isascii() and 'é'.isascii())
- What is printed? python from collections import deque d = deque('abc') d.rotate(1) d.appendleft('z') print(''.join(d), d.pop())
- What is printed? python print(len(bin(255)), bin(255).count('0'), bin(-255).count('1'))
- What is printed? python print('%s' % 'x' 3, '%s' 2 % ('a', 'b'), '%s' % ('x' 3))
- What is printed? python print(3 'a' + 'b', 'c' 3 + 'd')