Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is coding with python and I'm in the introductory course so make sure the module and function is not too complex.Thank u! Write a

This is coding with python and I'm in the introductory course so make sure the module and function is not too complex.Thank u!

Write a function sum_all that takes a file handle called handle_in as a parameter. The function reads through the file 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 along with their sum) to the output file output_q1.txt. Test your program with the sample file provided text_numbers.txt.

the sample file text_numbers.txt is

"I programed with C for 17 years, C++ for 10+ years, Java for 6 years and Python for 5 years. Through C is not an object oriented language , it's still my 1st preference"

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

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions