top of page

Extended Task 1

noun-project-5888539-FFFFFF.png

Pete Porker's Pork Pie Emporium

Hello, Pete Porker here...

I need a new program for customer orders at my bakery.

I need the customer to enter how many scotch eggs (49p each), pork pies (85p each) and quiche tarts (£1.45) they want to order.

Next, ask them to confirm their choice. If they are not happy, ask the questions again.

If they confirm their choice, print a receipt showing their order and total.

To make your program better, you should use validation (either while loops or error handling) to make sure that a user must enter a correct value.

noun-trophy-355128-C98C70.png

Bronze Award

--- Welcome to Pete Porker's Pork Pie Emporium ---

Scotch eggs are 45p, pork pies are 85p and quiche tarts are £1.49.

Enter the number of scotch eggs to buy: 9
Enter the number of pork pies to buy: 7
Enter the number of quiche tarts to buy: 4
-----
You selected 9 scotch eggs, 7 pork pies and 4 quiche tarts.

9 scotch eggs = £4.05
7 pork pies = £5.95
4 quiche tarts = £5.96

-------
Total: £15.96

There are many ways to create this program, but below are some suggestions:

Use inputs with int to let the user enter how many of each item they want.

Use total variables, e.g. totaleggs = eggs * 0.45 to work out the total cost for eggs, pies and tarts.

Set a finalcost variable by adding the total of the three items together.

Use dashes and \n (which makes a new line) inside speech marks to make your program more presentable.

noun-trophy-355128-D3D3D3.png

Silver Award

--- Welcome to Pete Porker's Pork Pie Emporium ---

Scotch eggs are 45p, pork pies are 85p and quiche tarts are £1.49.

Enter the number of scotch eggs to buy: 5
Enter the number of pork pies to buy: 3
Enter the number of quiche tarts to buy: 6
-----
You selected 9 scotch eggs, 7 pork pies and 4 quiche tarts.
-----
Are you happy with this selection?
no

Okay, enter your choices again.

Enter the number of scotch eggs to buy: 6
Enter the number of pork pies to buy: 2
Enter the number of quiche tarts to buy: 7
-----
You selected 6 scotch eggs, 2 pork pies and 7 quiche tarts.
-----
Are you happy with this selection?
yes

Excellent! Here is your receipt:

6 scotch eggs = £2.70
2 pork pies = £1.70
7 quiche tarts = £10.43

-------
Total: £14.83

There are many ways to improve this program and below are some suggestions:

Use a while loop to repeat the input stage until the user is happy with their choices.

You will need to ask the user if they are happy with the values that were entered and then use an if statement to repeat the loop if they enter 'no'.

Gold Award

Example solution:

noun-trophy-355128-FFB258.png

--- Welcome to Pete Porker's Pork Pie Emporium ---

Scotch eggs are 45p, pork pies are 85p and quiche tarts are £1.49.

Enter the number of scotch eggs to buy: 9
Enter the number of pork pies to buy: 35

Sorry you must enter a number between 1 and 20. Starting again...

 

Enter the number of scotch eggs to buy: 9

Enter the number of pork pies to buy: 20
Enter the number of quiche tarts to buy: 7
-----
You selected 9 scotch eggs, 20 pork pies and 7 quiche tarts.
-----
Are you happy with this selection?
YES

Excellent! Here is your reciept:

9 scotch eggs = £4.05
20 pork pies = £17.00
7 quiche tarts = £10.43

-------
Total: £31.48

There are many ways to make this program even better and below are some suggestions:

Include validation so that the user can only enter numbers between 1 and 20. You will need to use if statements and the and operator to do this.

You can include additional features to your program such as rounding the number to two decimal places and including coloured text using the Colorama library (which will only work if you are using an online editor like Replit).

You can use the .lower() command when checking if the user is happy with their choices to automatically accept 'Yes' and 'YES'.

If you really want to challenge yourself you could consider outputting the receipt in order from most expensive to least expensive, using if statements to check the three values (although that has not been done in this example on the left).

bottom of page