๐Ÿš€ New batches open: Advanced Excel โ€ข Power BI โ€ข SQL โ€ข AI for Analytics โ€” Book a free demo

Day 2 โ€” Python numbers and arithmetic

Python is a very good calculator. Today you learn every operator you will need for data work.

The operators

Notice the last one 10 / 3 gives 3.3333333333333335, and even 4 / 2 gives 2.0, not 2. In Python 3, a single slash always produces a decimal.

Floor division and remainder

% is far more useful than it looks โ€” it is how you test whether a number divides evenly.

Powers

Order of operations

Same rules as school maths: brackets, then powers, then ร— and รท, then + and โˆ’.

Updating a variable

+= means "add this to what is already there". You will use it constantly in loops.

A real calculation

round()

Money should almost never be printed with 12 decimal places.

Try these yourself

  1. Work out 15% of 82000.
  2. Check whether 4567 is even using %.
  3. Calculate the average of 42000, 38500 and 51200.
  4. Round 3.14159 to 3 decimal places.

Ready for pandas and real projects?

This tutorial covers core Python. Our Data Analytics course takes you into pandas, NumPy, real files and visualisation, with mentor support and portfolio projects.

See the course โ†’