Question: Write a program that includes the following three functions. (Refer to exercises 11, 12, 13, and 14 of Chapter 6.) Functions squareEach(nums) In this function,

Write a program that includes the following three functions. (Refer to exercises 11, 12, 13, and 14 of Chapter 6.)

Functions

squareEach(nums)

In this function, nums is a list of numbers. It modifies the list by squaring each entry.

sumList(nums)

In this function, nums is a list of numbers. It returns the sum of numbers in the list.

toNumbers(strList)

In this function, strList is a list of strings, each of which represents a number. It modifies each entry in the list by converting it to a number.

Use the functions above to implement a program that computes the sum of the squares of numbers read from the file.

You should create and save a file with one line and a list of numbers, each separated by a space.

An example would be a file with the following contents: 13 34 14 53 56 76.

Your program should prompt for a file name (the name you used when you saved the file) and print or display the sum of the squares of the values in the file.

Hint: use readlines().

Please Note: This is based on Chapter 6 from Python Intro by John Zelle, 2nd Edition.

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!