Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students also viewed these Databases questions

Question

Calculate Saponification Value of Fish Oil

Answered: 1 week ago