Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON Help Homework: File IO Step 1. Create a text file that is a series of numbers. Have multiple lines of data, with multiple numbers

PYTHON Help

Homework: File IO

Step 1.

Create a text file that is a series of numbers. Have multiple lines of data, with multiple numbers on each line.

Example:

345 435 345 435 334 34 34

12 12 34 56 12 45

1 34.4 1 234.1 0 0 3

0 0 1 3 4 5 1 2

123

Step 2:

Write a program that reads each line of data and displays the sum of each line.

Details:

Your program should, in general, follow these steps:

1.Ask the user for a filename

2.Open that file

a.For each line in the file

i.Convert it to a list of numbers

ii.Sum all the numbers in the list

iii.Print the total and the average of those numbers

3.Close the file

Make sure it ignores lines that begin with "#" or that have a length of zero. If the file does not exist dont crash. Just tell the user that it doesnt exist.

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

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions

Question

Evaluate the integral. dx x x2 + 1

Answered: 1 week ago

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago