Numbers are one of the most common things you’ll work with in Python. Whether you’re calculating scores, prices, dates, or distances — numbers are everywhere in your code.
Python gives you a few different ways to represent numbers, depending on what kind of value you need. Let’s look at the main ones and how to use them.
Integers
Integers are whole numbers — no decimals. They can be positive, negative, or zero. You’ll use them for counting, tracking years, indexing lists, and anything that doesn’t need a fraction.
You can do basic maths with integers like addition, subtraction, multiplication, and more — no extra steps needed.
age = 25
year = 2025
print(age + 1) # 26
print(year - 2000) # 25
Floats
Floats are numbers with decimal points. You’ll use these when precision matters — like money, measurements, averages, or percentages.
One heads-up: floats can sometimes give you tiny rounding errors (like 11.488499999), but that’s totally normal in programming. They still work just fine for most things.
price = 9.99
tax = 0.15
print(price * (1 + tax)) # 11.4885
Arithmetic Operators
Python lets you do math with easy-to-remember symbols. Here are the main ones:
+for addition-for subtraction*for multiplication/for division%for modulus (the remainder after division)**for exponent (power)
print(10 / 3) # 3.333...
print(10 % 3) # 1
print(2 ** 4) # 16
Interactive Exercise: Calculate a Discount
Let’s put this into practice. Change the values below to try out different discount scenarios. This helps you get used to working with numbers in a real-world situation.
price = 120
discount = 0.2
# Calculate discounted price
final_price = price * (1 - discount)
print("Final price:", final_price)
Numbers are the backbone of so many programs — from simple games to complex apps. Once you’re comfortable working with integers, floats, and math operators, you’re ready to take on more advanced problems and data types.