Math in Python

geometry, mathematics, volume

You don’t need to be a math genius to learn to code, however some basic knowledge is needed. Today we will learn how to do basic mathematical operations in Python.

Last article, we learnt about the string data type (wrapped in quotation marks). Today we will learn about the int data type. An int is any number with no decimal points. some examples are:

4, 0, -932, 99993432

We can do addition with these numbers:

num1 + num2

Press Play to try it out! Did it work? The next mathematical operation is subtraction. You can do this by doing:

num1 – num2

It’s been very simple so far but now it gets a bit harder. To do multiplication you must do:

num1 * num2

and to do division you must do:

num1 / num2

Try experimenting with different numbers. If you are putting your code in this website’s editor, make sure you wrap it in a print function. You can find an editor by clicking here. See the code in action down below.

You now know about basic mathematical operations in python. If you have any questions, comment or feel free to contact me. See you in the next lesson!

2 thoughts on “Math in Python

Leave a Reply

Your email address will not be published. Required fields are marked *