Python Numbers & Types Tutorial with Example

Python numbers is a data type that stores numeric values. It’s an immutable data type – means that it can change the value of data variable in a new value allocated. In this tutorial, you will learn about Python number data type with examples.

Python Numbers and Types Tutorial with Example

Python Numbers Simple example 

Here directly showing the number and using a variable. Printing a value and type in console. In output showing it’s type is class – <class ‘int’>

Output: 1234567890
<class ‘int’>

Python Numbers Types

Python supports integers, floating point numbers and complex numbers. They are defined  as :

  •  int,
  •  float
  • and complex class in Python.

Int Type

A whole number (Int or integer ),  + positive or – negative, without decimals of no limit length.

Output : <class ‘int’>

Float Type

Float or floating-point number is a number that can positive or negative and containing one or more decimals. Float numbers can also be scientific numbers with an “e” to indicate the power of 10.

Output : <class ‘float’>

Complex Type (Imaginary numbers)

Complex numbers are written with a “j” as the imaginary part. In python, you can put ‘j’ or ‘J’ after a number to make it imaginary, so you can write complex literals easily:

Output : <class ‘complex’>

Do comment if you have any doubt and suggestion on this tutorial.

Note : This example (Project) is developed in PyCharm 2018.2 (Community Edition)
JRE: 1.8.0
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.6
Python 3.7
All Examples of Numbers and types are in Python 3, so it may change its different from python 2 or upgraded versions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.