$24.99
Part 1 Turtle Graphics (cont.)
Draw the following two figures with Python Turtle.
Part 2 Selection
What is the difference between the following two functions?
def foo(): if True: if False: print(1) else:
print(2)
def foo(): if True: if False: print(1) else:
print(2)
Part 3 Repetition
Part 4 Functions
Nowadays, we can make customizations when we order food. For example, you can order your burger with extra or no cheese. A burger is represented by a string consisting of its ingredients as follows:
● ‘B’ stands for a piece of bun
● ‘C’ stands for cheese
● ‘P’ stands for patty
● ‘V’ stands for veggies
● ‘O’ stands for onions
● ‘M’ stands for mushroom
Examples:
• A simple burger
• ‘BVPB’
• A double cheese burger
• ‘BVCPCPB’
• This one?
• ‘BPVBPVCB’
The price of each ingredient is given:
Ingredient Price
‘B’ stands for a piece of bun $0.5
‘C’ stands for cheese $0.8
‘P’ stands for patty $1.5
‘V’ stands for veggies $0.7
‘O’ stands for onions $0.4
‘M’ stands for mushroom $0.9
Your task is to write a function burgerPrice(burger) that takes in a string representing a burger and returns the price of the burger. For example:
>>> burgerPrice(‘BVPB’)
3.2