Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 3.6 Write a program, addNums(ifile), which will take a file and return the sum of any positive numbers in the file. When the program

Python 3.6

Write a program, addNums(ifile), which will take a file and return the sum of any positive numbers in the file. When the program finds a non-numeric it will keep count of the number of non-numerics it finds in the file, continue to process the file and return a list consisting of the number of bad inputs followed by the sum of the numbers. Using a try/except, the program will return a [-1, 0] when there is a file not found error. You are required to use a try/except to check for any file not found and you are required to use a try/except as an error check for addition with a non-numeric character

image text in transcribed

smallMixed txt

a b c d e 100 199 10 22 fg hi jk lm no 99 88 77 66 55

mixedAlpha.txt

a z b y 1 26 2 25 c x d w 3 24 4 23 e v f u 5 22 6 21 g t h s 7 20 8 19 i r j q 9 18 10 17 k p l o 11 16 12 15 m n 13 14

addNurms ("smallMixed.txt") [10 716] add Nums mixed Alpha .txt") 26 351] addNums ("nosuch file.txt") I-1 01

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

Step: 3

blur-text-image

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

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions