« All Events
3 PM – Python OOP – Allison
July 23, 2025 @ 3:00 pm - 4:00 pm
- Make sure to do the below code in your SupermarketSystem project
- Upload main2.py as July23_main2.py
- In your main2.py file:
- In print_menu:
- Print by looping through everything in the menu_items dictionary. The result should be:
- 1 – Ice Cream – $5
- 2 – Fish – $4
- 3 – Cookies – $6
- Afterward, get user input by asking “Enter your selection or enter “Check Out” to checkout”
- Return user input
- Create a check_out function:
- Print: You have purchased (shopping cart’s length) items
- Create a variable called money and assign 0
- Loop through everything in the shopping cart
- If the item is frozen food, print: (item’s name) – remember to store inside a freezer
- If the item is not frozen food, just print the item’s name
- Make sure to add the item’s price to the money variable
- After the loop is done, print: Thank you for your business. Please pay $(money)
- In application_loop:
- Create a variable selection. Assign it with the value that print_menu returns.
- If user selection is check out
- call the check_out method and break from loop
- If user selection is invalid, print invalid selection
- This time, I want you to check if it’s invalid by checking if it doesn’t exist in the menu_item keys
- If the user selection is something else:
- Add the Grocery Item object the user chose to the shopping cart (hint: use your dictionary)
- Ex: If the user selects option 2, the Fish Grocery Item should be added
- Print: You have purchased {grocery object’s name} for ${grocery object’s price}
- Other
- Add any missing parts of your class notes from our class notes (see link at bottom)
- Review the homework answers (see link at bottom)
Notes
- You can reach out via allison@ayclogic.com if you have any questions.
- Class notes and previous homework answers can be found here: Link to Google Drive