Using Standard Library Modules

Introduction

Python ships with a large collection of ready-made modules known as the standard library. Instead of writing your own code to compute a square root, list the files in a folder, read command-line arguments, stamp a record with the current date, or generate a test value, you import a module that already does it. In this topic we look at five that come up constantly in engineering scripting: math for numeric functions and constants, os and os.path for working with files and directories in a platform-independent way, sys for interacting with the interpreter and the command line, datetime for dates and times, and random for pseudo-random values and sampling.

These modules matter in EGN3214 because they are the bridge between the plain Python syntax you have practiced and real scripting tasks: building a path to a data file, checking whether it exists before opening it, timestamping output, pulling an input filename from the command line, and exiting cleanly when something goes wrong. None of them require installation, so any script you write using them will run on a classmate's machine or a lab computer without extra setup. They also pair directly with the file I/O and exception handling material in the rest of this module.

As you watch the videos below, pay attention to three things: the import statement itself and the different forms it can take, the dotted notation used to reach a function inside a module, and how the presenter finds out what a module offers. Getting comfortable reading the official Python documentation for a module is more valuable than memorizing individual function names, because the same pattern applies to every module in the standard library.

Video 1: Time Module in Python | Python Tutorial - Day #84

CodeWithHarry · 11:37 · 138,483 views · 3y ago · captions — Watch on YouTube

About this video

This video walks through Python's time module, covering how the interpreter represents time, how to get the current time, how to format or convert it for display, and how to pause execution with a sleep call. It is demonstrated live in a code editor so you can see the import and the function calls in context.

Why this video

Time handling is the closest companion to the datetime subtopic, and the video shows the same pattern of importing a standard library module and exploring its functions that applies across all five modules here. The sleep and timestamp techniques it demonstrates are routinely useful in engineering scripts that log data or poll for results.

Video 2: Modules and Pip | Python Tutorial - Day #3

CodeWithHarry · 12:41 · 3,698,442 views · 3y ago · captions — Watch on YouTube

About this video

This lesson introduces what a module is in Python, how to bring one into your program with an import statement, and how to call the functions it provides. It distinguishes modules that come bundled with Python from third-party packages, and demonstrates using pip to install libraries that are not part of the standard library.

Why this video

It establishes the foundation the whole topic rests on: the import mechanism and dotted access that you will use identically for math, os, sys, datetime, and random. The contrast it draws between built-in and installed modules clarifies exactly why standard library modules need no additional setup.

About These Videos

These videos were chosen from YouTube on October 2, 2026. Each has captions; the player turns them on. Videos on YouTube can be changed or removed — if one no longer plays, tell your instructor. If a player does not appear, use its Watch on YouTube link.