ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print(len({1, 1.0, True, '1'}), len({'1', 1}), {1, 2} == {2.0, 1.0}, {0} == {False})- A. 2 1 True True
- B. 2 2 True True
- C. 2 2 False True
- D. 3 2 True True
Correct answer: B. 2 2 True True
1, 1.0 and True are one set element, and '1' is a different element, giving two. Sets compare equal when their elements compare equal, and False equals 0.
More Python Programming questions
- What is printed? python print(float('1' + '0' 308) == 1e308, 10 308 > 1e308, 10 308 < 1e308)
- What is printed? python from functools import reduce print(reduce(lambda acc, ch: acc 10 + int(ch), '2024', 0), reduce(lambda acc, ch: acc…
- What is printed? python print('{0:>{1}}'.format('x', 3), '{:0>3}'.format(7), '{:x<4}'.format('ab'), '{:^7.3f}|'.format(2.5))
- What is printed? python print(1 == True == 1.0, 2 > 1 == True, (2 > 1) == True, 1 < 2 == True)
- What is printed? python print(int(' 0x1f ', 16), int('1e3', 16), float('1e3'))
- What is printed? python from collections import Counter c = Counter(['x', 'y', 'x', 'z', 'y', 'x']) print(c.mostcommon()…