Lesson 4: Numbers and Math

⏱ ~20 min Lesson 4 of 10 💚 Free

Python is a fantastic calculator! It can add, subtract, multiply, divide, and much more — instantly, with numbers of any size.

Key Concepts

Basic Operators

Python uses + for add, - for subtract, * for multiply, / for divide. It also has ** for exponents (2**3 = 8) and % for remainder (10 % 3 = 1).

Order of Operations

Python follows PEMDAS just like math class: Parentheses first, then Exponents, then Multiply/Divide, then Add/Subtract. Use parentheses when in doubt!

Integer vs Float

Whole numbers like 5 are integers. Numbers with decimals like 3.14 are floats. When you divide two integers in Python 3, you always get a float: 7/2 = 3.5.

🆕 Try It: Live Python

Try it — edit the code and click Run!

✅ Check Your Understanding

1. What does ** do in Python?

2. What is 17 % 5?

3. What type is the result of 7 / 2?