ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print(sum(1 for c in 'Mississippi' if c in 'aeiouAEIOU'), 'Mississippi'.lower().count('s'), 'Mississippi'.find('ss', 3))- A. 4 2 5
- B. 4 4 5
- C. 3 4 2
- D. 4 4 2
Correct answer: B. 4 4 5
Mississippi has four vowels, all i, and four s letters. find('ss', 3) skips the first ss at index 2, so the match at index 5 is returned.
More Python Programming questions
- What is printed? python print([] == [] or 1 / 0, [] and 1 / 0, 0 or 1 and 2)
- What is printed? python print(3 % 2 == 1 and 4 % 2 == 0, 3 // 2 == 1 or 1 / 0)
- What is printed? python print(f'{"":>3}|', f'{"x":^3}|', f'{None!s:>6}|')
- What is printed? python from functools import lrucache @lrucache(maxsize=None) def t(n): if n == 0: return 0 if n < 3: return 1 return t(n…
- What is printed? python from collections import deque def countpaths(g): R, C = len(g), len(g[0]) dist = [[-1] C for in range(R)] ways =…
- What is printed? python def cnt(a, k): pre = {0: 1} s = ans = 0 for x in a: s += x ans += pre.get(s - k, 0) pre[s] = pre.get(s, 0) + 1…