ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
s = 'hello world'
print(s.count('o'), s.index('o', 5), s.title().split()[1][::-1])- A. 2 7 dlroW
- B. 2 4 dlroW
- C. 2 7 World
- D. 1 7 dlroW
Correct answer: A. 2 7 dlroW
'o' appears twice, and searching from index 5 finds the one at index 7. title() makes 'World', and reversing it gives 'dlroW'.
More Python Programming questions
- What is printed? python print(list(reversed(range(3))), list(range(3))[::-1] == list(reversed(range(3))), list(range(3, 0, -1)))
- What is printed? python print('Python'[::2], 'Python'[1::2], 'Python'[-2::-2])
- What is printed? python x = 3.0 print(x.isinteger(), (3.5).isinteger(), int(x) is x, type(int(x)).name)
- What is printed? python print(round(1e-20, 25) == 1e-20, round(123.456, 10), round(0.5 + 1e-17, 0))
- What is printed? python def f(s): return s.lower() == s[::-1].lower() print(f('Aba'), f('Ab'), f(''), f('A'))
- What is printed? python import itertools print(list(itertools.accumulate([1, 2, 3, 4])), list(itertools.accumulate('ab'))…