Python Tutorial
About Lesson

In this Python Tutorial i want to show you about How to Get Input in Python, so some times in programming you need to get the user input, and based on that user input you want to do some certain actions. most programs today use a dialog box as a way of asking the user to provide some type of input. if you are familiar with C++ or Java, for example in C++ we can use cin for text input, in Python we can use input() method for getting the user input.  This function first takes the input from the user and then evaluates the expression, which means Python automatically identifies whether user entered a string or a number or list.

 

 

So in the above example first we are going to get the input from the user with input() method and after that we want to print the input value in the console.

 

 

Now this is the result.

How to Get Input in Python
How to Get Input in Python

 

 

 

If you want to enter a number in this input, this will be the result.

 

 

Result

Python Enter Number
Python Enter Number

 

 

 

Let’s create another example. in this example we want to create a simple calculator, basically we are going to get two numbers from the user and after that we do arithmetic operations on the numbers.

 

 

 

Run the code and this is the result.

Python Arithmetic Operation
Python Arithmetic Operation