Question: I am confused on how to create a function then add an assert statement, then use that statement to create a formula. Please help Create

I am confused on how to create a function then add an assert statement, then use that statement to create a formula. Please help

Create a function named yards_to_meters(yds) 1.1 Include an assert to check 'yds' is an int with error message text = 'yds value is not an integer' 1.2 Convert 'yds' to 'meters' 1.3 Return the value of 'meters'

print("QUESTION 1 - ANSWERS")

# TEST CASE 1 try: meters = yards_to_meters(100) except AssertionError as msg: print("TEST1: ", "yards_to_meters(100) failed") print("TEST1: ", msg) else: print("TEST1: ", "yards_to_meters(100) passed") print("TEST1: METERS = ", meters) print()

# TEST CASE 2 try: meters = yards_to_meters(60.5) except AssertionError as msg: print("TEST2: ", "yards_to_meters(100) failed") print("TEST2: ", msg) else: print("TEST2: ", "yards_to_meters(100) passed") print("TEST2: METERS = ", meters) print()

# TEST CASE 3 try: meters = yards_to_meters('100') except AssertionError as msg: print("TEST3: ", "yards_to_meters(100) failed") print("TEST3: ", msg) else: print("TEST3: ", "yards_to_meters(100) passed") print("TEST3: METERS = ", meters) print() # TEST CASE 4 try: meters = yards_to_meters(40) except AssertionError as msg: print("TEST4: ", "yards_to_meters(100) failed") print("TEST4: ", msg) else: print("TEST4: ", "yards_to_meters(100) passed") print("TEST4: METERS = ", meters) print()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!