Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
35
21
210
37
20천
Answer: Technically, nothing (no returns, doesn't even print quotes) Solution: `*` of str and int gives repetition of string. Eg, "Py" * 3 gives "PyPyPy" If the multiplication is by 0, means 0 repetitions of the str, ie, empty string. So, "Python" * 0 is "" When printed, +
1
0
11
2
1천
strings aren't displayed with enclosing quotes. Hence, print("Python" * 0) is equivalent to print("") which just prints a blank line (not even the quotes.) That's the output.
0
0
2
0
66
United States 트렌드
- 1. Packers 95K posts
- 2. Packers 95K posts
- 3. Good Sunday 52.2K posts
- 4. Caleb Williams 39.1K posts
- 5. DJ Moore 29K posts
- 6. Malik Willis 15.5K posts
- 7. #BearDown 4,712 posts
- 8. And Mary 28.1K posts
- 9. Oregon 36.6K posts
- 10. Happy Winter Solstice 4,366 posts
- 11. Nixon 12.8K posts
- 12. Ben Johnson 10.2K posts
- 13. Doubs 9,088 posts
- 14. #BlackClover 8,757 posts
- 15. Jordan Love 13.2K posts
- 16. Bowen 14K posts
- 17. #Toonami 2,506 posts
- 18. #GoPackGo 7,887 posts
- 19. TOP CALL 7,340 posts
- 20. #GBvsCHI 3,239 posts
Loading...
Something went wrong.
Something went wrong.