PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Q/A example
# Ballpark Orders
# Get order sperated by spaces
# This will create a list of items ordered
order = input().split()
# Initialize variables
subtotal = 0.0
total = 0.0
# Menu items and prices
items_dict = {
"Nachos" : 6,
"Pizza" : 6,
"Coke" : 5,
"Cheeseburger" : 10,
"Water" : 4
}
# Iterate through order and calculate cost
for i in order:
if i in items_dict:
#add item price to subtotal
else:
# Item does not exist so order a coke instead
# Calculate tax and add to total
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run