ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(''.join(sorted('banana', reverse=True)), len(set('abcABC'.lower())), 'ABC'.isupper())- A. aaabnn 3 True
- B. nnbaaa 3 True
- C. nnbaaa 6 True
- D. nnbaaa 3 False
Correct answer: B. nnbaaa 3 True
Reverse sorting puts n first, then b, then the three a's. Lowercasing gives abcabc, which has three distinct letters. 'ABC'.isupper() is True.
More Python Programming questions
- Which implementation of "count how many times each character appears in s" is the best choice in Python when len(s) = 2 10^5?
- What is printed? python from itertools import accumulate print(list(accumulate([1, 2, 3], initial=0)), next(iter(sorted({3, 1, 2}))))
- What is printed? python st = [] for t in '2 1 + 3 '.split(): if t.isdigit(): st.append(int(t)) else: b = st.pop() a = st.pop() st.append(a…
- What is printed? python a = [-2, 1, -3, 4, -1, 2, 1, -5, 4] best = cur = a[0] for x in a[1:]: cur = max(x, cur + x) best = max(best, cur)…
- What is printed? python print(sum(bin(i).count('1') for i in range(8)))
- What is printed? python seen = {} for i, x in enumerate([2, 7, 11, 15]): if 9 - x in seen: print((seen[9 - x], i)) break seen[x] = i