Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
35
20
209
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. Rays 13.1K posts
- 2. Shane Baz 2,654 posts
- 3. Brandon Lowe 2,352 posts
- 4. Merry Christmas 175K posts
- 5. Tucker 170K posts
- 6. NextNRG 3,737 posts
- 7. Western Michigan 1,968 posts
- 8. Kennesaw State 1,900 posts
- 9. #FursuitFriday 14.2K posts
- 10. #FanCashDropPromotion 3,138 posts
- 11. Mangum 1,400 posts
- 12. Kennedy Center 186K posts
- 13. #jonita 41.9K posts
- 14. Mike Burrows 1,393 posts
- 15. #Rashmer 29.5K posts
- 16. Happy Holidays 51K posts
- 17. Bodine 1,893 posts
- 18. Astros 3,338 posts
- 19. Jake Paul 30K posts
- 20. Ben Shapiro 94.1K posts
Loading...
Something went wrong.
Something went wrong.