Input:


The function is able to read data entered by the user and to return the same data to the running program. This allows the program you create to be used by someone else, a 'user', who does not have to know anything about programming!

Note:

  • The program prompts the user to input some data from the console (most likely using a keyboard, although data can be input using voice or image).

  • The input() function is invoked without arguments (this is the simplest way of using the function). The function will switch the console to input mode; you’ll see a blinking cursor, and you’ll be able to input some keystrokes, finishing by hitting the Enter key. All the inputted data will be sent to your program through the function’s result.

  • Note: You need to assign the result to a variable. This is crucial – missing this step causes the entered data to be lost.

  • Use the print() function to output the data produced, with some additional remarks.


Note: This is very, very important. The value you get from an input() function is always a STRING. You cannot do any math operations on it. Luckily, there is a solution.

  • The int() function takes one argument (a string) and tries to convert it into an integer. If it fails, the whole program fails too. (There is a workaround for this situation that you will be shown later);

  • The float() function takes one argument and tries to convert it into a float (the rest is the same).

Try This: 
               print("Hi, I'm Python. What's your name?) 
               name = input()  
               print("Hello, ", name, "- nice to meet you!")