« All Events
5 PM – Intro To Python – Gamas
November 20 @ 5:00 pm - 6:00 pm
Today We Did
- We reviewed homework
- We continued with grocery_shopping_cart.py
Homework
- Create nov_20_random_hw2.py and copy and paste this code and tell me what it is doing
import random as r
cars = []
cars.append("honda")
cars.append("hyundai")
cars.append("toyota")
random_car = r.choice(cars)
print(random_car)
- Inside your oct_30_grocery_shopping_cart.py
- Change the code, so you can add “Egg”, “Milk” and “Orange Juice” to the purchased_item list. This is very similar to what you did in nov_13_elements_practice_hw.py homework
- After the while loop, you have to use for loop to go through each element inside the “purchased_item” list and print the item. This is also very similar to what you did in nov_13_elements_practice_hw.py.
- If you do it properly, your program will do like the following
What do you want to purchase:
1. Milk - $5
2. Eggs - $3
3. Orange Juice - $6
Enter your selection 1 to 3 (Enter 'exit' for quit): 1
You have purchased Milk for $5
What do you want to purchase:
1. Milk - $5
2. Eggs - $3
3. Orange Juice - $6
Enter your selection 1 to 3 (Enter 'exit' for quit): 1
You have purchased Milk for $5
What do you want to purchase:
1. Milk - $5
2. Eggs - $3
3. Orange Juice - $6
Enter your selection 1 to 3 (Enter 'exit' for quit): 2
You have purchased Egg for $3
What do you want to purchase:
1. Milk - $5
2. Eggs - $3
3. Orange Juice - $6
Enter your selection 1 to 3 (Enter 'exit' for quit): 3
You have purchased Orange Juice for $6
What do you want to purchase:
1. Milk - $5
2. Eggs - $3
3. Orange Juice - $6
Enter your selection 1 to 3 (Enter 'exit' for quit): exit
You have purchased the following items:
Milk
Milk
Egg
Orange Juice
You have to pay $19.
- Create nov_20_turtle_green_grapes_hw.py and draw the following drawing using python turtle
- Copy the rectangle and circle functions from your old projects
- There should be total of 23 grapes
- 1st row 5 grapes
- 2nd row 6 grapes
- 3rd row 5 grapes
- 4th row 4 grapes
- 5th row 2 grapes
- 6th row or bottom row 1 grape