ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(1 == 1.0 and '1' != 1, [1, 2] == [1.0, 2.0], (1, 'a') == (1.0, 'a'))
- A. True True True
- B. True False True
- C. False True True
- D. True True False
Correct answer: A. True True True
Numbers of different types compare by value, so 1 == 1.0 holds, and lists and tuples compare element by element. A string is never equal to a number.
More Python Programming questions
- What is printed? python print(set([1, 2]) == {1.0, 2.0}, {1: 'x'}.get(1.0), {'1': 2}.get(1))
- What is printed? python print(2 63 - 1 == 9223372036854775807, (2 63) % 10, -2 63 // 10)
- What is printed? python print(str(10 15 / 10), str(10 16 / 10), 10 16 // 10)
- What is printed? python print('%.3g' % 0.0001234, '%.3g' % 123456.0, '%g' % 0.5)
- What is printed? python print(max('7', '10'), max(7, 10), min('7', '10'), '7' > '10')
- What is printed? python print(len(f'{3.5:>8.2f}'), f'{-3.5:08.1f}', f'{12:#06x}', f'{7:+05d}')