ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(''.join(reversed('ab' * 2)), 'ab'[::-1] * 2 == 'baba')- A. abab True
- B. baba False
- C. baba True
- D. abab False
Correct answer: C. baba True
Reversing 'abab' gives 'baba'. The slice 'ab'[::-1] is 'ba', and repeating it twice gives 'baba'.
More Python Programming questions
- Which operation is O(1) on average in CPython?
- A loop runs s += c for 100000 single characters in CPython. Which statement is most accurate?
- Which statement about converting a string to an int in Python 3.13 is correct?
- What relative and absolute tolerances does math.isclose use by default?
- Which key sorts records by score descending and then by name ascending, using one stable sort?
- What is the largest float that is less than 1.0 in Python, as printed by repr?