Computers and Technology
Computers and Technology, 05.05.2021 18:30, eayoungin

Needed in python! Auto-graded programming assignments may use a Unit test to test small parts of a program. Unlike a Compare output test, which evaluates your program's output for specific user input 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)
This example lab uses multiple unit tests to test the kilo_to_pounds() function.
Complete a program that takes a weight in kilograms as input, converts the weight to pounds, and then outputs the weight in pounds. 1 kilogram = 2.204 pounds (lbs).
Ex: If the input is: 10
the output is:
22.040000000000003 lbs
Note: Your program must define the function
def kilo_to_pounds(kilos)
The program below has an error in the kilo_to_pounds() function.
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 result from the kilo_to_pounds() function, which has an error. The second test case uses a Unit test to test the kilo_to_pounds() function, which fails.
Change the kilo_to_pounds() function to multiply the variable kilos by 2.204, instead of dividing. The return 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 for a kilo_to_pounds() function, a kilo_to_pounds() function that works for you in develop mode will result in a failed unit test (the unit test will not be able to find kilo_to_pounds()).
Code given in zybooks:
def kilo_to_pounds(kilos) {
# This statement intentionally has an error.
return (kilos / 2.204)
if __name__ == '__main__':
kilos = float(input());
pounds = kilo_to_pounds(kilos);
print(pounds, "lbs");

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 13:00, Cookie320
Write a program which asks you to enter a name in the form of first middle initial last. so you might enter for example samuel p. clemens. use getline to read in the string because it contains spaces. also, apparently the shift key on your keyboard doesn’t work, because you enter it all lower case. pass the string to a function which uses .find to locate the letters which need to be upper case and use toupper to convert those characters to uppercase. the revised string should then be returned to main in the form last, first mi where it will be displayed.
Answers: 1
image
Computers and Technology, 22.06.2019 14:30, camerondillonn
If the polar bear were taken out of the food chain what would happen to the seal population the seal population would diminish the seal population would grow dramatically the seal population would stay the same the seal population would decrease slightly
Answers: 1
image
Computers and Technology, 23.06.2019 02:30, jaueuxsn
Which component acts as a platform on which application software runs
Answers: 2
image
Computers and Technology, 23.06.2019 11:00, shawn20034
This chapter lists many ways in which becoming computer literate is beneficial. think about what your life will be like once you’re started in your career. what areas of computing will be most important for you to understand? how would an understanding of computer hardware and software you in working from home, working with groups in other countries and contributing your talents.
Answers: 1
Do you know the correct answer?
Needed in python! Auto-graded programming assignments may use a Unit test to test small parts of a...

Questions in other subjects: