0% found this document useful (0 votes)
80 views

Input - Output in Python: Department of Mechanical Engineering

Python provides two functions, raw_input() and input(), to read input from the keyboard. Raw_input() reads a single line as a string, while input() evaluates the input as a string, number, or list. Python also uses the print() function to output results. Files in Python can be opened, read, written to, and closed to permanently store data on disk.

Uploaded by

Subbu Suni
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views

Input - Output in Python: Department of Mechanical Engineering

Python provides two functions, raw_input() and input(), to read input from the keyboard. Raw_input() reads a single line as a string, while input() evaluates the input as a string, number, or list. Python also uses the print() function to output results. Files in Python can be opened, read, written to, and closed to permanently store data on disk.

Uploaded by

Subbu Suni
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 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