ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(''.join(sorted(set('hello'), key=ord)))- A. lheo
- B. ehlo
- C. hello
- D. olhe
Correct answer: B. ehlo
A set of the characters is {h, e, l, o}, which has no duplicates. Sorting those by code point gives e, h, l, o.
More Python Programming questions
- What is printed? python print(len({0.0, -0.0, 1}), hash(1) == hash(1.0) == hash(True))
- What is printed? python print(1 == 1.0 == True, {1: 'a'}.get(True))
- What is printed? python print([i j for i, j in zip(range(3), range(3, 0, -1))])
- What is printed? python print(''.join(chr(ord('a') + (ord(c) - ord('a') + 3) % 26) for c in 'xyz'))
- What is printed? python import math print(len(str(math.factorial(200))))
- What is printed? python import bisect print(bisect.bisectleft([1, 1, 1], 1), bisect.bisectright([1, 1, 1], 1))