ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(''.join(c.upper() if i % 2 else c for i, c in enumerate('python')))- A. pYtHoP
- B. qYtHoN
- C. pYtHoM
- D. pYtHoN
Correct answer: D. pYtHoN
enumerate counts from 0, so indices 1, 3 and 5 are uppercased. The letters at even positions keep their case.
More Python Programming questions
- What is printed? python print(' '.join(w[::-1] for w in 'hello big world'.split()))
- What is printed? python print(max(len(w) for w in 'the quick brown fox'.split()), [w for w in 'the quick brown fox'.split() if len(w) == 5])
- What is printed? python print(''.join(sorted('hello', key=lambda c: (c not in 'aeiou', c))))
- What is printed? python print(round(0.1 0.1, 3) == 0.01, round(2.345, 2), round(2.355, 2))
- What is printed? python print(max(1, 2.0, True), min([0.0, -0.0, 0]), sum([]) == 0.0)
- What is printed? python print(10100 // 1098, (10100) % 97 == pow(10, 100, 97))