You are on page 1of 5

INPUT – OUTPUT

IN PYTHON

DEPARTMENT OF MECHANICAL ENGINEERING


READING INPUT FROM THE KEYBOARD (INPUT OPERATION )

 Python provides us with two inbuilt functions to read the input

from the keyboard.


– raw_input()
– input()

 raw_input(): This function reads only one line from the standard

input and returns it as a String.

 Note: This function is decommissioned in Python 3.

D E PA R T M E N T O F M E C H A N I C A L E N G I N E E R I N G
 input(): The input() function first takes the input from the user

and then evaluates the expression, which means python

automatically identifies whether we entered a string or a number

or list.

 But in Python 3 the raw_input() function was removed and

renamed to input().

D E PA R T M E N T O F M E C H A N I C A L E N G I N E E R I N G
• eval() : Function takes a string and evaluate the result

OUTPUT OPERATION

• In order to print the output, python provides us with a built-in


function called print().

D E PA R T M E N T O F M E C H A N I C A L E N G I N E E R I N G
FILES IN PYTHON

 A file is a named location on the disk which is used to store the

data permanently.

 Here are some of the operations which you can perform on

files:
 open a file
 read file
 write file
 close file

D E PA R T M E N T O F M E C H A N I C A L E N G I N E E R I N G

You might also like