Question: 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.

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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!