Practical Projects
Practical Projects
Great job learning modules, packages, pip, virtual environments, and requirements files.
Now it is time to practice by building real projects with clear instructions.
Project 1: Calculator Module App
Build a small calculator using your own module.
Create This Structure
project/
main.py
math_tools.py
Step 1: Create math_tools.py
Add these functions:
def add(a, b):
return a + b
def subtract(a, b):
return a - b
Step 2: Create main.py
Tasks:
- Import
math_tools - Print result of
add(2, 3) - Print result of
subtract(3, 2)
Example:
import math_tools
print(math_tools.add(2, 3))
print(math_tools.subtract(3, 2))
Expected Output
5
1
Project 2: Greeting Package
Build a package with two modules.
Create This Structure
app/
greetings/
hello.py
bye.py
main.py
Step 1: Create hello.py
Add:
def say_hello():
print("Hello")
Step 2: Create bye.py
Add:
def say_bye():
print("Goodbye")
Step 3: Create main.py
Tasks:
- Import both functions
- Run both functions
Example:
from greetings.hello import say_hello
from greetings.bye import say_bye
say_hello()
say_bye()
Expected Output
Hello
Goodbye
Project 3: Random Password Tool
Build a password generator.
Tasks
- Import
random - Create a list:
chars = ["A", "B", "C", "1", "2", "3", "x", "y", "z"]
- Pick 6 random characters
- Join them into one password
- Print the password
Example Output
A2xBy3
(Output will be different each time.)
Project 4: Date App
Build a simple date tool.
Tasks
- Import
datefromdatetime - Save today’s date in a variable
- Print the full date
- Print only the year
Example:
from datetime import date
today = date.today()
print(today)
print(today.year)
Expected Output
2026-04-30
2026
Project 5: Setup Project Environment
Practice using tools from the terminal.
Tasks
- Create a project folder named
my_project - Open terminal in that folder
- Create virtual environment:
python -m venv venv
- Activate it
- Install
requests - Create:
pip freeze > requirements.txt
Expected Structure
my_project/
venv/
main.py
requirements.txt
Final Challenge: Utility Toolkit
Build a multi-file project.
Create This Structure
toolkit/
math_tools.py
text_tools.py
main.py
Step 1: Create math_tools.py
Add:
def double(n):
return n * 2
def square(n):
return n * n
Step 2: Create text_tools.py
Add:
def shout(text):
return text.upper()
def count_letters(text):
return len(text)
Step 3: Create main.py
Tasks:
- Import all four functions
- Print:
double(5)
square(5)
shout("hello")
count_letters("hello")
Expected Output
10
25
HELLO
5
Real World Use Case
Developers organize projects into modules and packages every day in web apps, automation tools, APIs, and data systems.
Quiz
- Why is
math_tools.pybetter than putting calculator code inside one largemain.pyfile? - In Project 2, what import path is used to access
say_hello()fromhello.py? - Why should
venvbe created before installing packages? - What does
pip freeze > requirements.txtsave? - In the Utility Toolkit, why are text functions and math functions placed in different files?
Assignment
Choose one project and improve it by adding at least two new features.
Examples:
- Add multiply/divide to calculator
- Add more greetings
- Make password length user-controlled
- Add reverse text tool
- Add cube function
Summary
You practiced building organized Python projects using modules, packages, libraries, and environments with clear real-world structure.