July 2017
Intermediate to advanced
374 pages
8h
English
A module basically allows you to logically organize your programming code. It is similar to any other Python program. They are needed in scenarios where we need only a bit of code to be imported instead of the entire program. A module can be a combination of one or multiple functions classes, and many more. We will use a couple of inbuilt functions, which are a part of the Python library. Also, wherever needed, we will create our own modules.
The following example code showcases the structure of modules:
#myprogram.py
### EXAMPLE PYTHON MODULE # Define some variables: numberone = 1 age = 78 # define some functions def printhello(): print "hello" def timesfour(input): print input * 4 # define a class class house: def __init__(self): ...