Numbers are one of five built in Python Data Types. These can be integers with no fractional part, floating-points with some fractional part, complex numbers with some imaginary part, rationals.
Examples of Number Data Type in Python
- Integers – 8, 9, -10
- Floating Point – 3.29, 93.1, -10.34
- Complex Number – 10 + 3i, 93 – 29i
- Rationals – 48/19, 373/82
Doing number arithmetic in Python
Python inherently support certain arithmetical operations like addition, subtraction, multiplication and some others. If you just to try these out then just open terminal/command line on your laptop and type python3 then press enter.
For following up with me further on this article. Please install python on your PC, if you’ve not already and in case your not aware of how to do it. Then click on links below and see how to do it.
• Installing Python on Mac
• Installing Python on Windows
Adding Numbers in Python
Subtracting Numbers in Python
Multiplying Numbers in Python
Dividing Numbers in Python
Python’s Math Module
Python does have a Math module which contains a number of mathematical functions like factorilal, gcd, isqrt and many more. These functions are really helpful as in order to use these in your code, you just need to write 2 lines.
- import math
If your interested in knowing what funcions are there inside Python’s math module and how to use these Math functions inside Python Program? See – Math module in Python.