Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please help me with this code 6. 18 Lab training: Unit tests to evaluate your program Auto-graded programming assignments may use a Unit test to
please help me with this code
6. 18 Lab training: Unit tests to evaluate your program Auto-graded programming assignments may use a Unit test to test small parts of a program. Unike a Comoare output test, which evaluates your program's putput for specific ingut values, a Unit test evaluates individual functions to determines if each function - is named correctly and has the correct parameters and return type - calculates and returns the correct value (or prints the correct output) The zyLabs auto-grader runs main.py as a soript in main.py, the line if _name _ =- main _% is used to separate the main code from the functions' code so that each fubction can be unit teated. Enter statements to be run as the main code under if _ name - "* - main _ : Indent the statements so the statements beiong to the if block Refer to the subsection importing modules ind executing scripts under section Modve basics for moreinformation about running a program as a script Note Do not remove if __ name__" __ "ain_" from the code Otherwise, the unit tosts will fail even though the program produces the correct output. This example lab uses multiple unit tests to test the kio to pounds0 function. Complete a program that takes a weight in klograms as input, converts the weight to pounds, and then outputs the weight in pounds 1 kilogram =2.204 pounds (lbs). The program must define the following function: def kilo_to_pounde ( kilos ) - take kilos as a parameter, convert kilos from kilograms to pounds, and return the weight in pounds: Ex: If the input of the program is: The program below has an error in the kilo_to_pounds0 function 1. Try submitting the program for grading (click "Submit mode;, then 'submit for grading') Notice that the first two test cases fail, but the third test case passes. The first test case fails because the program outputs the resuit from the klo-to. pound9i) function which bas an error. The second test case uses a unit test to test the kilo to pounds( function, which fails. 2. Change the kilo to pounds0 function to multiply the variable kilos by 2.204, instead of dividing The retum statement should be return (kilos 2.204 ) Submit again. Now the test cases should all pass Note: A common error is to mistype a function name with the incorrect capitalization. Function names are case sensitive, so if a lab program asks fora kilo. to.pounds() function, a kilo. To.Pounds() function that works for you in "Develop mode' will result in a falled unit lest. The unit test will not be able to find kilo, to pounds0. main.py Output differs. See highlights below Input Your output Expected output 2. Unit test Tests kilo_to_pounds (10) returns 22.040 Test feedback 3.Unit test Tests kilo_to pounds (0) returns 0.0 Test feedback Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started