ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
print(sorted('bca', reverse=True)[0], 'bca'.index('c'))- A. a 2
- B. c 2
- C. c 1
- D. b 2
Correct answer: C. c 1
Reversed sorting puts c first, and index returns the position of c in bca, which is 1 because b comes before it.
More Python Programming questions
- What is printed? python from collections import defaultdict d = defaultdict(int) d['x'] += 2 d['y'] print(dict(d))
- What is printed? python print(list(map(pow, [2, 3], [3, 2])))
- What is printed? python print(min(['10', '9', '2']), min([10, 9, 2]))
- What is printed? python s = {1, 2} t = s t |= {3} print(s, s is t)
- What is printed? python print(int(3.99), int(-3.99), round(3.5), round(4.5))
- What is printed? python print('ab' in ['ab', 'cd'], 'ab' in 'cdab', [] in [[]])