ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print(str(1.0), str(1), str(1.0e0), str(10.0 ** 0), repr(1e0))
- A. 1.0 1 1.0 1 1.0
- B. 1.0 1 1 1.0 1.0
- C. 1 1 1.0 1.0 1.0
- D. 1.0 1 1.0 1.0 1.0
Correct answer: D. 1.0 1 1.0 1.0 1.0
Float literals and float results print with a decimal point, even when the value is whole. The integer 1 prints without one, and 10.0 ** 0 is a float.
More Python Programming questions
- What is printed? python print(7 & ~1, 7 >> 1 << 1, (7 | 8) & 12, 6 ^ 3 ^ 3)
- What is printed? python print(sorted([(-1, 'a'), (1, 'b'), (-1, 'c')], key=lambda t: t[0], reverse=True))
- What is printed? python x = 'abc' y = x.upper() z = x.upper().lower() print(y, z == x, x.upper().upper() == y, len(y + z))
- What is printed? python print(int('0009'), float('009.50'), int(' -0 '), str(-0))
- What is printed? python print(len(str(2 64)), str(2 64)[:4], 2 64 % 1000)
- What is printed? python print('%c%c' % (72, 105), chr(0x263A) == 'u263a', ord('A') + 1, chr(ord('a') + 25))