Back to questions
JuniorTheoryCommon
What happens when this program runs?
age = 30
print("Age: " + age)A TypeError is raised
- Expecting
Age: 30, as if Python turned30into text:+never turns a number into text, so astrplus anintraisesTypeError; writestr(age). - Expecting a
ValueError: that one comes from a bad value such asint("2.5"), while mixing astrand anintin+is a wrong type.
- How would you change the second line so that it prints
Age: 30? - What does
print("5" * 3)print, and why is it not an error?