ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(int('12') * 2 ** 3, float('12e3') // 1000, float('1_000.5e1'))- A. 96 12.0 10005.0
- B. 96 12 10005.0
- C. 96 12.0 1000.5
- D. 96 24.0 10005.0
Correct answer: A. 96 12.0 10005.0
2 ** 3 is 8, so 12 * 8 is 96. float() accepts underscores and exponents, and floor division of a float returns a float, so 12e3 // 1000 is 12.0.
More Python Programming questions
- What is printed? python import math print(math.gcd(-12, 18), math.gcd(12, -18), math.lcm(-4, 6), math.gcd(0, 0))
- What is printed? python def digitssum(n): return sum(int(c) for c in str(abs(n))) print(digitssum(-9075), digitssum(1020), digitssum(0))
- What is printed? python x = 1020 + 1 y = float(x) print(int(y) == x, int(y) - x, y == 1020, float(x) == y)
- What is printed? python import math print(math.floor(1e300) == 10300, math.floor(1e300) == int(1e300), round(1e300) == 10300)
- What is printed? python print(0.1 + 0.2 != 0.3, (0.1 + 0.2) - 0.3 < 1e-16, abs((0.1 + 0.2) - 0.3) <= 5e-17)
- What is printed? python print(max('zebra', 'Zebra'), min('a', 'B'), sorted('bA', key=ord)[0], 'bA' > 'Ab')