Numbers: int and float

Two kinds of numbers

  • int (integer) – a whole number with no decimal point: 7, -3, 2026.
  • float – a number with a decimal point: 3.14, -0.5, 99.0.
apples = 12        # int
price = 45.50      # float
print(apples)
print(price)

Output

12
45.5

Notice that Python prints 45.5, not 45.50. A float doesn't keep extra zeros at the end.

Doing maths with numbers

apples = 12
price = 45.5
print(apples * price)

Output

546.0

When you mix an int and a float, the answer is a float.

Big numbers

You can use underscores to make big numbers easier to read. Python ignores them:

population = 1_400_000_000
print(population)

Output

1400000000

Common mistake: Don't use commas inside numbers. 1,000 is not one thousand in Python – it is two separate values, 1 and 000.

HOME LEARN COMMUNITY DASHBOARD