In this tutorial we are going to learn :

• Numbers
• Type Conversion

### Numbers

We have three number types in Python to use mostly and these are integer, float, and complex numbers types.
Look at the example below.

Example :

``````x = 4       # integer
y = 2.8     # float
z = 1 + 3j  # complex

# printing numbers types with type() function
print(type(x))
print(type(y))
print(type(z))  ``````
• We have some mathematical operators to do some tasks with numbers.

Example :

``````print(10 + 4)       # addition
print(10 - 4)       # subtraction
print(10 * 4)       # multiplication
print(10 / 3)       # division to get all float numebr
print(10 // 3)      # division to get first number
print(10 % 3)       # remainder of the division
print(10 ** 4)      # exponential ``````
• Addition with two numbers and setting it.

Example :

``````x = 10

x = x + 4

print(x) ``````

We have a better way for that. Addition with + operator. Look at the example below

``````x = 10

x += 4

print(x) ``````

### Type Conversion

We use the input() function to get data from the user.  input() function takes the data as
a string.

Look at the example below.

Example :

Explanation :

You see that program gave an error. Because Python expects string from the user.

To fix that we have to use convert the data type. We can use the int() method to convert it.

Look at the example below.

``````x = input("x :")

y = int(x) + 1

print(f"{x}, {y}") ``````
0 0 vote
Article Rating
Subscribe
Notify of