ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
print(type(True + 1).__name__, type(2 * 1.0).__name__)
- A. int float
- B. bool float
- C. int int
- D. float float
Correct answer: A. int float
True behaves as the int 1 in arithmetic, so True + 1 is an int, and an int times a float is a float.
More Python Programming questions
- What is printed? python print(list(enumerate(['x'], 1))[0][0] + 1)
- What is printed? python print(list('ab') == ['a', 'b'], 'ab' == ['a', 'b'])
- What is printed? python print(len(dict.fromkeys('aab')), list(dict.fromkeys('aab')))
- What is printed? python print([x for x in [1, 2, 3] for in range(x)])
- What is printed? python print(sorted(['b10', 'b9', 'a100', 'c2'], key=lambda s: (s[0], int(s[1:]))))
- What is printed? python print(sorted([-2, 1, 2, -1], key=abs))