American Young Coder

AYC logo
Loading Events

« All Events

  • This event has passed.

5 PM – Python OOP – Allison

July 18 @ 5:00 pm - 7:00 pm

What We Did Today

  1. Finished LibrarySystem project

Homework

  1. Read the July18_main_with_bug_fixes file and update your own main.py from the Library System project. See the highlights and comments to see which parts should be updated. Updates include bug fixes and small ways to improve our code.
  2. Make sure to do the below code in your SupermarketSystem project
  3. When you’re done with the homework, create a folder called July18_SupermarketSystem in your Google Drive. Upload main.py and book.py there.
  4. Create grocery_item.py file.
    1. Create a Grocery Item class. It should have  3 attributes: name, price, and frozen_food
  5. In your main.py file:
    1. Create an empty list called shopping_cart
    2. Create a menu that says:
      • What do you want to purchase:
        1. Ice Cream – $5
        2. Fish – $4
        3. Cookies  – $6
        4. I am done, checkout please
        Enter your selection:
    3. Create a dictionary called menu_items
    4. Add the below to menu_items dictionary:
      1. key: “1”, value: Grocery Item with the name Ice Cream, price 5, and frozen_food = True
      2. key: “2”, value: Grocery Item with the name Fish, price 4, and frozen_food = True
      3. key: “3”, value: Grocery Item with the name Cookies, price 6, and frozen_food = False
    5. Create an application loop
      1. If user selection is invalid, print invalid selection
      2. If user selection is 4, break out of while loop
      3. 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 Eggs Grocery Item should be added
        2. Print: You have purchased {grocery object’s name} for ${grocery object’s price}
  6.  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 18
Time:
5:00 pm - 7:00 pm
Event Categories:
,