Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
35
20
208
37
20K
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
1K
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 Trends
- 1. Sam Darnold 5,633 posts
- 2. Seahawks 36.3K posts
- 3. Rams 44.9K posts
- 4. Kenneth Walker 2,882 posts
- 5. Cooper Kupp 1,836 posts
- 6. Portuguese 15.8K posts
- 7. Portugal 41K posts
- 8. #TNFonPrime 2,835 posts
- 9. Salem 33.8K posts
- 10. Josh Wallace N/A
- 11. Claudio Manuel Neves-Valente 2,726 posts
- 12. Kubiak 1,300 posts
- 13. McVay 3,136 posts
- 14. New Hampshire 16.8K posts
- 15. Ben Shapiro 20.2K posts
- 16. #LARvsSEA 1,345 posts
- 17. Kennedy Center 105K posts
- 18. Charbonnet 1,736 posts
- 19. Puka 29.8K posts
- 20. Jalen Johnson 2,837 posts
Loading...
Something went wrong.
Something went wrong.