Both reverse the string the same way. Slice gives ‘nohtyP’, reversed() + join gives ‘nohtyP’ too. So it prints True.
Answer: (A) True The code defines s1 as the string "Python". s2 = s1[::-1] uses Python's slicing syntax to reverse the string s1, resulting in the value "nohtyP". s3 = "".join(reversed(s1)) uses the reversed() function to iterate over the characters of s1 in reverse
🚀 Say hello to Matt Pocock at JSNation! Independent TypeScript educator and builder of awesome self-paced courses at Total TypeScript.
Top engineers. Modern React. Two days in Paris. React Paris 2026 lineup is LIVE.
Both s2 and s3 are created with different ways of reversing strings. But result is same. SO it will orint true.
True. s2 and s3 produce the exact same result s1, but reversed. The final query performs a boolean equality check on two identical values; therefore, the result is True
Actually, s2 is more straightforward and requires less kernel overhead. It would be even more efficient to avoid storing it in a variable and instead generate the query only when needed
United States トレンド
- 1. #BTCCBestCEX 2,689 posts
- 2. Bruce Thornton N/A
- 3. Slept 20.5K posts
- 4. Mets 37.9K posts
- 5. Eileen Higgins 8,460 posts
- 6. Markstrom N/A
- 7. Dodgers 44.5K posts
- 8. Maresca 39.7K posts
- 9. White Sox 3,696 posts
- 10. Clemson 7,467 posts
- 11. Villanova 1,617 posts
- 12. Kentucky State University 3,506 posts
- 13. #ShootingStar N/A
- 14. Diaz 78.7K posts
- 15. Garrison 1,661 posts
- 16. 2026 MLB Draft 2,846 posts
- 17. Roch Cholowsky N/A
- 18. Paolo 10.1K posts
- 19. Stearns 12.4K posts
- 20. Anthony Black 1,141 posts
Something went wrong.
Something went wrong.