![]() Prompt: This is optional again it can be any string or commands that the user wants to display. If you have asked the user to enter the age, it will automatically take an int as the data type for the variable age. As in the raw_input() function, it can return an only a string value, but in this input() function, we can get the return value of any data type Python decides as to what data type to be returned based on the variable value. In Python, we do not declare any data type while initializing or declaring the variable. The return value of this method can be string or number or list or tuple, etc. This is also a Python method for reading the input string from the user through an input device like a keyboard and display the return value of this function on the output screen or console. Print ("Name of the place where I stay is: ", place) ![]() This is optional it can be any string or command which you want to display on the output console.Įxample: place = raw_input("Where do you stay?") Python has two functions for taking in the input from the user or reads the data that is entered through the console, and the result of this can be a string, list, tuple or int, etc., which is stored into a variable. ![]() In Python, the print() function is used to display the input obtained or the value it wants to display, which is specified, whereas to accept the input line from the user, there are two functions such as input() and raw_input(). In Python, as we know that we don’t specify any data types while declaring any variable, and also there are two different functions to display and handle input data obtained from the user, they are input() and print(). There are also some built-in methods or functions to read the string on the console and return it in other languages. In Python, to read the string or sentence from the user through an input device keyboard and return it to the output screen or console, we use the input() function.
0 Comments
Leave a Reply. |