Learn Without Walls
← Back to Module 10

Module 10: Study Guide

Review key concepts from Modules & Imports

Key Terms

Module: A Python file (.py) containing functions, classes, and variables that can be reused through importing.
Standard Library: The collection of modules that come built into Python (math, random, datetime, etc.).
pip: Python's package installer for downloading and installing third-party packages from PyPI.
PyPI: Python Package Index - an online repository of over 400,000 community-created Python packages.
Virtual Environment: An isolated Python environment where packages are installed separately from the system Python.
Dot Notation: Using module.function() to access items inside a module.
Alias: A shorter name for a module created with import module as alias.

Lesson 1: Built-in Modules

What to Know

Lesson 2: Import Statements

Three Import Styles

import math              # Use as: math.sqrt(16)
from math import sqrt    # Use as: sqrt(16)
import math as m         # Use as: m.sqrt(16)

What to Know

Lesson 3: Installing Packages

What to Know

Lesson 4: Organizing Code

What to Know

Review Questions

1. What is the difference between import math and from math import sqrt?

2. Why should you avoid from module import *?

3. What happens when Python encounters an import statement for a module that was already imported?

4. What is the purpose of if __name__ == "__main__":?

5. When would you use a virtual environment?

6. What is the difference between pip install and import?

Common Mistakes to Avoid