# Python Numbers - int, float and complex short note

Python basically supports three types of numbers which includes

- int
- float
- complex

## Integer

Integers can be represented using following syntax. You can also print which type of variable is defined in python code using **type()** function

`i = 5 print(type(i)) # Check the datatype of variable i print(i) #Print the value of i `

You can also apply various operations on **integer numbers** as shown in given example

`i = 5 print("Number is %d" % i) #print value of i print("Addition is %d" %(i + 1)) # Addition print("Addition is %d" %(i - 1)) # Subtraction print("Multiplication is %d" %(i * 2)) # Multiplication print("Exponential is %d" %(i ** 3)) # Exponential print("floating Division is %f" %(i / 2)) # Floating Division print("Integer Division is %d" %(i // 2)) # Integer Division i += 1 #Increment the value of i by 1 print(i) i -= 1 #Decrement the value of i by 1 print(i) i *= 1 #Multiply the value of i by 1 print(i) i **= 2 #i raise to power 2 which is 5 square print(i) i /= 4 #Floating division prints value in floating format print(i) i //= 2 #Integer divison prints value in integer format print(i) `

## Float

Float numbers can be represented using following syntax. You can also print which type of variable is defined in python code using **type()** function

`i = 5.0 print(type(i)) # Check the datatype of variable i print(i) `

`i = 5 print(float(i)) `

You can also apply various operations on **float numbers** as shown in given example

```
print("
") f = 11.7 print(type(f)) # Check the datatype of variable i print(f) # Print the value of the variable i print("Number is %f" % f) # printf() type syntax print("Number is %.3f" % f) # printf() style formatting print("Addition is %f" %(f + 1)) # Addition print("Substraction is %f" %(f - 1)) # Subtraction print("Multiplications is %f" %(f * 2)) # Multiplication print("Exponential is %f" %(f ** 3)) # Exponential print("Floating division is %f" %(f / 2)) # Floating Division print("Integer Divison is %f" %(f // 2)) # Integer Division f += 1 #Increment the value of f by 1 print(f) f -= 1 #Decrement the value of f by 1 print(f) f *= 1 #Multiply the value off by 1 print(f) f **= 2 #f raise to power 2 print(f) f /= 4 #Floating division prints value in floating format print(f) f //= 2 #Integer division prints value in Integer format print(f)
```

## Complex

Complex numbers are written with a "j" as the imaginary part:

`x = 7+8j y = 2j z = -3j print(type(x)) print(type(y)) print(z) `

How was the tutorial? Nice. Right?

## Deep Concept videos to crack the highly-piad interviews.

Chekout out our Youtube Channel to get detailed video content on important topics in interviews.

## What is your Interview Score?

Test your skillset with the curated questions created by experts around the globe.

Book a free test slot. Now !.

It usually takes 30 mins for an online test and this test will be MCQ based. Get detailed analytics based on your test and recommedations with personalised roadmaps.

Book a test slot. Now!## Recommended tutorials