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, they have different hours, # so when choosing where to go, you have to think about who's # still open! # # Imagine you're choosing between the following restaurants: # # - Barrelhouse: Closes at 11:00PM # - Taco Bell: Closes at 2:00AM # - Cookout: Closes at 3:00AM # - Waffle House: Never closes. Ever. # # Assume that this list is also a priority list: if Barrelhouse # is open, you choose Barrelhouse. If not, you choose Taco Bell # if it's open. If not, you choose Cookout if it's open. If # not, you choose Waffle House. # # However, there are two wrinkles: # # - We're using 12-hour time. # - hour will always represent a time from 10PM to 5AM. # # That means that if hour is 10 or 11, it's PM; if hour is # 12, 1, 2, 3, 4, or 5, it's AM. This will make your reasoning # a little more complex. You may assume that all four # restaurants open later than 6AM, though, so you don't have # to worry about opening time, just closing time. # # Add some code below that will print what restaurant you'll # go to based on the current values of hour and minute. # Add your code here!
Code:
#code
#Given value of hour and minute-
hour = 3
minute = 45
#Applying conditions:
#Since,restaurants opens after 6 AM,so one will go to Barrelhouse if hour is less than 11(first priority)
if hour>6 and hour < 11:
print("Barrelhouse")
#if its less than 2AM then one will go to tacko bell(second priority as it will execute only if first condition does not executes.
elif hour<2:
print("Taco Bell")
#if its less than 3AM then one will go to tacko bell(will come to this condition only when both of the above condition fails).
elif hour<3:
print("Cookout")
#if none of the conditio is satisfied then one will go to Waffelhouse which is always open.
else:
print("Waffelhouse")
Output:
Create a new program in Mu and save it as ps3.2.1.py and take the code below...
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 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 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 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.2.2.py and take the code below and fix it as indicated in the comments: # Write a function called "in_parentheses" that accepts a # single argument, a string representing a sentence that # contains some words in parentheses. Your function should # return the contents of the parentheses. # # For example: # in_parentheses("This is a sentence (words!)") -> "words!" # # If no text appears in parentheses, return an...
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...
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.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 ps3.4.3.py and take the code below and fix it as indicated in the comments: # Consult this blood pressures chart: http://bit.ly/2CloACs # # Write a function called check_blood_pressure that takes two # parameters: a systolic blood pressure and a diastolic blood # pressure, in that order. Your function should return "Low", # "Ideal", "Pre-high", or "High" -- whichever corresponds to # the given systolic and diastolic blood pressure. # #...