Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1. (2 points) Joe wants to write a code to compute the perimeter of a rectangle. The following is his code which has four errors.

image text in transcribedimage text in transcribed

Q1. (2 points) Joe wants to write a code to compute the perimeter of a rectangle. The following is his code which has four errors. Fix the errors. In [ ]: def Rec_Perimeter(length, width) perimeter = 2 * (length + width) Return Rec_Perimeter call the function for a rectangle with length = 10 ft and width = 5 ft. Q2. (2 points) Write a function that counts the number of even numbers when a list of integer is passed in. Fill pieces of the following function. In [ ]: count_even_numbers (numbers): count = 0 for num in if % 2 count += Q3 (2 points) We want to write a function to find the harmonic mean. More detail can be found here: https://en.wikipedia.org/wiki/Harmonic mean Assume that we want to pass unknow number of arguments represented by vars to the function In (): "?' HarmonicMean('?' vars): #12 points x = '7' "?' var in '?': x += '?' return '?'/ # now we want to test the code for numbers from 1 to vars='?' (range (1,11)) # 1 point print (HarmonicMean('?'vars) ) 10 (included). Q4 (2 points) Write a function that will return the number of digits in an integer. In (): # write your code here: Q5. (2 points) Write a function sum_of_squares(xs) that computes the sum of the squares of the numbers in the list xs. For example, sum_of_squares([2. 3. 4) should return 4+9+16 which is 29. In ( )

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 10g Insider Solutions

Authors: Arun R. Kumar, John Kanagaraj, Richard Stroupe

1st Edition

0672327910, 978-0672327919

More Books

Students also viewed these Databases questions