What We Did Today
- Started creating a Grocery System using classes
Homework
Create a file called June25_MoreClassPractice.py and submit into the google drive when you are finished:
- Yanbao:
- Catch up and review on 6/18’s lesson.
- Upload the below homework to your Google Drive:
- 6/18 HW
- 6/20 HW
- This week’s HW
- Everyone:
- Continue our class’s Jun25_GrocerySystemWithClass project
- Created 2 more items in our dictionary
- Key 4 will have Butter with price of 2
- Key 5 will have Salt with price of 3
- Add the below code underneath our inventory. This is the answer for the challenge question in class. Do your best to understand the code – I will review it next class.
- Create an empty list shopping_cart
- Create an integer variable total_cost
- Create the rest of the program.
- Assign the variable “selection” with the answer returned from print_menu()
- Break from the program if user enters “99”
- If the user enters something that is not in the dictionary’s keys, print: “Invalid selection, please try again”
- If the user enters a valid key:
- Add that item’s price to the total cost.
- Add the item’s name to the shopping cart.
- Print: “You purchased [item’s name] for $[item’s price]
- After the user breaks from the program, print: “You have purchased [length of shopping_cart] items”
- Afterwards, loop and print everything in the shopping_cart list
- Afterwards, print: Thank you for your business, please pay $[total_cost]
- Do the Try It Yourself section on pg.167. Make sure to label each section with comments (Ex: #9-4, #9-5)
- Review the different data types. I will ask everyone next week these questions so be prepared: “What are objects? Is it a data type? Why is it important? How are they different from other data types?”
- 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