Write a function get_parallelogram_area (base, height) which takes a base and height of a parallelogram as...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a function get_parallelogram_area (base, height) which takes a base and height of a parallelogram as parameters, and returns the area (i.e. base height) of the parallelogram rounded to the nearest integer. The parameters can be of any type. You should first try to convert the parameter into a float by using float (). If the parameter is a float or an integer or a string that represents a float, then the conversion will be successful. Otherwise, this will generate a TypeError (if the type of the parameter cannot be converted to a float) or a ValueError (if the type is valid but the value cannot be converted to a float). Your function should return a tuple. • The first item in the tuple should be the area of the parallelogram and the second item is an empty string if the values are valid, or The first item in the tuple is 0 and the second item is "ERROR: Not a Parallelogram" when a value is 0, or • The first item in the tuple is O and the second item is "ERROR: Invalid input" when a value is negative, or • The first item in the tuple is O and the second item should be a string that names the type of Exception that occurred when converting the value. For example: Test print (get_parallelogram_area(10.5, 2)) print(get_parallelogram_area(-10, -2)) print(get_parallelogram_area(10, 0)) Result (21, ) (0, 'ERROR: Invalid input') (0, 'ERROR: Not a Parallelogram') print (get_parallelogram_area('ten', 2)) (0, 'ValueError') print (get_parallelogram_area([1,2,3], 4)) (0, 'TypeError') Expected parallelogram_area(10.5, 2)) (21, ¹) parallelogram_area('10.5', -2)) (0, 'ERROR: Invalid input') barallelogram_area(-10, -2)) (0, 'ERROR: Invalid input') parallelogram_area(10, 0)) (0, 'ERROR: Not a Parallelogram') parallelogram_area('ten', 2)) (0, 'ValueError') barallelogram_area([1,2,3], 4)) (0, 'TypeError') Got (21, ¹) (0, 'ValueError') (0, 'ERROR: Invalid input') (0, 'ERROR: Not a Parallelogram") (0, 'ValueError') (0, 'TypeError') x Write a function get_parallelogram_area (base, height) which takes a base and height of a parallelogram as parameters, and returns the area (i.e. base height) of the parallelogram rounded to the nearest integer. The parameters can be of any type. You should first try to convert the parameter into a float by using float (). If the parameter is a float or an integer or a string that represents a float, then the conversion will be successful. Otherwise, this will generate a TypeError (if the type of the parameter cannot be converted to a float) or a ValueError (if the type is valid but the value cannot be converted to a float). Your function should return a tuple. • The first item in the tuple should be the area of the parallelogram and the second item is an empty string if the values are valid, or The first item in the tuple is 0 and the second item is "ERROR: Not a Parallelogram" when a value is 0, or • The first item in the tuple is O and the second item is "ERROR: Invalid input" when a value is negative, or • The first item in the tuple is O and the second item should be a string that names the type of Exception that occurred when converting the value. For example: Test print (get_parallelogram_area(10.5, 2)) print(get_parallelogram_area(-10, -2)) print(get_parallelogram_area(10, 0)) Result (21, ) (0, 'ERROR: Invalid input') (0, 'ERROR: Not a Parallelogram') print (get_parallelogram_area('ten', 2)) (0, 'ValueError') print (get_parallelogram_area([1,2,3], 4)) (0, 'TypeError') Expected parallelogram_area(10.5, 2)) (21, ¹) parallelogram_area('10.5', -2)) (0, 'ERROR: Invalid input') barallelogram_area(-10, -2)) (0, 'ERROR: Invalid input') parallelogram_area(10, 0)) (0, 'ERROR: Not a Parallelogram') parallelogram_area('ten', 2)) (0, 'ValueError') barallelogram_area([1,2,3], 4)) (0, 'TypeError') Got (21, ¹) (0, 'ValueError') (0, 'ERROR: Invalid input') (0, 'ERROR: Not a Parallelogram") (0, 'ValueError') (0, 'TypeError') x
Expert Answer:
Answer rating: 100% (QA)
The required code and test output are given below FUNCTION CODE def ge... View the full answer
Related Book For
Discovering Advanced Algebra An Investigative Approach
ISBN: 978-1559539845
1st edition
Authors: Jerald Murdock, Ellen Kamischke, Eric Kamischke
Posted Date:
Students also viewed these computer engineering questions
-
Multiple Choice Questions The following questions relate to determining sample size in tests of details of balances. For each one, select the best response. a. Mr. Murray decides to use stratified...
-
Debt-equity ratio is sub-part of A Short-term solvency ratio B C Long-term solvency ratio Debtors turnover ratio D None of the above
-
The questions below relate to determining the CUER in audit sampling for tests of controls, using the following table: Required a. Using nonstatistical sampling, calculate TER SER for each of columns...
-
What is control resolution in a robot positioning system?
-
You have a position open and are trying to hire a new person. Assume that the new persons experience will follow a normal distribution with the mean and (sample) standard deviation of your current...
-
Prony brake dynamometer is a type of: (a) Transmission dynamometer (b) Absorption dynamometer (c) Electrical dynamometer (d) None of these
-
Pier 1 Imports recently reported the following stockholders' equity (adapted and in millions except par value per share): Suppose Pier 1 split its common stock 2 for 1 in order to decrease the market...
-
Deleon Inc. is preparing its annual budgets for the year ending December 31, 2017. Accounting assistants furnish the data shown below. An accounting assistant has prepared the detailed manufacturing...
-
Do you believe no-knock warrants are consistent with the 4 th amendment? Why or why not?Explain
-
Defend the significance of LG considering the opinions of an executive jury when formulating the business's inventory management policy.
-
Assume that the City of Coyote has produced its financial statements for December 31, 2020, and the year then ended. The city's general fund was only used to monitor education and parks. Its capital...
-
A commercial interface unit uses different names for the handshake lines associated with the transfer of data from the I/O device into the interface unit. The interface input handshake line is...
-
A check for which the bank ensures that the drawer has suffi cient funds to make payment. a. bad c heck b. draft or bill of exchange c. cashiers c heck d. certifi ed check e. check f. drawee g....
-
A check that bears a date later than the date on which the check was written. a. bad c heck b. draft or bill of exchange c. cashiers c heck d. certifi ed check e. check f. drawee g. drawer h. holder...
-
An indorsement that transfers an instrument to whoever has possession of it. a. bearer ins trument b. blank indors ement c. counterclaim d. dishonorment e. holder in due course f. indorsee g....
-
Indicate whether each of the following statements is true or false by writing T or F i n t he a nswer c olumn. The purpose of transnational institutions is to maintain legal and economic order in...
-
The board of directors of Berweck Corporation declared a cash dividend on December 26, 2022, to be paid on February 18, 2023, to shareholders holding the stock on February 2, 2023. Given these facts,...
-
Determine whether the lines are parallel, perpendicular, or neither. 2x + 3y = -12, 2y - 3x = 8
-
With a specific line of fit, the data point (6, 47) has a residual of 2.8. The slope of the line of fit is 2.4. What is the equation of the line of fit?
-
Solve each system of equations algebraically, using the substitution or elimination method. a. b. c. y-x24 y-(x-2)2 + 3 3x2 +9y2-9 3x2 +52-8 4 x2 (y +4) 9
-
Find the value of 4a-d. a. a = log 13 b. b = 3.6a c. c = antilog b d. d = 133.6 e. Compare the values you found. Describe any relationship you see. f. Complete the statement "log ab = ? . g. This...
-
Explain the limitations that auditors face when they perform the attest function.
-
Indicate whether you think the following third-party groups would normally represent a (1) primary beneficiary, (2) foreseen party, or (3) foreseeable party. Give reasons for your answers. a. A...
-
Use and Dispose Company was organized to manufacture and sell inexpensive golf clubs that can be used during the golf round and then thrown away at the end of the round. In order to keep the business...
Study smarter with the SolutionInn App