skill_completed = "Python Syntax" exercises_completed = 13 points_per_exercise = 5 #The amount of points for each exercise may change, because points don't exist yet point_total = 100 point_total = 100 + (exercises_completed) *(points_per_exercise) print("I got "+str(point_total)+" points!")
Hello Code Academy. I am an absolute beginner to Python and coding in general, as well as a beginner to these forums. So, please let me know if I breached any forum rules or anything like that.
My question is about stage 14/14 “Review” of “Python Syntax” in “Learn Python 2”. Link here and code written above.
What I have learnt so far is that Python can translate different categories of code, an integer into float, for example, or integer into string (or vice versa), in this specific case.
That’s why I am confused about the last line of code above. As I understand, quotation marks make “Python Syntax”, for example, a string (in the first line). Whereas 13 or 5 in the second and third line are integers because they do not have quotation marks and no decimal points so are neither strings nor floats.
Given this information, I am confused as to why the last line of code expresses (point_total) as a string (str is short for string?). Shouldn’t this be expressed as an integer, because we are working with numbers, without quotation marks (point_total equals or corresponds to the integers 13, 5 and 100 in this code).
Therefore, the last line of code seems like it should be int(point_total) not str. However, this did not work: the error message produced was TypeError: cannot concatenate ‘str’ and ‘int’ objects
I hope this question makes sense. Thanks very much in advance for any attention towards this post!