# Numbers

There are 3 types :

1. Integer
2. Float
3. Complex

   1. Integer(int) : Integer is a non decimal number formed by the combination of 0 - 9 digts.
   2. Float(float) : Float is an decimal number that can be represented on number line.
   3. Complex(complex) : They are the numbers consist of an imaginary number and real number.

   We can use the type() function to know which class(int,float,complex) a variable or a value belongs to!!

Example - 1:

```python
x = input("Enter any number :  ") 
#input() function is used to have input on console.
y = input("Enter any number : ")
z = input("Enter any number : ")
print(type(x)) 
#type(object) function returns the type of object.
print(type(y)) 
#print() is a function that outputs to your console window.
print(type(z))
```

Enter any number : 3&#x20;

Enter any number : 4.5&#x20;

Enter any number : 3+6j

\<class 'str'>

\<class 'str'>

\<class 'str'>

![](/files/-Ldi6ntoO7vEyefAetbv)

Initially every value is a string in python so to convert them in int, float, complex we use specific functions for each conversion.

1. For integer we use int()
2. For float we use float()
3. For complex we use complex()

Example - 2:

```python
#id(object) As we can see the function. 
#Accepts a single parameter and is used to return the identity of an object. 
#This identity has to be unique and constant for this object during the lifetime. 
#Two objects with non-overlapping .
#lifetimes may have the same id() value.
#int
x = int(input("Enter a number : "))
y = int(input("Enter a number : "))
print("Type of X : ",type(x)) 
print("Type of Y : ",type(y))
print("Value of X : ",x)
print("Value of Y : ",y)
print("Id of X : ",id(x))
print("Id of Y : ",id(y))
x = 6
print("x = ",x,"y = ",y)
print("Id of X : ",id(x))
print("Id of Y : ",id(y))
```

Enter a number : 3&#x20;

Enter a number : 4

Type of X :  \<class 'int'>

Type of Y :  \<class 'int'>

Value of X : 3

Value of Y : 4

Id of X : 1487936480

Id of Y : 1487936496

x = 6 y = 4

Id of X : 1487936528

Id of Y : 1487936496

Example - 3:

```python
x = float(input("X : "))
y = float(input("Y : "))
print("X = ",x)
print("Type(x) = ",type(x))
print("Y = ",y)
print("Type(y) = ",type(y))
```

X : 6.789654321

Y : 876543.098765432

X = 6.789654321

Type(x) = \<class 'float'>

Y = 876543.098765432

Type(y) = \<class 'float'>

Example - 4:

```python
#complex
x = 3+5j #here 3 is real and 5 is imaginary known as iota 
print("Type of X : ",type(x)) #The output of inner print function is the input of outer print function
# So The overall output is "none" 
print("Value of X : ",x)
```

Type of X :  \<class 'complex'>

Value of X : (3+5j)

Example - 5:

```python
x = 7489231752389582589023580265786238589275890237472895789237892374899734
```

```python
print(x)
```

```
7489231752389582589023580265786238589275890237472895789237892374899734
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gyansetu-python.gitbook.io/python-programming/python-data-types/numbers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
