Skip to main content

Posts

Showing posts with the label input and print statement

Input and Output

A Program needs to interact with end user to accomplish the desired task, this is done using Input-Output facility. Input means the data entered by the user (end user) of the program.  In python, we have raw_input() and input ( ) function available for Input. raw_input() Syntax of raw_input() is: x=raw_input (“prompt message”) If prompt message is present, it is displayed on the monitor after which user can provide the data from keyboard. The function takes exactly what is typed from keyboard, convert it to string and then return it to the variable on LHS of  =. Example (in interactive mode) >>>x=raw_input ("Enter your name: " ) Enter your name: ABC x is a variable which will get the string (ABC), typed by user during the execution of program. Typing of data for the raw_input() function is terminated by pressing enter key. We can use raw_input() to enter numeric data also. In that case we typecast, i.e., change the datatyp...