2. Python Standard Library#

This chapter was coauthored by Jason DeBacker and Richard W. Evans.

The standard library of Python is all the built-in functions of the programming language as well as the modules included with the most common Python distributions. The Python online documentation has an excellent page describing the standard library. These functionalities include built-in functions, constants, and object types, and data types. We recommend that you read these sections in the Python documentation.

In addition, the iframe below contains a PDF of the BYU ACME open-access lab entitled, “The Standard Library”. You can either scroll through the lab on this page using the iframe window, or you can download the PDF for use on your computer. See [BYU ACME, 2023]. Exercise 2.1 below has you work through the problems in this BYU ACME lab. The two Python files used in this lab are stored in the ./code/StandardLibrary/ directory.

2.1. Exercises#

Exercise 2.1

Read the BYU ACME “The Standard Library” lab and complete Problems 1 through 5 in the lab. [BYU ACME, 2023]

Exercise 2.2

Create a python module that prints something (e.g. Hello World!) and run it from the command line using python module_name.py.

Exercise 2.3

Create a Jupyter notebook (.ipynb) with your Python code from Exercise 2.2 and run it in the VS Code text editor.

Exercise 2.4

Write a function that finds the Fibonacci sequence up to an integer N > 0 in the notebook. Now call this function for N = 10 and N=100.

Exercise 2.5

Use the sys module to create a relative path from a Python module, print that path.