ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print(abs(-0.0), abs(-3), abs(True), abs(-2 ** 63))
- A. 0 3 1 9223372036854775808
- B. 0.0 3 True 9223372036854775808
- C. 0.0 3 1 9223372036854775808
- D. 0.0 3 1 9223372036854775807
Correct answer: C. 0.0 3 1 9223372036854775808
abs of -0.0 is the float 0.0, and abs of -3 is 3. abs(True) is the integer 1, and the integer 2**63 has no overflow in Python.
More Python Programming questions
- What is printed? python print(bool(0.0 or 0j), bool(0j or 1j), 0j == 0, 1j 1j)
- What is printed? python print([x for x in range(5) if x % 2], [x for x in 'a1b2' if x.isdigit()], {x % 3 for x in range(6)})
- What is printed? python print(str(()), str([()]), repr(('a',)), str(('a', 1)))
- What is printed? python x = 10 def f(): return x x = 20 print(f(), (lambda y=x: y)(), [lambda: i for i in range(2)][1]())
- What is printed? python print(list(map(int, '1 2 3'.split())), list(map(str.upper, 'ab')), sum(map(int, '9' 3)) % 7)
- What is printed? python print('%.3g' % 0.0001234, '%.3g' % 123456.0, '%g' % 1e-5, '%G' % 1e-10)