Numbers at the prompt
At the >>> prompt Python is a calculator. + adds, - subtracts and * multiplies. As in maths, * goes before +, so 2 + 3 * 4 is 14. Brackets change the order: (2 + 3) * 4 is 20.
/ always gives a float, a number with a decimal point: 7 / 2 is 3.5, and even 6 / 2 is 3.0. // divides and drops the fraction, so 7 // 2 is 3. % gives the remainder: 7 % 2 is 1.
Types, line by line
Now a file, tea.py. Every value in it has a type: int for whole numbers such as 5, float for numbers with a decimal point such as 1.5, and str (string) for text in quotes such as "tea".
Python works out the right-hand side first: 2 + 3 is 5. It is a whole number, so its type is int. = stores it under the name cups. Each memory box shows a name, a type and a value.
cups * 1.5 reads cups, 5, from its box. 1.5 has a decimal point, so it is a float, and an int times a float gives a float: 7.5. Floats can be very slightly off: 0.1 + 0.2 is 0.30000000000000004.
Text in quotes is a string, type str. Single and double quotes both work. * repeats a string, so "tea" * 2 is 'teatea'. + joins two strings end to end, and len() counts the characters.
print() takes values of any type, turns each one into text and writes them with one space between: teatea 7.5. The string loses its quotes on screen; the quotes only mark where text starts and ends.
+ joins a string only to another string. str(cups) turns the int 5 into the text '5', so the two strings join into Cups: 5. int() and float() convert the other way: int("42") is the number 42.
Mixing types
Leave out str() and Python stops at line 5: it will not join a number to text. Lines 1 to 4 already ran, so teatea 7.5 is on the screen above the TypeError.
Try it yourself
;; step 1/9 >>> 2 + 3 * 4 14 >>> (2 + 3) * 4 20 >>> 10 - 4 6 >>> 2 ** 10 # ** is "to the power of" 1024
The $ and >>> at the start of a line are prompts printed for you: you do not type them. On macOS and Linux the command may be python3. Python 3.11 and later also print a line of ~ and ^ under the failing code, pointing at the +; the figure leaves it out. In the real message, the ... is the full path to the file.