Question: python 3.1-3.5 Write a function sum_all that takes a file handle as a parameter. The function reads through a file of text and returns a

python 3.1-3.5

Write a function sum_all that takes a file handle as a parameter. The function reads through a file of text and returns a list of the numbers encountered and their sum. Digits that occur within words should be ignored. For example, for the text in the file "If I were 21 instead of 53 I'd probably punch you in the nose a 2nd time" should return a list of the numbers encountered 21 and 53, along with their sum 74. You need to only deal with numbers that are surrounded by spaces. Save the function in a PyDev library module named a9_functions.py

Write a program q1.py that test sum_all function and prints/writes the returned values (the list of number returned and with their sum) to the output file output_q1.txt.

10 20 30 40 50 60 90 80 70 11 22 13 14 14 14

Write a function sum_all that takes a file handle as a parameter. The function reads through a file of text and returns a list of the numbers encountered and their sum. Digits that occur within words should be ignored. For example, for the text in the file "If I were 21 instead of 53 I'd probably punch you in the nose a 2nd time" should return a list of the numbers encountered 21 and 53, along with their sum 74. You need to only deal with numbers that are surrounded by spaces. Save the function in a PyDev library module named a9_functions.py

Write a program q1.py that test sum_all function and prints/writes the returned values (the list of number returned and with their sum) to the output file output_q1.txt.

10 20 30 40 50 60 90 80 70 11 22 13 14 14 14

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!