ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print(hash(()) == hash(()), (1, 2) < (1, 2, 0), 'b' * 2 > 'ab' * 2, (1, 'b') < (1, 'a'))
- A. False True True True
- B. True False True False
- C. True True False False
- D. True True True False
Correct answer: D. True True True False
Equal tuples hash equally, and a prefix of a tuple is smaller than the longer tuple. bb is greater than abab because b is greater than a at the first position. (1, 'b') is not less than (1, 'a').
More Python Programming questions
- What is printed? python print(sorted(['b', 'B', 'a'], key=lambda s: (s.lower(), s)))
- What is printed? python from math import prod print(prod([2, 3, 4]), prod([]), prod([0.5, 4]), prod(range(1, 4), start=10))
- What is printed? python print(2 -1 2 1, 2 -(1 2) 1, (2 -1) (2 1))
- What is printed? python print('%-5s|%5s|' % ('ab', 'cd'), '%(x)d-%(y)s' % {'x': 1, 'y': 'z'})
- What is printed? python print(0.1 3 == 0.30000000000000004, 0.1 3 - 0.3 == 5.551115123125783e-17, 0.3 - 0.1 3 == -5.551115123125783e-17)
- What is printed? python print(len('ab' + 'c' 0), 'ab'[1:][0] 2, ('ab' 2)[::3])