Create a new program in Mu and save it as ps3.2.2.py and take the code below and fix it as indicated in the comments:
egg = True milk = True butter = True flour = True # You may modify the lines of code above, but don't move them! # When you Submit your code, we'll change these lines to # assign different values to the variables. # Imagine you're deciding what you want to cook. The boolean # variables above state whether or not you have each of those # four ingredients. # # Here are the dishes you know how to cook and their # ingredients: # # 1. pancakes: egg, milk, butter, flour # 2. omelette: egg, milk, butter # 3. custard: egg, milk # 4. poached eggs: egg # # The list above is also a priority list. If you have the # ingredients for pancakes, you'll make pancakes instead of # any of the other dishes. If you're missing flour but have # the other ingredients, you'll make an omelette. You'll only # make poached eggs if the only ingredient you have is eggs. # # Complete the program below such that it prints which dish # you'll make based on the ingredients you have handy. All # the dishes should appear exactly as shown above: all lower # case, spelled the same way. If you do not have the # ingredients to make any of these dishes, then print the # text "Go to the store!" # Add your code here!
Code:
egg = True
milk = True
butter = True
flour = True
if egg==True and milk==True and butter==True and flour==True:
print("pancakes")
elif egg==True and milk==True and butter==True :
print("omelette")
elif egg==True and milk==True:
print("custard")
elif egg==True :
print("poached eggs")
else:
print("Go to the store!")
Output:
Create a new program in Mu and save it as ps3.2.2.py and take the code below...
Create a new program in Mu and save it as ps3.2.1.py and take the code below and fix it as indicated in the comments: hour = 3 minute = 45 # You may modify the lines of code above, but don't move them! # When you Submit your code, we'll change these lines to # assign different values to the variables. # Around Georgia Tech, there are plenty of places to get a # late night bite to eat. However,...
Create a new program in Mu and save it as ps2.4.3.py Take the code below and fix it as indicated in the comments: Level = 50 Attack = 125 Defense = 110 Power = 60 Modifier = 1 # You may modify the lines of code above, but don't move them! # Your code should work with different values for the variables. # In the Pokemon game franchise, damage is calculated using this formula found here: # https://bulbapedia.bulbagarden.net/wiki/Damage # #...
Create a new program in Mu and save it as ps2.3.3.py Take the code below and fix it as indicated in the comments: busy = True hungry = False tired = True stressed = False # You may modify the lines of code above, but don't move them! # Your code should work with different values for the variables. # Logical operators get more complex when we start using them # with the results of other logical operators. So, let's...
Create a new program in Mu and save it as ps3.3.1.py and take the code below and fix it as indicated in the comments: mystery_int = 50 # You may modify the lines of code above, but don't move them! # When you Submit your code, it should work with # different values for the variables. # Write a for loop that prints every third number from 1 to # mystery_int inclusive (meaning that if mystery_int is 7, it #...
Create a new program in Mu and save it as ps2.4.1.py Take the code below and fix it as indicated in the comments: dividend = 7 divisor = 3 # You may modify the lines of code above, but don't move them! # Your code should work with different values for the variables. # The variables above create a dividend and a divisor. Add # some code below that will print the quotient and remainder # of performing this operation....
Create a new program in Mu and save it as ps3.3.3.py and take the code below and fix it as indicated in the comments: mystery_int = 46 # You may modify the lines of code above, but don't move them! # When you Submit your code, it should work with # different values for the variables. # Use a while loop to create a countdown from mystery_int to # 0. Count down by 3s: if mystery_int is 46, then you...
Create a new program in Mu and save it as ps4.3.3.py and take the code below and fix it as indicated in the comments: # Imagine you're writing some code for an exercise tracker. # The tracker measures heart rate, and should display the # average heart rate from an exercise session. # # However, the tracker doesn't automatically know when the # exercise session began. It assumes the session starts the # first time it sees a heart rate...
Create a new program in Mu and save it as ps4.5.2.py and take the code below and fix it as indicated in the comments: # Do not change the line of code below. It's at the top of # the file to ensure that it runs before any of your code. # You will be able to access french_dict from inside your # function. french_dict = {"me": "moi", "hello": "bonjour", "goodbye": "au revoir", "cat": "chat", "dog": "chien", "and": "et"} #...
Create a new program in Mu and save it as ps4.4.1.py and take the code below and fix it as indicated in the comments: # Write a function called "save_leaderboard" that accepts a # single list of tuples as a parameter. The tuples are of the # form (leader_name, score) # The function should open a file called "leaderboard.txt", # and write each of the tuples in the list to a line in the file. # The name and score...
Create a new program in Mu and save it as ps4.3.1.py and take the code below and fix it as indicated in the comments: # Write a function called grade_scantron. grade_scantron should # take as input two lists: answers and key. Each list contain # strings. Each string will be only one letter, a character # from A to E. grade_scantron should return how many questions # the student got "right", where a student gets a question # right if...