What is Console in Python? Console (also called Shell) is basically a command line interpreter that takes input from the user i.e one command at a time and interprets it. If it is error free then it runs the command and gives required output otherwise shows the error message. A Python Console looks like this.

Here we write command and to execute the command just press enter key and your command will be interpreted.
For coding in Python you must know the basics of the console used in Python.
The primary prompt of the python console is the three greater than symbols
>>>
You are free to write the next command on the shell only when after executing the first command these prompts have appeared. The Python Console accepts command in Python which you write after the prompt.

Accepting Input from Console
User enters the values in the Console and that value is then used in the program as it was required.
To take input from the user we make use of a built-in function input().
# input input1 = input() # output print(input1) |
We can also type cast this input to integer, float or string by specifying the input() function inside the type.
- Typecasting the input to Integer: There might be conditions when you might require integer input from user/Console, the following code takes two input(integer/float) from console and typecasts them to integer then prints the sum.
# inputnum1=int(input())num2=int(input())# printing the sum in integerprint(num1+num2)chevron_rightfilter_none - Typecasting the input to Float: To convert the input to float the following code will work out.
# inputnum1=float(input())num2=float(input())# printing the sum in floatprint(num1+num2)chevron_rightfilter_none - Typecasting the input to String: All kind of input can be converted to string type whether they are float or integer. We make use of keyword str for typecasting.
# inputstring=str(input())# outputprint(string)chevron_rightfilter_none
Recommended Posts:
- Taking input in Python
- Ways to read input from console in Java
- Taking multiple inputs from user in Python
- Vulnerability in input() function – Python 2.x
- Python Input Methods for Competitive Programming
- How to input multiple values from user in one line in Python?
- Python | Find all close matches of input string from a list
- Generate two output strings depending upon occurrence of character in input string in Python
- Position after taking N steps to the right and left in an alternate manner
- Program to multiply two Matrix by taking data from user
- HTML | DOM console.timeEnd() Method
- Input Groups in Bootstrap with Examples
- Change an HTML5 input placeholder color with CSS
- Program to find out the data type of user input
- Check input character is alphabet, digit or special character
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



