
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
INCHES_TO_CM = 2.54
POUNDS_TO_KG = 0.453592
def inches_to_cm( inches ):
'''
Function -- inches_to_cm
Converts inches to centimeters and returns (answers) the resulting
value
Parameters:
inches (float) -- the original distance/height in inches
Returns a float value representing the original vaule converted
to centimeters
'''
return abs(inches * INCHES_TO_CM) # convert negative distance to positive
def cm_to_inches( centimeters ):
'''
Function -- cm_to_inches
Converts centimeters to inches and returns (answers) the resulting
value
Parameters:
centimeters (float) -- the original distance/height in centimeters
Returns a float value representing the original vaule converted
to inches
'''
return abs(centimeters * (1 / INCHES_TO_CM))
def pounds_to_kg( pounds ):
'''
Function -- pounds_to_kg
Converts pounds to kilograms and returns (answers) the resulting
value
Parameters:
pounds (float) -- the original weight in pounds
Returns a float value representing the original vaule converted
to kilograms
'''
return abs(pounds * POUNDS_TO_KG) # convert negative weight to positive
def kg_to_pounds( kg ):
'''
Function -- cm_to_inches
Converts kilograms to pounds and returns (answers) the resulting
POUNDS_TO_KG = 0.453592
def inches_to_cm( inches ):
'''
Function -- inches_to_cm
Converts inches to centimeters and returns (answers) the resulting
value
Parameters:
inches (float) -- the original distance/height in inches
Returns a float value representing the original vaule converted
to centimeters
'''
return abs(inches * INCHES_TO_CM) # convert negative distance to positive
def cm_to_inches( centimeters ):
'''
Function -- cm_to_inches
Converts centimeters to inches and returns (answers) the resulting
value
Parameters:
centimeters (float) -- the original distance/height in centimeters
Returns a float value representing the original vaule converted
to inches
'''
return abs(centimeters * (1 / INCHES_TO_CM))
def pounds_to_kg( pounds ):
'''
Function -- pounds_to_kg
Converts pounds to kilograms and returns (answers) the resulting
value
Parameters:
pounds (float) -- the original weight in pounds
Returns a float value representing the original vaule converted
to kilograms
'''
return abs(pounds * POUNDS_TO_KG) # convert negative weight to positive
def kg_to_pounds( kg ):
'''
Function -- cm_to_inches
Converts kilograms to pounds and returns (answers) the resulting
value
Parameters:
centimeters (float) -- the original weight in kilograms
Returns a float value representing the original vaule converted
to pounds
'''
return abs(kg * (1 / POUNDS_TO_KG))
Parameters:
centimeters (float) -- the original weight in kilograms
Returns a float value representing the original vaule converted
to pounds
'''
return abs(kg * (1 / POUNDS_TO_KG))
value
Parameters:
centimeters (float) -- the original weight in kilograms
Returns a float value representing the original vaule converted
to pounds
'''
Parameters:
centimeters (float) -- the original weight in kilograms
Returns a float value representing the original vaule converted
to pounds
'''

Transcribed Image Text:• Filename: test measurements.py
• Starter code: measurement_conversions.py
Using the starter code that includes two functions that convert between metric and imperial values for distance (inches <-> centimeters) and
weight (pounds <-> kilograms), your job is to test these functions. You should write a main () in test measurements.py; when we run it, we
should see all of your tests, the expected result for each one, and the actual result for each one.
You have flexibility with regards to your output since we won't be using the Gradescope autograder to examine your output text.
However, we will be manually inspecting your output, so be sure your output is readable and clean. Here's an example of part of our test suite
running (this is a small snippet, not the entire run):
*** Testing inches ->
cm conversions
Converting 0 inches to centimeters:
0.00 expected
>> result
= 0.00
%D
Converting 1 inches to centimeters:
2.54 еxpected
>> result
= 2.54
%3D
..etc.
*** Testing cm -> inches conversions
Converting 0 centimeters to inches:
>> result = 0.00 expected
0.00
Converting 38 centimeters to inches:
= 14.96
>> result
expected
14.96
..etc.
Structuring your code:
• You have little-to-no repeated code, because you've so wisely put anything that gets repeated into functions.
• We won't be using the auto-grader for this part of the assignment. To earn full credit for correctness, make sure your output is clean, clear
and easy to read for visual verification of results
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 3 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- H Step 6: Descriptive Statistics: Points Scored By Your Time in Home Games The management of your team wants you to run descriptive statistics on the points scored by your team in the games played at your team's venue i 2015. Calculate descriptive statistics including the mean, median, variance, and standard deviation for points scored by your team played at Home. following edits to the code block below: 1. Replace ??MEAN_FUNCTION?? with the name of Python function that calculates the mean. 2. Replace ??MEDIAN_FUNCTION?? with the name of Python function that calculates the median. 3. Replace ??VAR_FUNCTION?? with the name of Python function that calculates the variance. 4. Replace ??STD_FUNCTION?? with the name of Python function that calculates the standard deviation. After you are done with your edits, click the block of code below and hit the Run button above. print("Points Scored by Your Team in Home Games (2013 to 2015)") print(" ") your_team_home_df =…arrow_forwardJupyter Notebook Fixed Income - Certicificate of Deposit (CD) - Compound Interest Schedule An interest-at-maturity CD earns interest at a compounding frequency, and pays principal plus all earned interest at maturity. Write a function, called CompoundInterestSchedule, that creates and returns a pandas DataFrame, where each row has: time (in years, an integer starting at 1), starting balance, interest earned, and ending balance, for an investment earning compoundedinterest. Use a for(or while) loop to create this table. The equation for theith year's ending balance is given by: Ei =Bi (1+r/f)f where: Ei is year i's ending balance Bi is year i's beginning balance (note: B1 is the amount of the initial investment (principal) r is the annual rate of interest (in decimal, e.g., 5% is .05) f is the number of times the interest rate compounds (times per year) The interest earned for a given year is Ei - Bi Note the term of the investment (in years) is not in the above equation; it is used…arrow_forwardI'm trying to create a function to count the mortgage CREATE FUNCTION yen_11_monthlyPayment(mortage_amount numeric,apr numeric,years integer) RETURNS numeric language plpgsql AS $$ begin RETURN power(mortage_amount *(apr / 12) * (1+(apr / 12),years * 12)/ ((1+(apr / 12), years * 12) - 1)); END; $$ but when I'm trying to put the numberselect yen_11_monthlyPayment(250000.00, 0.04125, 30);and it doesn't workarrow_forward
- Consider the following code. How many times is the function rec func 3( ) called in total? def rec_func_3(n): if n < 0: return 1 if n < 3: return 1 return rec_func_3(n 15) rec_func 3(40)arrow_forwardCreate a function func_1.m to analyze the following function: The function needs to ask for x and plot the y(x). Select the range of x y=2*x.^2.*cos(x)./exp(0.1*x);arrow_forwardRefactor the following code using the concept of functions. a = 2 b = 3 C= 4 d = 5 a = 2 b = 3 C= 4 d = 5arrow_forward
- Write the function data_tuple_from_line(line_str) that takes a line of input (with value separated by commas) and returns a tuple containing install_id, install_date, size, cost, subsidy, zip code, city, state. In the result tuple: The install_id, install_date, zip code, city, and state should all be strings. The size, cost, and subsidy should all be floats. The city should be in title case.arrow_forwardLanguage is C, please code according to parameters, answer as simply as possible, need ASAP. Thank you! Write two functions, total_product and total_sum. Both functions return an integer. Total_product function takes in a 2D array of integers along with an integer with the number of rows and columns. This function will return an integer with the product of the sum of the rows. See example for details. The total_sum function takes in an array of integers with the size of the array. The total_sum function will find the sum of the 1D array. You must call the total_sum function in the total_product to receive full credit. Example: row/column 0 1 2 3 total_sum(row) Result 0 1 2 3 4 10 1 5 6 7 8 26 Given this 2D array above, the answer for total_product would be 260. Because row one adds up to be 10, and row two adds up to be 26. We multiple this together to get total product.arrow_forward*Part A and B important. The functions are just examples. A. Write a function called getDimension() that asks the user inputs for the dimensions that consists of twovalues: row and column, then return it to the mainline (also known as global scope) of the program. Therange of the dimensions that the user can input is from 4 to 10 for both rows and columns Please referto the gameplay sample. B. Next, use a 2-dimensional list to represent the game board, where each cell can be either empty(represented by a space " "), a token belonging to human (represented by "X"), or a token belonging tocomputer (represented by "O") as shown in Table 1. Write a function called printBoard(board) thattakes a 2-dimensional list representing the game board and prints it to the console functions: 1) dropToken (board, col, token): takes a 2-dimensional list representing the game board, acolumn number, and a token (either "X" or "O") and returns the row number of the placed token.This function places the…arrow_forward
- Write a function named max_year that, given one parameter of origin ( value in OdName), returns the year with the maximum immigrants.arrow_forwardDefine Functions fill and fill_n.arrow_forwardJS Write a function named sum_between_indices whose parameter is a list/array of decimal numbers. Your function must return the sum of the entries at index 4 through index 15. Make certain to include the entries at index 4 and at index 15 in your sum. You SHOULD assume the parameter will have more than 15 entries.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education