def test_getVelocitySkater(self): #test with tomato mass self.assertEqual(funcs.getVelocitySkater(100, .1, 7), .007) self.assertEqual(funcs.getVelocitySkater(140, .1, 9.899), .007) #test with banana cream pie mass self.assertEqual(funcs.getVelocitySkater(100, 1.0, 7), .07) self.assertEqual(funcs.getVelocitySkater(140, 1.0, 9.899), .071) #test with rock self.assertEqual(funcs.getVelocitySkater(100, 3.0, 7), .21) self.assertEqual(funcs.getVelocitySkater(140, 3.0, 9.899), .212) #test with gnome self.assertEqual(funcs.getVelocitySkater(100, 5.3, 7), .371) self.assertEqual(funcs.getVelocitySkater(140, 5.3, 9.899), 0.375) #test with lightsaber self.assertEqual(funcs.getVelocitySkater(100, 9.03, 7), .632) self.assertEqual(funcs.getVelocitySkater(140, 9.03, 9.899), .638)
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(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 = 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 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_vs_3(self): self.assertEqual(funcs.getVelocitySkater(0, 1, 1), "-nan")
def test_vs_2(self): self.assertEqual(funcs.getVelocitySkater(130, .2, 30), 0.046153846153846156)
def test_vs_1(self): self.assertEqual(funcs.getVelocitySkater(2, 2, 2), 2)
def test_getVelocitySkater_6(self): self.assertAlmostEqual(funcs.getVelocitySkater(1, 3, 27), 81)
def test_getVelocitySkater_4(self): self.assertAlmostEqual(funcs.getVelocitySkater(3.0, 3.0, 27.0), 27.0)
def test_getVelocitySkater_2(self): self.assertAlmostEqual(funcs.getVelocitySkater(1, 1, 54.0), 54.0)
def test_getVelocitySkater(self): self.assertAlmostEqual(funcs.getVelocitySkater(50, 1, 10), 0.2) self.assertAlmostEqual(funcs.getVelocitySkater(35, 2.5, 6), 0.4285714)
def test_getVelocitySkater(self): self.assertAlmostEqual( funcs.getVelocitySkater(49.89512, 0.1, 12.124355), 0.02429968101) self.assertAlmostEqual( funcs.getVelocitySkater(58.96696, 5.3, 21.679483), 1.9485701806)
def test_getVelocitySkater(self): answer13 = funcs.getVelocitySkater(5.0, 0.1, 0) self.assertAlmostEqual(answer13, 0) answer14 = funcs.getVelocitySkater(10, 9.07, 54) self.assertAlmostEqual(answer14, 48.978)