Answered step by step
Verified Expert Solution
Question
1 Approved Answer
ule Lab Assessment 1: Create a Unit Converter Overview = main.py + 1 def convert_kg(value): 2 # Your code starts here Scenario 3 You work
ule Lab Assessment 1: Create a Unit Converter Overview = main.py + 1 def convert_kg(value): 2 # Your code starts here Scenario 3 You work for a small company that exports artisan chocolate. Although you measure your products in kilograms, you often get orders in both pounds and ounces. You have decided that rather than have to look up conversions all the time, you could use Python code to take inputs to make conversions between the different units of measurement. 4 5 def convert_pounds (value): 6 # Your code starts here 7 8 9 def convert_ounces (value): 10 # Your code starts here 11 You will write three blocks of code. The first will convert kilograms to pounds and ounces. The second will convert pounds to kilograms and ounces. The third will convert ounces to kilograms and pounds. 12 13 if name 14 The conversions are as follows: 15 main": # Test your code here # convert_kg(10) # convert_pounds (10) # convert_ounces (10) 16 17 1 kilogram = 35.274 ounces 18 1 kilogram = 2.20462 pounds 19 20 1 pound = 0.453592 kilograms 1 pound = 16 ounces 1 ounce = 0.0283 kilograms Overview = 1 pound = 0.453592 kilograms 1 pound = 16 ounces 1 ounce = 0.0283 kilograms 1 ounce = 0.0625 pounds For the purposes of this activity the template for a function has been provided. You have not yet covered functions in the course, but they are a way of reusing code. Like a Python script, a function can have zero or more parameters. In the code window you will see three functions defined as def convert_kg(value):, def convert_pounds (value): , and def convert_ounces(value): . Each function will have a block showing you where to place your code. Grading This lab is partially auto-graded and partially manually graded by your instructor. Your instructor may adjust your score up or down based on your "make it your own" task. Complete all lab requirements before you submit your work. To submit, click the checkbox, or checkboxes, and then click the "Submit" button in the task list. = What you need to do 2. Organizing and structuring code for readability. main.py + 1 def convert_kg(value): 2 # Your code starts here 3 3. It is recommended that you use your own test cases in order to check for correctness. You can test your code inside the main__ provided. 4 5 def convert_pounds (value): # Your code starts here 6 Steps for Completion 7 Tasks 8 9 def convert_ounces (value): 10 # Your code starts here > 11 Write code for the convert_kg(value) function that converts value into pounds and ounces. The function should output the following statement "x kg converted is y pounds and z ounces.". 12 13 if 14 15 name _main__": # Test your code here # convert_kg(10) # convert_pounds (10) # convert_ounces (10) 16 Write code for the convert_pounds (value) function that converts value into kg and ounces. The function should output the following statement "x pounds converted is y kg and z ounces.". 17 18 19 20 > Write code for the convert_ounces (value) function that converts value into kg and pounds. The function should output the following statement "x ounces converted is y kg and z pounds
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