beginner pathway

Python Fundamentals for Useful Small Tools

Use Python to read local text, transform it, and print useful results.

Download course manifest

Reference word counter

Your First Python Script

A Python script is a plain text file of instructions. Start with visible output and small inputs. A useful beginner script should be easy to read and easy to rerun.

Exercise

Write a script that stores your learning goal in a variable and prints it.

Assessment

What function displays text in the terminal?

print sends a visible result to standard output.

Sources

Build a Word Counter

A word counter is small but real: it accepts a path, reads text, splits on whitespace, counts the words, and reports a clear error when the file is missing.

Exercise

Explain how you would turn the example into a command that accepts a file path.

Assessment

Which method reads text from a pathlib Path?

Path.read_text reads a text file using the chosen encoding.

Sources

Test the Word Counter Tool

Testing turns a script into a dependable tool. Put the count logic in a function, test that function with known text, then keep the command-line wrapper thin.

Exercise

Write one test case for empty text and one for three words.

Assessment

Why test a function instead of only looking at printed output?

A function test is repeatable and can fail clearly when behavior changes.

Sources

Final mini-project

Build and test a tiny word-count script for local text files.