โ† Back to Python Course
๐Ÿ Python Playgroundยท20 minยทBeginner
๐Ÿ”ข

Numbers & Math

Python is a super calculator!

Discover how Python can do math โ€” addition, subtraction, multiplication, division, and more!

๐Ÿ“–

What we are learning

Python loves math! You can use it like a calculator to add, subtract, multiply, and divide. You can also store the results in variables and use them later. Let us crunch some numbers!

๐Ÿ’ก Think of it like this:

Think of Python as the world's fastest calculator. You type in a math problem, hit run, and boom โ€” the answer appears instantly. No buttons to press, no batteries needed!

๐ŸŒŸ

Why it matters

Math is everywhere in programming. Games use it for scoring, apps use it for prices, and robots use it to figure out how far to move.

Where you see this in real life:

  • โœ“Games calculate damage, scores, and health points
  • โœ“Shopping apps calculate totals, taxes, and discounts
  • โœ“Weather apps calculate temperatures and wind speeds
๐ŸŽฏ

By the end, you can:

  • 1.Do basic math operations in Python
  • 2.Use math with variables
  • 3.Understand integer division and modulo
๐Ÿ”ค

New words

integerfloatadditionsubtractionmultiplicationdivisionmodulo
๐Ÿ
What is 15 + 27 times 3? Try to figure it out in your head, then let Python check your answer!
๐Ÿค“

Fun Fact!

Python can calculate numbers so big they would not fit on a million calculators. Try printing 2 ** 100!

๐Ÿ”ข Python the Calculator

Python is amazing at math! You can use it like a super-powered calculator. Just type a math expression and Python solves it instantly.

โž• Basic Math Operations

+
Add
-
Subtract
*
Multiply
/
Divide
๐ŸTry basic math!
main.py
โ— Output
Python can add, subtract, multiply, and divide!

๐Ÿงฎ Math with Variables

You can store numbers in variables and do math with them!

๐ŸMath with variables
main.py
โ— Output
Click โ–ถ Run to see the output!

๐Ÿค“ Two Special Operators

// Integer Division

Divides and throws away the decimal part

10 // 3 = 3

% Modulo (Remainder)

Gives you the remainder after division

10 % 3 = 1
๐ŸTry // and %
main.py
โ— Output
Click โ–ถ Run to see the output!
๐Ÿ
Did you know? The * symbol means multiply in Python, not x! And / means divide, not รท!
๐Ÿง 

Quick Quiz!

+10 XP

What does the % (modulo) operator do in Python?

๐Ÿ
Finished the lesson? Click the button to mark it complete and earn XP!