ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(' '.join(w[::-1] for w in 'hello big world'.split()))- A. olleh gib dlrow
- B. olleh big world
- C. hello gib dlrow
- D. olleh gib dlrom
Correct answer: A. olleh gib dlrow
split() breaks the sentence into words, each word is reversed by slicing, and join puts single spaces back between them.
More Python Programming questions
- 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))
- What is printed? python print(sorted(['b10', 'b9', 'a10'], key=lambda s: (s[0], int(s[1:]))))