← Back to Unit 1

Week 10 Lesson 01 Challenge

YEAR 9 DIGITAL TECHNOLOGIES • DICTIONARIES CHALLENGE

Pet Service Price Lookup Challenge

In this challenge, you will learn what a dictionary is, how to use it, and then use one to look up pet service prices.

🐾 SCENARIO

The Pet Services business wants a quick way to check prices.

Instead of writing lots of separate variables like wash_price, groom_price and nail_trim_price, you will store all of the services and their prices in one dictionary.

Then your program will ask the user for a service name and find the correct price.

🎯 THE CHALLENGE

Your program must do these 5 things:

  1. Create a dictionary called services.
  2. Store at least 4 pet services and their prices in it.
  3. Ask the user to type the name of a service.
  4. Check whether that service is in the dictionary.
  5. Print either the correct price or a clear message saying the service was not found.

What is a dictionary?

A dictionary stores information as pairs.

Each pair has:

  • a key - the label or thing you look up
  • a value - the information connected to that key

In this challenge:

  • the key is the service name
  • the value is the price

What does that look like in Python?

services = {
    "wash": 25,
    "groom": 40,
    "nail trim": 15,
    "flea treatment": 30
}

How to read this:

  • "wash" is a key
  • 25 is the value for that key
  • A colon : joins the key to the value
  • Commas separate each pair

How do you use a dictionary?

1. Make the dictionary

Create a variable and store the key-value pairs inside curly brackets { }.

2. Ask for a key

In this challenge, the user types the service name.

3. Check whether that key exists

if service_name in services:

4. Get the value from the key

price = services[service_name]

Be crystal clear about what to build

You are building a price lookup program.

Your program is not booking a service, saving to a file, or using a loop menu.

It only needs to do this:

  1. Store service names and prices in a dictionary.
  2. Ask the user to type one service name.
  3. Check whether that name is in the dictionary.
  4. If it is there, print the price.
  5. If it is not there, print Service not found or a similar message.

Minimum requirements

  • Use a dictionary called services
  • Include at least 4 services
  • Ask for user input with input()
  • Use an if statement
  • Use the dictionary to get the price
  • Print clear output
💭 WHAT YOU SHOULD THINK ABOUT
  • Which part is the key?
  • Which part is the value?
  • What happens if the user types a service that is not there?
  • How will your program get the correct price?
  • How can you make your output easy to read?
📌 SUCCESS CRITERIA
  • Your program uses a dictionary correctly.
  • Your dictionary links service names to prices.
  • Your program asks the user for one service name.
  • Your program checks if the service exists.
  • Your program prints the correct price when found.
  • Your program prints a clear message when the service is not found.

Helpful example of the program flow

1. Create the dictionary
2. Ask the user for a service name
3. Check if the service name is in the dictionary
4. If yes, print the price
5. If no, print a message

Example services you could use

  • wash
  • groom
  • nail trim
  • flea treatment
💬 WHAT TO POST IN REPLY BELOW
  • Your code attached as a .py file
✅ REMEMBER

This challenge is about learning how dictionaries connect one thing to another.

Keep your program simple. Make the dictionary work first.