Numbers in Python

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.

STOP 🖐🏻
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

Adding numbers in Python, Arithmetic operations on numbers in Python

Subtracting Numbers in Python

Subtracting numbers in Python, Arithmetic operations on numbers in Python

Multiplying Numbers in Python

Multiplying numbers in Python, Arithmetic operations on numbers in Python

Dividing Numbers in Python

Dividing numbers in Python, Arithmetic operations on 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
  • math.function_name(argument)

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.

Josh

Hi, I'm Josh a Computer Science graduate from California State University, Sacramento since coming out with my Master's from university. I've worked with multiple startups across US and in UK as well primarily as a Python Developer. Here on this website, I'm sharing my knowledge of Python. If you want to ask me anything about Python feel free to reach out, I would be happy to help you out.

Leave a Reply

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

Recent Posts