A program can calculate with values instead of writing out every result. Python distinguishes whole numbers, called integers (int), from floating-point numbers (float), which approximate real numbers. A float can have a whole-number value such as 4.0; the decimal point describes its representation, not a requirement for a nonzero fractional part.
items = 7
cost = 2.5
print(items + 3)
print(items - 3)
print(items * cost)
print(items / 2)
10
4
17.5
3.5
+, -, *, and / add, subtract, multiply, and divide. In Python 3, / produces a float even when both operands are integers and the result is whole: 8 / 2 is 4.0. Dividing by zero raises ZeroDivisionError; it does not produce a usable answer.
Expressions follow precedence: multiplication and division come before addition and subtraction. Parentheses make grouping explicit. Exponentiation uses ** and happens before multiplication. An exponent describes repeated multiplication: 3 ** 2 means three times three. The symbol ^ is bitwise XOR in Python, not exponentiation.
print(2 + 3 * 4)
print((2 + 3) * 4)
print(3 ** 2)
14
20
9
Floats cannot represent every decimal fraction exactly. For example, 0.1 + 0.2 may display 0.30000000000000004. For currency, integer minor units or the standard-library decimal module may be more appropriate than assuming floats are exact.