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. Epstein 744K posts
- 2. Bill Clinton 74.6K posts
- 3. TravisScott 1,675 posts
- 4. Michael Jackson 30.6K posts
- 5. Elise Stefanik 12K posts
- 6. Dashie 1,209 posts
- 7. Oklahoma 30.9K posts
- 8. Chris Tucker 4,782 posts
- 9. Lamarr 8,782 posts
- 10. The DOJ 154K posts
- 11. Jake Paul 36.5K posts
- 12. Diana Ross 2,408 posts
- 13. Timmy 12.2K posts
- 14. #JakeJoshua 14.3K posts
- 15. ISIS in Syria 14.4K posts
- 16. #RollTide 4,621 posts
- 17. Rays 15.8K posts
- 18. Caroline Dubois N/A
- 19. Slick Willy 3,410 posts
- 20. Marty Supreme 14.8K posts
Loading...
Something went wrong.
Something went wrong.