# Python input( ) function

In this tutorial, we are going to see how input is given in the Python language. We will use input() function in Python.

## input( ) function in Python

The input is used to store some value in the assigned variable which is given by the user. Now we can see how different data types are given as an input in Python.

We will check how input is taken for these three most popular data types:

- String
- Integer
- Float

### Giving string as an input

When the input is in the form of string we can give it by the below example,

name = input("Enter your name") number = input("Enter the number")

note:

whatever the input( ) function will always convert it into a string.

### Giving integer as an input

It is so simple to give an integer as an input in Python. The thing is to do is using the keyword int before giving the input function.

let us see an example:

num1=int(input("Enter the first number")) num2=int(input("Enter the second number")) num3=num1+num2 print("The addition of two number is", num3)

The above program is the addition of two numbers. here the two numbers are taken as the integer and computed the addition of the two numbers.

output: Enter the first number45 Enter the second number45 The addition of two number is 90

### Giving float as an input in Python

The input for the type float is also similar as we have given in the integer type..

let us see by an example,

num1=float(input("Enter the first number")) num2=float(input("Enter the second number")) num3=num1+num2 print("The addition of two number is", num3)

note:

we have not mentioned any datatype for num3 the Python itself will consider it has a float value

The above program is to compute the addition of two float numbers.

output: Enter the first number5.5 Enter the second number4.5 The addition of two number is 10.0

Also learn:

## Leave a Reply