Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
35
21
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. Bama 26.5K posts
- 2. Ryan Williams 3,089 posts
- 3. Oklahoma 45.6K posts
- 4. Mateer 8,896 posts
- 5. Ty Simpson 3,400 posts
- 6. Epstein 1.05M posts
- 7. Woodley 14.9K posts
- 8. #RollTide 8,322 posts
- 9. Clinton 195K posts
- 10. #CFBPlayoff 10.5K posts
- 11. Anderson Silva 10.7K posts
- 12. #JakeJoshua 28.6K posts
- 13. #SmackDown 17.2K posts
- 14. DeBoer 5,931 posts
- 15. Chris Finch 2,091 posts
- 16. Alycia 5,331 posts
- 17. #OPLive 1,940 posts
- 18. Sixers 5,702 posts
- 19. Maxey 3,510 posts
- 20. Venables 1,868 posts
Loading...
Something went wrong.
Something went wrong.