Lesson 2: Generating the Pet Service
Project Overview
We will create a Python program that simulates some type of pet grooming service. The program will collect and interpret information from the user to create a booking summary and calculate a cost.
Project Requirements
- Pet name
- Pet breed
- Petβs age (in human years)
- Another characteristic of pet (example: size)
- Type of service requested (bath, haircut, full grooming)
- Calculate the total cost of the service based on certain characteristics of the pet
- Display a summary of the booking including all the information about the pet that the user input at the start of the program
Lesson 2: Learning Intention
- I can convert my decision tree into a functioning Python program.
- I understand how to store variables and use conditional statements to create a program where user input impacts outcomes.
How we will build the program (3 phases)
- Collecting and storing the user inputs
- Validating and manipulating the data
- Generating the final booking confirmation
Phase 1
In the code below you can see that the program asks for user input and stores that information in a variable with an appropriate name. You will need to replicate a similar idea for your pet services program.
Remember input() always gives you text (a string), so for ages and prices you will often need: int(input("..."))
Phase 2
In my program I decided to convert the dogβs human age to dog years. This requires the dogβs age in human years to be stored as an integer. The code below multiplies this value by 7 before displaying the age in dog years on the final booking confirmation.
The code also checks what size the dog is and changes the price accordingly. You will need to work out what features of your program require you to check or manipulate the data.
Hints for your pet service version
- Think about which inputs affect cost (service type, size, age, breed).
- Use .lower() to make comparing inputs easier (example: "Small" and "small" become the same).
- If you want to check if an answer is valid, you can compare it to a list of allowed options.
Phase 3
When we display the final booking confirmation for the user, there are some clever ways we can use formatting to display text that includes information from our stored variables.
- \n prints the string on a new line
- f in f"..." means a formatted string (f-string). It lets you insert variables using { }.
- .capitalize() makes the first letter uppercase (useful for names)
β Lesson 2 Student Checklist
β I have created variables for each user input (pet name, breed, age, size, service).
β I used int(input("...")) for any value I want to do maths with (like age).
β I used if / elif / else to set a price based on pet characteristics and the selected service.
β My program prints a clear booking summary that includes every key piece of input data.
β My program prints the final total cost.
β My output is readable (new lines, headings, tidy formatting).
Common mistakes and quick fixes
- ValueError when using int(): you typed letters instead of a number. Re-enter the age using digits only.
- My if statement never runs: your input might be "Small" but you checked "small". Fix by using .lower() on the input.
- My output looks messy: add a heading and use \n to space lines out.
π€ Submit (Discussion Reply)
Instead of posting screenshots, you will upload your .py file as your submission.
PetService_FirstnameLastname.py
Example: PetService_AlexNguyen.py
How to upload your .py file in your reply
- In Thonny: File β Save as and save your program.
- Go back to this discussion and click Reply.
- Look for the Attach button (paperclip icon) in the reply box.
- Select your .py file and upload it.
- In your reply text, write 1 to 2 sentences explaining what your pricing rules were (example: size changes price, service changes price).