November 2018
Beginner
304 pages
7h 35m
English
An important thing to know about Python is that modules, as written, are pretty much only useful as imported objects for other programs. However, a module can be written to be imported or function as a standalone program.
When a module is imported into another program, only certain objects are imported over. Not everything is imported, which is what allows a module to perform dual duty. To make a module operate by itself, a special line has to be inserted near the end of the program.
The following program is a simple dice rolling simulator, broken up into separate parts:
# random_dice_roller.py (part 1)1 import random #randint 2 3 def randomNumGen(choice): 4 """Get a random number to simulate a d6, d10, or d100 roll.""" ...
Read now
Unlock full access