Datatypes in Python


☞A type identifies a set of values (and their representation in memory) and a set of operations that transform these values into other values of that set.

☞Python is a dynamically typed language.

☞Python offers the following built-in core data types.

☞Here we will learn about int(), float(), complex() datatypes


Working on numbers

☞If you want to directly assign a number you can do it as given below.

Working on integers

Example :

a=20
b=-24
c=+35
print(a,b,c)
Output
20 -24 35

Working on floating numbers

Example :

a=20.343
b=-24.324323
c=+34.4523432
d=56.23423432423432455397755
print(a)
print(b)
print(c)
print(d)
Output
20.343
-24.324323
34.4523432
56.23423432423432  # floating point takes double precision(15 digits)

Working on complex numbers

Example :

a=2 + 5j
b=1.5 + 7j
c=0 + 3.4j
d=5 + 0j
e=0 + 0j
print(a)
print(b)
print(c)
print(d)
print(e)
Output
(2+5j)
(1.5+7j)
3.4j
(5+0j)
0j
1. if real and imaginary part are non-zero, then output will be in parenthesis() 2. if real part is zero, then output will be imaginary part without parenthesis()