[SOLVED] IT5001 Lab 2- Functions, Selection and Repetition

35.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon Lab-2-ntbkw0.zip (210.2 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
πŸ”’ Securely Powered by:
Secure Checkout
5/5 - (2 votes)

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

  • Lab-2-ntbkw0.zip