ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print('Python'[::2], 'Python'[1::2], 'Python'[-2::-2])- A. Pto yhn Ptoh
- B. Pto ynh otP
- C. Pto yhn otP
- D. Pty yhn otP
Correct answer: C. Pto yhn otP
[::2] takes every second character starting at P, and [1::2] starts at y. [-2::-2] walks backward from o, giving o, t and P.
More Python Programming questions
- 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'))…
- What is printed? python print(len([x for x in range(1, 100) if x % 3 == 0 or x % 5 == 0]), sum(x for x in range(1, 100) if x % 3 == 0 or x…
- What is printed? python print(bin(10)[::-1], int(''.join(reversed(bin(10)[2:])), 2), format(10, 'b').zfill(6))