subject

In this assignment, you will revisit reading data from a file, and use that data as arguments (parameters) for a number of functions you will write. You will need to:Write and test a function square_each(nums)Where nums is a (Python) list of numbers. It modifies the list nums by squaring each entry and replacing its original value. You must modify the parameter, return will not be allowed!Write and test a function sum_list(nums)Where nums is a (Python) list of numbers. It returns the sum of the numbers in passed-in the list. Write and test a function to_numbers(str_list)Where str_list is a list of strings, each of which represents a number. Modify each entry in the list by converting it to a number. You can choose to use return the list, or just modify str_list in-place, similar to #1, above. Write and test a function main()Take the previous three functions and construct a main() function that will call these functions properly. The program computes the sum of the squares of numbers read from a file. Your program should prompt for a file name and print out the sum of the squares of the values in the file. Hint: use readlines()You may download two example files of numbers to read in, numbers (space seperated)or numbers (comma seperated). You may choose to read in numbers in another format of your choosing, http://www. pas. rochester. edu/~rsarkis/csc161/_static/misc/nu mbers. txt, and http://www. pas. rochester. edu/~rsarkis/csc161/_static/misc/nu mbers_csv. txt so long as you choose one method and document it in your program comments. OutputThis example parses the numbers_csv. txt file. The result should be the same regardless of which input data was used. This program computes the sum of the squares of numbers read from a file. Please enter the file name: numbers_csv. txtThe sum of the squares of the numbers in the file is 32932.0

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 20:00, bowmanari2154
What is used to analyze and summarize your data without graphical support
Answers: 1
image
Computers and Technology, 23.06.2019 05:00, bellad0124outlookcom
In cell b18, enter a formula to calculate the amount budgeted for meals. this amount is based on the daily meal allowance and the total travel days (# of nights+1).
Answers: 1
image
Computers and Technology, 23.06.2019 12:00, daelinrobinson
If you're using an existing powerpoint presentation that will receive new slides based on a word outline, select the a. slide that will appear after the new slides. b. first slide in the presentation. c. slide that will appear before the new slides. d. last slide in the presentation.
Answers: 2
image
Computers and Technology, 24.06.2019 01:30, kevin72836
Hazel has just finished adding pictures to her holiday newsletter. she decides to crop an image. what is cropping an image?
Answers: 1
You know the right answer?
In this assignment, you will revisit reading data from a file, and use that data as arguments (param...

Questions in other subjects:

Konu
Mathematics, 02.09.2019 10:00
Konu
English, 02.09.2019 10:00