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 # # For simplicity, we'll assume Modifier is 1 # # Add code below such that the program prints the total damage # caused based on the variables given above. # # Hint: Don't try to do all these calculations at once! Break # the complicated formula down into bite-sized little chunks. # Add your code here!
Create a new program in Mu and save it as ps2.4.4.py
Take the code below and fix it as indicated in the comments:
start_hour = 3 start_minute = 48 length = 172 # You may modify the lines of code above, but don't move them! # Your code should work with different values for the variables. # Let's try something trickier! The variables above represent # the start time for a run as well as the length of the run # in minutes. The original values, for example, show a run # that started at 3:48 and lasted 172 minutes. # # Add some code below that will print the time at which the # run will end, using normal formatting (e.g. 6:40 for the # original data above). To do this, you'll need to somehow # find both the hours and minutes of the new time, convert # both to strings, and add those to the colon ":" to print # the time. # # You may assume that the length of the run will never cross # 12:59 (e.g. you don't have to worry about going from # 12:59 to 1:00 or 23:59 to 0:00). You also don't need to # worry about the lack of 0 in front of single-digit minute # counts (e.g. it's fine to show 5:07 as 5:7). #Add your code here!
#ps2.4.3.py
level = int(input("Enter the level: ")) #taking input for
level
attack = int(input("Enter the attack: ")) #taking input for
attack
defence = int(input("Enter the defence: ")) #taking input for
defence
power = int(input("Enter the power: ")) #taking input for
power
modifier = 1 #since modifier is assumed to be 1
print("Modifier assumed to be:",modifier)
level_modified = ((2*level)/5) + 2 #calculates the first
calculation on level
a_d = attack/defence #calculates the ratio of attack and defence
damage = ((level_modified * power * a_d)/50)+2 #calculating
damage without modifier
damage_modified = damage * modifier #calculating damage with
modifier
print("\nThe damage dealt is -> ",int(damage_modified))
#printing it out in int since health is not float
#ps2.4.4.py
start_hour = int(input("Enter the starting hour: ")) #enter the
starting hour
start_minute = int(input("Enter the starting minutes les than 60:
")) #enter the starting minute
length = int(input("Enter the length: ")) #enter the length to be
added
current_minutes = (start_hour * 60) + (start_minute) #converting
the whole start_time into minutes
#i.e. 1 hour has 60mins so (start_hour * 60) + start_minute
final_minutes = current_minutes + length
#we add the length to current_minutes
end_hour = final_minutes//60 # dividing the final_minutes by 60,
// returns integer value
end_minute = final_minutes%60 #finds the remainder after dividing
by 60
end_time = str(end_hour) + ":" + str(end_minute) #converting it
into a string with ':'
print("\n\nThe final time is: ",end_time) #printing
Create a new program in Mu and save it as ps2.4.3.py Take the code below and...
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 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.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 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.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. # #...
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.2.1.py and take the code below and fix it as indicated in the comments: # Write function called third_character that accepts a # string as an argument and returns the third character # of the string. If the user inputs a string with fewer than # 3 characters, return "Too short". # Write your function here! # Below are some lines of code that will test your function. # You...
Create a new program in Mu and save it as ps3.4.1.py and take the code below and fix it as indicated in the comments: # Write a function called hide_and_seek. The function should # have no parameters and return no value; instead, when # called, it should just print the numbers from 1 through 10, # follow by the text "Ready or not, here I come!". Each # number and the message at the end should be on its own...