top of page

## 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.

## 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.

## 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

â€‹

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

â€‹

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:

--- 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

â€‹

â€‹

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).