def main(): pounds=float(input("How much do you weigh (pounds)? ")) distance=float(input("How far away your profesor is (meters)? ")) object=(input("Will you throw a rotten (t)omato,banana cream (p)ie, (r)ock, (l)ight saber, or lawn (g)nome? ")) massObject=funcs.getMassObject(object) # Get the mass of the object massSkater=funcs.poundsToKG(pounds) # Convert pounds to kg for skater velObj=funcs.getVelocityObject(distance) # Get velocity of obj velocitySkater=funcs.getVelocitySkater(massSkater,massObject,velObj) # Get velocity of obj # Display comment based on the mass of thrown obj and distance thrown if (massObject<=.1): print("Nice throw! You're going to get an F!") elif((massObject>.1) and (massObject<=1.0)): print("Nice throw! Make sure your professor is OK.") elif (massObject>1.0): if (distance<20): print("Nice throw! How far away is the hospital?") elif (distance>=20): print("Nice throw! RIP professor.") # Print velcoity of skater print("Velocity of Skater:",velocitySkater,"m/s") # Display comment based on velocity if (velocitySkater<.2): print("My grandmother skate faster than you!") elif (velocitySkater>=.2)and (velocitySkater<1.0): pass elif (velocitySkater>=1.0): print("Look out for that railing!!!")
def main(): pounds = int(input('How much do you weigh (pounds)? ')) massSkater = poundsToKG(pounds) distance = int(input('How far away is your professor (meters)? ')) massObject = input( 'Will you throw a rotten (t)omato, banana cream (p)ie, (r)ock, (l)ight saber, or lawn (g)nome? ' ) mass = getMassObject(massObject) velObject = getVelocityObject(distance) SkaterVelocity = getVelocitySkater(massSkater, mass, velObject) if mass <= 0.1: print(x, "You're going to get an F!") elif mass > 0.1 and mass <= 1.0: print(x, "Make sure your professor is OK.") elif mass > 1.0: if distance < 20: print(x, "How far away is the hospital?") else: print(x, "RIP professor.") print('Velocity of skater: %.3f m/s' % SkaterVelocity) if SkaterVelocity < 0.2: print("My grandmother skates faster than you!") elif SkaterVelocity >= 1.0: print("Look out for that railing!!!") else: SkaterVelocity = 0
def main(): pounds = float(raw_input('How much do you weigh (pounds)? ')) distance = float(raw_input('How far away is your professor (meters)? ')) object = raw_input( 'Will you throw a rotten (t)omato, banana cream (p)ie, (r)ock, (l)ight saber, or lawn (g)nome? ' ) massSkater = funcs.poundsToKG(pounds) massObject = funcs.getMassObject(object) velObject = funcs.getVelocityObject(distance) velSkater = funcs.getVelocitySkater(massSkater, massObject, velObject) if massObject <= 0.1: statement1 = "You're going to get an F!" elif massObject <= 1.0: statement1 = "Make sure your professor is OK." else: if distance < 20: statement1 = "How far away is the hospital?" else: statement1 = "RIP professor." if velSkater < 0.2: statement2 = "My grandmother skates faster than you!" elif velSkater >= 1.0: statement2 = "Look out for that railing!!!" else: statement2 = "" print "\nNice throw! " + statement1 print "Velocity of skater: %.3f m/s" % velSkater if statement2: print statement2
def main(): pounds = float(input("How much do you weigh (pounds)? ")) distance = float(input("How far away is your professor (meters)? ")) object = input( "Will you throw a rotten (t)omato, banana cream (p)ie, (r)ock, (l)ight saber, or lawn (g)nome? " ) massSkater = float(funcs.poundsToKG(pounds)) massObject = float(funcs.getMassObject(object)) velocityObject = float(funcs.getVelocityObject(distance)) velocitySkater = float( funcs.getVelocitySkater(massSkater, massObject, velocityObject)) velocitySkater = round(velocitySkater, 3) print() if massObject <= 0.1: print("Nice throw!", "You're going to get an F!") elif 0.1 < massObject <= 1.0: print("Nice throw!", "Make sure your professor is OK.") elif massObject > 1.0: if distance < 20: print("Nice throw!", "How far away is the hospital?") elif distance >= 20: print("Nice throw!", "RIP professor.") print("Velocity of skater:", format(velocitySkater, ".3f"), "m/s") if velocitySkater < 0.2: print("My grandmother skates faster than you!") if velocitySkater >= 1.0: print("Look out for that railing!!!")
def test_getMassObject(self): answer3 = funcs.getMassObject('t') self.assertEqual(answer3, 0.1) answer4 = funcs.getMassObject('p') self.assertEqual(answer4, 1.0) answer5 = funcs.getMassObject('r') self.assertEqual(answer5, 3.0) answer6 = funcs.getMassObject('l') self.assertEqual(answer6, 9.07) answer7 = funcs.getMassObject('g') self.assertEqual(answer7, 5.3) answer8 = funcs.getMassObject('a') self.assertEqual(answer8, 0) answer9 = funcs.getMassObject(10) self.assertEqual(answer9, 0) answer10 = funcs.getMassObject(-10.0) self.assertEqual(answer10, 0)
def main(): #Ask how much skater weighs to get massSkater massSkater = int(input("How much do you weigh (pounds)? ")) #use poundsToKG function to get their weight in kilograms mass = funcs.poundsToKG(massSkater) #Ask how far skater is from professor to get distance distance = int(input("How far away is your professor (meters)? ")) #use distance in function getvelocityObject velObject = funcs.getVelocityObject(distance) object = str( input( "Will you throw a rotten (t)omato, banana cream (p)ie, (r)ock, (l)ight saber, or lawn (g)nome? " )) massObject = funcs.getMassObject(object) #I have the massObject skatervelocity = funcs.getVelocitySkater(mass, massObject, velObject) #now I have all the variables... print the ending! print("\nNice throw! ", end="") if massObject <= 0.1: print("You're going to get an F!") elif massObject > 0.1 and massObject <= 1.0: print("Make sure your professor is OK.") elif massObject > 1.0 and distance < 20: print("How far away is the hospital?") elif massObject > 1.0 and distance > 20: print("RIP professor.") #this is the first line of the comments if skatervelocity == "-nan": print("Velocity of skater: -nan m/s") elif skatervelocity != "-nan": print("Velocity of skater:", "%.3f" % skatervelocity, "m/s") if skatervelocity < 0.2: print("My grandmother skates faster than you!") elif skatervelocity >= 0.2 and skatervelocity < 1.0: return "" elif skatervelocity >= 1.0: print("Look out for that railing!!!")
def main(): weight = float(input("How much do you weigh (pounds)? ")) distance = float(input("How far away is your professor (meters)?")) item = input( " Will you throw a rotten (t)omato, banana cream (p)ie, (r)ock, (l)ight saber, or lawn (g)nome? " ) skatermass = funcs.poundsToKG(weight) massObj = funcs.getMassObject(item) velocityObj = funcs.getVelocityObject(distance) velocitySkaterraw = funcs.getVelocitySkater(skatermass, massObj, velocityObj) #determining the response based on the returned mass massresponse = "" if (massObj <= 0.1): massresponse = "You're going to get an F!" elif (massObj > 0.1 and massObj <= 1.0): massresponse = "Make sure your professor is OK" elif (massObj > 1.0 and distance < 20): massresponse = "How far away is the hospital?" elif (massObj > 1.0 and distance >= 20): massresponse = "RIP professor." #converting skater velocity to 3 decimal places velocitySkater = round(velocitySkaterraw, 3) #determining the response based on the returned velocity skaterresponse = "" if (velocitySkater < 0.2): skaterresponse = "My grandmother skates faster than you!" elif (velocitySkater >= 0.2 and velocitySkater < 1.0): skaterresponse = "" elif (velocitySkater >= 1.0): skaterresponse = "Look out for that railing!!!" #printing the outputs print() print("Nice throw!", massresponse) print("Velocity of skater:", velocitySkater, "m/s") print(skaterresponse)
def test_mo_1(self): self.assertEqual(funcs.getMassObject("t"), 0.1)
def test_getMassObject(self): self.assertAlmostEqual(funcs.getMassObject('t'), 0.1)
def test_mo_6(self): self.assertEqual(funcs.getMassObject("e"), 0)
def test_getMassObject_2(self): self.assertAlmostEqual(funcs.getMassObject('p'), 1.0)
def test_mo_4(self): self.assertEqual(funcs.getMassObject("g"), 5.3)
def test_mo_5(self): self.assertEqual(funcs.getMassObject("l"), 9.07)
def test_mo_2(self): self.assertEqual(funcs.getMassObject("p"), 1.0)
def test_mo_3(self): self.assertEqual(funcs.getMassObject("r"), 3.0)
def test_getMassObject(self): self.assertEqual(funcs.getMassObject('t'), .1) self.assertEqual(funcs.getMassObject('p'), 1.0) self.assertEqual(funcs.getMassObject('r'), 3.0) self.assertEqual(funcs.getMassObject('g'), 5.3) self.assertEqual(funcs.getMassObject('l'), 9.07)
def test_getMassObject_3(self): self.assertAlmostEqual(funcs.getMassObject('r'), 3.0)
def test_getMassObject_7(self): self.assertAlmostEqual(funcs.getMassObject(3), 0.0)
def test_getMassObject_5(self): self.assertAlmostEqual(funcs.getMassObject('l'), 9.07)
def test_getMassObject_4(self): self.assertAlmostEqual(funcs.getMassObject('g'), 5.3)