As well as displaying text, programming languages will also work out math. An example of this could be:

https://codapi.org/embed/?sandbox=python&code=data%3A%3Bbase64%2CKyjKzCvRMNI20uQqADMNtQ21DWEcI20jLSNNAA%3D%3D

Earlier on in 1 - Printing Basics, I wrote that print is a function. You can tell a function in Python because it has parenthesis ( ).

Operators

Operator Python symbol
+ +
- -
x *
รท /

In the above example, Python is evaluating everything between the parenthesis. Have you noticed that 2+2 * 2 is 6? You probably learned about BIDMAS (or BODMAS) in math lessons. multiplication happens before addition in the order of operations.

Tasks

Try some maths in python

Some more operators

A couple more operators you will need to learn are the DIV and MOD operators. These are often useful in programming and frequently come up in exam questions.

Operator Operator Explanation
MOD % remainder (or modular) division only shows the remainder of any division.
DIV // integer (or floor) division removes the decimal point and remainder of any division.
equal to == This is a comparative operator. You will learn more about these in the coming lessons. It is used to compare 1 object to another object.

https://codapi.org/embed/?sandbox=python&code=data%3A%3Bbase64%2CKyjKzCvRUCpKTS%2FNSSxSSMksyyzOzM9T0lEw1TfS5CqASOfmp2BIqyKkM%2FNKUtNT0XTrG2kCAA%3D%3D

https://youtube.com/shorts/JhG7WRKpk_Y?si=txHMRV_qc-7ZCl22