Preface#
This site contains a set of lecture notes (the “book”) for the Python components of IST-5551, offered by the Jaggi Business School at Missouri S&T in Rolla, Missouri. It was inspired in part by Dr. Allen Downey’s Think Python .
At a Glance#
Each chapter in this book builds on the previous ones, so you should read them in order and take time to work on the exercises before you move on.
Part I: Fundamentals: Core Python concepts such as statements, expressions, operators, built-in data types, conditionals, loops, functions, files, modules, and packaging.
Part II: Data Structures: Python’s main data structures – lists, tuples, dictionaries, and sets – along with strings, regular expressions, and text analysis.
Part III: Advanced Topics: Algorithms, searching and sorting, exceptions, unit testing, and object-oriented programming.
Appendices: Practical setup topics such as tooling, Python installation, virtual environments, Jupyter notebooks, and related workflow tips.
How to Use This Book#
Each chapter section is an interactive Jupyter Notebook. You can:
Read through the rendered content
Interact with the code directly by downloading the notebooks locally or using Binder
Use the Live Code cells for practice
Live Coding#
Some sections include exercises that support live coding. To enable them, click the Live Code button. It may take some time to launch a new session; wait until you see a “ready” message. The live coding cells let you practice the concepts and skills introduced in each section.
Custom Code#
If you download the notebook files and place them in a folder in your project directory, or if you write your own notebooks and want to use features such as jupyturtle, you may need additional helper files. The cell below downloads the files used specifically for this book. You don’t need to understand this code yet, but you can see that it downloads several *.py files from Dr. Allen Downey’s GitHub repository to enable the required functionality.
You then create a folder in your project directory called shared, place the downloaded files in it, and add an empty file called __init__.py, which makes the shared folder a package. Later, in any project notebook, you can import modules from that package and use their functions:
from shared import [module]
The download function:
from os.path import basename, exists
def download(url):
filename = basename(url)
if not exists(filename):
from urllib.request import urlretrieve
local, _ = urlretrieve(url, filename)
print("Downloaded " + str(local))
return filename
thinkpython: ‘AllenDowney/ThinkPython ’
diagram: ‘AllenDowney/ThinkPython ’
jupyturtle: ‘ramalho/jupyturtle ’
To use the downloaded files as modules, create a directory named shared in the project root and place the files in it. In each notebook that needs these modules, put the code snippet below at the beginning of the notebook.
import sys
from pathlib import Path
current = Path.cwd()
for parent in [current, *current.parents]:
if (parent / '_config.yml').exists():
project_root = parent # ← Add project root, not chapters
break
else:
project_root = Path.cwd().parent.parent
sys.path.insert(0, str(project_root))
from shared import thinkpython, diagram, jupyturtle
Credits#
Parts of these notes are adapted from Think Python by Dr. Allen Downey.
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License .