Question: The following pertains to python programming. 1) Write a function, sum_sqr_list(l) that performs the following tasks. This function receives a list l as an argument.

The following pertains to python programming.

1) Write a function, sum_sqr_list(l) that performs the following tasks.

  • This function receives a list l as an argument.

  • It returns a list of two values: One is the sum of all values in the list, and the other is the sum of squares of all values.

  • At the top of the function, it checks if the argument is a list. If it is not a list, it prints error "Error: The argument is not a list."

  • If the argument is a list, it calculates the sum of all values in the list and the sum of squares of all values in the list.

  • It returns a list with two values: sum and sum of sequares. If the argument was not a list, it returns [0, 0].

a) # Complete the following function below TO ANSWER. please ONLY WRITE THE CODE NECESSARY. # DO NOT CHANGE THE FUNCTION NAME AND ARGUMENTS! def sum_sqr_list(l): if type(l) != type(list()) else: return [ , ]

-----

# The following code is provided, You can modify it as you want, to test your function. l = {1, 2, 3, 4, 5} a = sum_sqr_list(l) print(a) l = [1, 2, 3, 4, 5] a = sum_sqr_list(l) print(a)

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!