American Young Coder

AYC logo
Loading Events

« All Events

  • This event has passed.

3 PM – Python OOP – Allison

July 23 @ 3:00 pm - 4:00 pm

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

Notes

  1. You can reach out via allison@ayclogic.com if you have any questions.
  2. Class notes and previous homework answers can be found here: Link to Google Drive

Details

Date:
July 23
Time:
3:00 pm - 4:00 pm
Event Categories:
,