Simple Python projects with source code
Build three simple Python projects for beginners with source code, expected output, and exact edits. Practice calculations, text handling, and CSV summaries.

These three simple Python projects for beginners with source code let you build an order calculator, a word counter, and a CSV quantity summary. Each standalone script includes starting data, expected output, and an exact edit, so you can check both whether the program works and whether you understand why its result changes.
A local Python setup
You can run all three projects with Python 3 and its standard library, the collection of modules included with Python. You won't need extra packages, downloaded data, or an account with another service. The examples use fictional workplace data, including an order priced in Philippine pesos.
If your Python installation includes IDLE, Python's editor and interactive shell, open IDLE and select File > New File. Paste one complete script, save it with the filename specified in its first comment, and select Run > Run Module. Read the printed result in the shell window.
Use the same predict-run-edit loop for each project:
- Predict the output from the starting values before running the script.
- Run the saved file and compare the actual output with the expected output.
- Make only the specified edit, save the file, and run it again.
- Explain which input changed, which operation used that input, and why the output changed.
Work through the projects in order. The calculator introduces arithmetic, the word counter adds text handling, and the CSV summary introduces structured records. Keeping the tools fixed makes each new concept easier to isolate.
An order calculator
An order calculator teaches variables and arithmetic through a snack-order calculation. A variable is a name associated with a value. Here, separate variables represent the item quantity, unit price, and delivery fee, so you can change one input without rewriting the calculation.
Save the following complete script as order_calculator.py. Predict the total, run the original script, then change the quantity assignment exactly as instructed in the block and run it again.
# Save as order_calculator.py and run in Python 3.
# Goal: calculate item cost plus one delivery fee.
# Starting values: 3 items, PHP 45 each, PHP 30 delivery.
# Model: 3 * 45 + 30 = 165.
quantity = 3
unit_price = 45
delivery_fee = 30
total = quantity * unit_price + delivery_fee
print(f"Order total: PHP {total}")
# Expected output:
# Order total: PHP 165
# Edit: change quantity = 3 to quantity = 4, then run again.
# Changed model: 4 * 45 + 30 = 210.
# Expected changed output:
# Order total: PHP 210
Practice what this post teaches
Python performs multiplication before addition, so the calculation finds the item cost first and adds delivery once. The formatted string, identified by the letter f before the opening quotation mark, inserts the total into the message. The print function displays that message.
After the quantity edit, the unit price and delivery fee stay fixed. The total increases by the cost of one additional item, not by another delivery fee. Explaining those unchanged inputs is part of understanding the calculation.
Keep this version to whole pesos. The calculator doesn't handle centavo rounding, discounts, or invalid quantities such as a negative item count. Those rules need explicit decisions before you extend the script.
A word counter for short messages
A word counter teaches you to turn a string, a text value, into a list, an ordered collection of items. Printing the list as well as its length makes the transformation visible instead of hiding everything behind a final number.
Save the script as word_counter.py and run the starting version. Then replace the entire message assignment with the replacement shown in the comments, preserving its repeated spaces, and run it again.
# Save as word_counter.py and run in Python 3.
# Goal: count whitespace-separated pieces in a message.
# Starting text: "Send the updated report".
# Model: ["Send", "the", "updated", "report"] has 4 pieces.
message = "Send the updated report"
words = message.split()
print(words)
print(f"Word count: {len(words)}")
# Expected output:
# ['Send', 'the', 'updated', 'report']
# Word count: 4
# Edit: replace the message assignment with:
# message = " Send the updated report today "
# Run again. Extra spaces don't create extra pieces.
# Changed model: the original 4 pieces plus "today" = 5.
# Expected changed output:
# ['Send', 'the', 'updated', 'report', 'today']
# Word count: 5
The split method without an argument separates the string at whitespace, including spaces, tabs, and line breaks. Consecutive whitespace doesn't create empty items, and leading or trailing whitespace doesn't add items. The len function then counts the items in the resulting list.
A common mistake is counting the message directly instead of counting the words list. Applying len to the message counts characters, including spaces. Use the printed list as your check: the reported word count should match the number of visible list items.
Punctuation attached to a word stays attached, and a hyphenated expression without spaces remains one piece. For a workplace text check, define the counting rule before deciding whether the result is correct.
A CSV quantity summary
A CSV quantity summary teaches imports, loops, and conversion from text to numbers. CSV means comma-separated values, a common format for exported records. This example embeds the records in the script so file paths won't distract you from the calculation.
Save the script as quantity_summary.py and run it. For the second run, change only the folders quantity inside the csv_text assignment, following the edit in the block.
# Save as quantity_summary.py and run in Python 3.
# Goal: total the quantity column in fictional stock data.
# Starting records: notebooks = 3, folders = 2.
# Model: 3 + 2 = 5 units.
import csv
import io
csv_text = "item,quantity\nnotebooks,3\nfolders,2\n"
rows = csv.DictReader(io.StringIO(csv_text))
total = 0
for row in rows:
total += int(row["quantity"])
print(f"Total units: {total}")
# Expected output:
# Total units: 5
# Edit: replace folders,2 with folders,4 in csv_text.
# Run again. Changed model: 3 + 4 = 7 units.
# Expected changed output:
# Total units: 7
The import statements make the csv and io modules available. The io.StringIO function wraps the embedded text in a file-like object that the CSV reader can read. Within the text, each backslash-n sequence represents a new line.
The csv.DictReader class uses the first row as column headings. Each subsequent row becomes a dictionary, a collection of named values, so the loop can retrieve the quantity field by name. A for loop repeats its indented instruction for each record.
CSV fields arrive as text. The int function converts each quantity into a whole number, and the accumulation statement adds that number to the running total. Starting the total at zero gives the loop a numeric value to update.
Don't remove the conversion and expect Python to infer the column's meaning. Adding a text quantity to the numeric total raises a TypeError, an error caused by incompatible value types. Blank or nonnumeric quantities also need validation, meaning checks that decide whether an input is acceptable; this beginner script doesn't provide those checks yet.
For another task after the embedded-data example, try the Project: expense report from a messy CSV.
Practice order and portfolio evidence
Build portfolio evidence by keeping each working script together with its input, expected output, exact edit, and limitation. A portfolio is a collection of work you can explain and demonstrate, not just a folder of copied code.
Connect each project to a specific skill:
- Order calculator: explain how separate inputs support a reusable workplace calculation.
- Word counter: show the intermediate list and explain why extra spaces don't increase its length.
- CSV summary: trace one record from a text field through numeric conversion into the total.
For an interview demonstration, choose one script and explain the input-to-output path without reading every line aloud. Then make its specified edit and explain the changed result. Small scripts show individual skills, but they don't establish readiness to maintain a complete workplace application.
Common questions
Which simple Python project should I build first? Start with the order calculator because its inputs and arithmetic are easy to trace by hand. Move to the word counter, then the CSV summary, which adds modules, records, and a loop.
Can I run these Python projects without installing extra packages? Yes. All three scripts use Python 3 and its standard library, so you don't need third-party packages. You still need access to a Python 3 interpreter, the program that executes Python code.
Why does the CSV example convert quantities with int()? The CSV reader returns the quantity fields as text, even when those fields contain digits. The int function converts each field into a whole number that can be added to the numeric total.
How can I check whether I understand source code I've copied? Predict the starting output before running the program, then explain each intermediate operation. Make the specified edit and predict the new output before running the script again.
What should I include when I share a beginner Python project? Include the source file, its Python version requirement, starting input, expected output, and instructions for running it. Add one tested modification and an honest limitation, and identify supplied source code rather than presenting copied work as entirely your own.
When you want more guided practice, use The Work Gym's Python course. The first unit is free without an account, and exercises are checked automatically with a hint that names the mistake.