Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions