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

Python-06 (Modules and File Input-Output)

This document discusses modules and file input/output in Python. It explains that modules allow organizing Python code and importing modules. It also describes how Python searches for modules in the current directory, PYTHONPATH directories, and default directories. The document then covers using the input() and raw_input() functions to take input from the user and print the received input.

Uploaded by

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

Python-06 (Modules and File Input-Output)

This document discusses modules and file input/output in Python. It explains that modules allow organizing Python code and importing modules. It also describes how Python searches for modules in the current directory, PYTHONPATH directories, and default directories. The document then covers using the input() and raw_input() functions to take input from the user and print the received input.

Uploaded by

Saurabh Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Modules and File InputOutput

By: Dr. Vipin


Kumar

Modules
Module is a file consisting of Python code.
It allows to organize Python code.
Import Statement Syntax:
>>> import ModuleName
FromImport Statement Syntax:
>>> from ModuleName import SubModule_1,
SubModule_2, SubModule_3 SubModule_n

Conti

Module-02

Module-03

Module-01

Conti

Module-01

Outputs

Modules Location
Python Interpreter searches for the module in
the following sequences, while importing the
module:
The current directory
Then, searches each directory in the shell variable
PYTHONPATH
Then, check the default path. In unix, default path
is /usr/local/lib/python/

File Input-Output
Keyword Input:
There are two build function in Python to read
a line of text from slandered input.
row_input
Example :
Str=row_input(Enter the inout=)
print(received input=,str)

input
Example :
Str=input(Enter the inout=)
print(received input=,str)

File Input-Output
Input() function is equivalent to row_input(), but
input() function assumes the input is a valide Python
expression and returns evaluated result.
Example :
Str=input(Enter the input=)
print(received input=,str)
>>>
Enter the input:[x*3 for x in range(2,10,2)]

You might also like