Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python Please!!! Write a program that receives a filename as user input. The file is structured as multiple lines containing numbers separated by a single
Python Please!!!
Write a program that receives a filename as user input. The file is structured as multiple lines containing numbers separated by a single space. For example, this would be an acceptable file: 1 2 3 7 Your program should open this file and: 1. print all its contents; 2. write the average of all numbers to a new file called result.txt. IMPORTANT NOTES: you should round the average down (should be an integer); you can assume there will be no empty lines; there might be any arbitrary number lines in the file; . there might be any arbitrary number of elements in a single line. Example 1: If input is: filel.txt and the contents of file1.txt are 1 2 you should first print the content, and then write 1 to result.txt. Note that the average of (1+2+2) is 1.6666, and you should round it down to 1 before writing to result.txt. Example 2: If input is: file2.txt and the contents of file2.txt are 1 2 3 5 1 you should first print the content, and then write 2 to result.txt. Note that the average of (1+2+3+4+5+1) is 2.6666, and you should round it down to 2 before writing to result.txt. 296528.7655254.qx3zyy LAB ACTIVITY 13.88.1: File Average (Files) 0/11 Downloadable files file2.txt filel.txt Download main.py 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started