Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
35
20
209
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. Jake Paul 159K posts
- 2. Bama 37.9K posts
- 3. Oklahoma 63.2K posts
- 4. #RollTide 16.3K posts
- 5. Mateer 11.7K posts
- 6. Ryan Williams 3,682 posts
- 7. Rose Bowl 4,452 posts
- 8. #CFBPlayoff 15K posts
- 9. 6ix9ine 5,049 posts
- 10. #boxing 8,202 posts
- 11. Clinton 224K posts
- 12. Epstein 1.16M posts
- 13. Ty Simpson 5,783 posts
- 14. Wolves 20.4K posts
- 15. Tyson Fury 2,853 posts
- 16. KO'd 7,994 posts
- 17. Hulk Hogan 2,633 posts
- 18. Finch 7,551 posts
- 19. Woodley 17.3K posts
- 20. Dort 9,527 posts
Loading...
Something went wrong.
Something went wrong.