Nearly every program we write will need to read input from the user via the keyboard, and Python provides two built-in functions to support this. A function is a piece of prewritten code that performs an operation and then returns a value back to the program. Normally the value that is returned is assigned to a variable so that it can be used later in the program
where prompt is an optional string that is displayed on the screen, and variable
is the name of some variable that will reference the value read from the
keyboard. Every value read by input() will be turned into a string.
Although the input() function is useful for reading strings, it doesn't work well for
reading numbers. That is why you need to convert the string into an integer or a
float in order to do calculations.
Get Free Quote!
285 Experts Online