Introduction Variables Data Types Numbers Casting Strings Boolean Operators Lists Tuples Dictionaries If-Else While Loops For Loops Functions Arrays Scope Modules User Input File Handling Python Maths

Welcome to the lesson on Python modules

Modules

A module is basically a code library for python.

Inside the python file a function should be called and any code can then be entered.

Then, save the file and name it to anything you want. Example.py .

Then on the top of your main code, enter import Example.py or the name of your previous file.

An alias can also be given to the imported python file. An example would be import example.py as ex

using variables and functions from other python files.

If a variable is to be used from another file, it can be done as so.

Example: likewise with functions

modules_var
Try it out yourself

built in modules

Import platform can be used to determine system platform

import platform can also be used with dir() to see all the modules.

Example:

module_platform

End of Python Modules

You have learned Modules in simple terms. Let's proceed on to Quiz.

Quiz Time!
Next Lesson
Back To Top