Learn
01.6 | PROJECT: A PERSONALISED CALCULATOR
01 | A PROJECT WITH A CLEAR PURPOSE
Your first project is a personalised practice calculator. It greets a user, calculates practice time and plans a target. It also calculates how much time each completed project represents on average.
A project is more than a code listing to copy. You need a purpose, suitable inputs, clear calculations and tests showing that the outputs match the requirements. Start with a small working version, then extend it.
This project uses the skills from Section 1 only. It does not require a menu, decisions or loops yet. The core version assumes sensible valid input; later lessons will add robust handling.
02 | DEFINE WHAT THE PROGRAM MUST DO
The program asks for a first name, completed sessions, minutes per session, extra practice minutes, completed projects, target hours and planned future minutes per session.
It calculates total completed minutes, hours and average minutes per completed project. It calculates target minutes and how many complete planned sessions fit within that target, plus leftover minutes. The planned target is a separate future block, not a remaining amount after subtracting past practice.
Success means these results are correct, clearly labelled and personalised. This precise definition prevents a report from mixing “already completed”, “future target” and “time still needed”.
03 | CHOOSE TYPES AND STATE ASSUMPTIONS
Use str for the name, int for whole-number completed session and project counts, and float for quantities that can include fractional minutes or hours. To practise // and % without float rounding complications, the future session size and target hours use whole numbers in the core version.
Assume completed sessions are non-negative, minutes and extra minutes are non-negative, completed projects is positive, target hours is non-negative and planned session minutes is positive. The positive denominators prevent division by zero.
These assumptions are written guidance, not enforced checks. If the user enters a word instead of a number, conversion can fail. Adding decisions, retries and exception handling is a later improvement.
04 | PLAN THE INPUT, PROCESS AND OUTPUT
Input collects values. Processing converts and calculates. Output communicates the result. Write those three roles before coding so you know what each line contributes.
The main formulas are total_minutes = sessions × minutes_per_session + extra_minutes, total_hours = total_minutes / 60, and average_minutes_per_project = total_minutes / projects.
The future block uses target_minutes = target_hours × 60. Complete planned sessions = target_minutes // planned_minutes. Leftover minutes = target_minutes % planned_minutes. The leftovers are the unused part of that target block after the complete sessions, not proof you must do another complete session.
05 | BUILD THE GREETING FIRST
Create practice_calculator.py. Begin with a title and the user’s first name. strip surrounding whitespace and print a greeting. Save and run this before adding any calculations.
That first run checks your file, editor, interpreter and input location. If it fails, the problem is confined to a few lines instead of a long unfinished project.
# Personalised practice calculator
print("Practice planner")
username = input("First name: ").strip()
print(f"Welcome, {username}!")06 | ADD THE COMPLETED PRACTICE CALCULATION
Collect sessions, session duration and extra minutes. The count is int; durations can be float. Multiplication happens before addition, matching the intended formula.
With three sessions of twenty-five minutes and ten extra minutes, the total is 3 × 25 + 10 = 85 minutes. Dividing by sixty gives about 1.4167 hours.
Print a clear minutes report first. Then add the hours calculation. A small verified step is easier to debug than several untested formulas added together.
sessions = int(input("Completed sessions (whole number, 0 or more): "))
minutes_per_session = float(input("Minutes per completed session: "))
extra_minutes = float(input("Extra practice minutes: "))
total_minutes = sessions * minutes_per_session + extra_minutes
total_hours = total_minutes / 60
print(f"Completed practice: {total_minutes:.1f} minutes")07 | ADD AN AVERAGE WITH A MEANING
Ask for the positive number of completed projects. Divide total practice minutes by that count. The result is an average allocation of practice time per project, not a measurement of how long every individual project took.
With 85 minutes and two projects, the mean is 42.5 minutes. If the count is zero, the calculation is undefined and Python raises ZeroDivisionError. State the positive-count assumption now and plan a guard when you learn selection.
projects = int(input("Completed projects (whole number greater than 0): "))
average_minutes = total_minutes / projects
print(f"Average practice per project: {average_minutes:.1f} minutes")08 | PLAN A SEPARATE FUTURE PRACTICE BLOCK
Ask for a whole-number target in hours and a positive whole-number future session duration in minutes. Convert the target into minutes using sixty minutes per hour.
A two-hour target gives 120 minutes. With 25-minute sessions, four complete sessions use 100 minutes and leave twenty. The quotient counts complete sessions; the remainder is minutes, not part of a session count.
Check the reconstruction: 4 × 25 + 20 = 120. This provides a quick test that the units and operators are correct.
MINUTES_PER_HOUR = 60
target_hours = int(input("Future target hours (whole number, 0 or more): "))
planned_minutes = int(input("Future session minutes (whole number greater than 0): "))
target_minutes = target_hours * MINUTES_PER_HOUR
complete_sessions = target_minutes // planned_minutes
leftover_minutes = target_minutes % planned_minutes09 | THE COMPLETE CORE PROGRAM
The complete version below uses readable sections and a named conversion constant. Run it with the sample values before personalising its wording. The f-string formats make the report readable but do not change the stored calculations.
# Personalised practice calculator
# Core version assumes valid numbers and positive divisors.
MINUTES_PER_HOUR = 60
print("Practice planner")
username = input("First name: ").strip()
sessions = int(input("Completed sessions (whole number, 0 or more): "))
minutes_per_session = float(input("Minutes per completed session: "))
extra_minutes = float(input("Extra practice minutes: "))
projects = int(input("Completed projects (whole number greater than 0): "))
target_hours = int(input("Future target hours (whole number, 0 or more): "))
planned_minutes = int(input("Future session minutes (whole number greater than 0): "))
# Completed practice and mean allocation per project
total_minutes = sessions * minutes_per_session + extra_minutes
total_hours = total_minutes / MINUTES_PER_HOUR
average_minutes = total_minutes / projects
# A separate future practice block
target_minutes = target_hours * MINUTES_PER_HOUR
complete_sessions = target_minutes // planned_minutes
leftover_minutes = target_minutes % planned_minutes
print()
print(f"Practice report for {username}")
print(f"Completed practice: {total_minutes:.1f} minutes")
print(f"Completed practice: {total_hours:.2f} hours")
print(f"Average practice per project: {average_minutes:.1f} minutes")
print(f"Future target block: {target_minutes} minutes")
print(f"Complete future sessions: {complete_sessions}")
print(f"Unused time in that block: {leftover_minutes} minutes")10 | TEST WITH EXPECTED ANSWERS
Use name Maya, completed sessions 3, minutes per session 25, extra minutes 10, projects 2, future hours 2 and future session minutes 25. Predict the completed total 85, displayed hours 1.42, average 42.5, target 120, complete future sessions 4 and leftover 20.
Test exact division with future hours 1 and session minutes 20: three sessions and zero remainder. Test zero future hours with a positive session size: zero sessions and zero leftover. Test fractional completed session duration such as 12.5 to confirm float input is useful.
Record actual results beside predictions. Deliberately test projects = 0, planned_minutes = 0 and non-numeric input to document the core version’s limitations. An expected failure should be recorded, not hidden.
11 | USE THE PROJECT MODEL TO CHECK YOUR MATHS
The browser model below previews the project’s formulas for sensible input. It checks these form values, while the core Python script still relies on its stated assumptions. The browser is not executing your Python source.
12 | PERSONALISE WITHOUT BREAKING THE FORMULAS
Choose a theme such as robotics practice, music rehearsal or coding sessions. Change the title, prompts and output wording. Keep the quantities and units consistent with the formulas.
Add one extra useful calculation, such as total completed minutes converted to seconds. Explain its formula before coding it. A decorative title is welcome, but a meaningful new result shows more understanding.
Keep a working copy before extending. Change one feature, rerun the ordinary tests and check that existing results still match. This is a simple regression check: a new change should not silently damage a previously correct calculation.
13 | REFLECT ON WHAT YOUR PROGRAM CAN DO
Explain how the source uses every Section 1 skill: saved file, print, comments, variables, types, input, conversions and arithmetic. Point to a line for each rather than only naming the idea.
Identify limitations honestly: it cannot yet recover from bad numeric text, choose a menu option or repeat automatically. The next section introduces comparisons and decisions so your programs can respond to different situations.
Final challenge: write a short user guide with valid sample inputs, units and one complete expected report. Give the program to a partner to test without coaching them through each prompt.