Learn Python Programming

Python Numbers

In this tutorial, we w’ll learn how to convert one data type to another data type and mathematical operations.

Following numeric types supported in python

  1. int
  2. Float
  3. Complex

Any numeric types variable can be created when you assign a numeric value to them:

For example

X = 1 #Int
Y = 1.0 #Float
Z = 1j #Complex
You can check the type of variable using the type() function.



Let’s discuss Numeric Types variables in details

1. Int –

An integer can be a positive or negative whole number. It should not contain any decimal point.

Ex –

x = 1
y = 304234409238
z = -8098898

2. Float –

A float can be a positive or negative number containing one or more decimals.

Ex –

x = 9.60
y = 4.0
z = -56.77

3. Complex –

A complex number is written as X+iJ, where i is the imaginary part.

Ex –

x = 3+2j
y = 10j
z = -933i