Question: # Write a Python program that reads the data from the file, calculates the average age of the people in the file, and writes the
# Write a Python program that reads the data from the file, calculates the average age of the people in the file, and writes the result to another file called output.txt
# Here are the requirements:
# If the data.txt file does not exist or cannot be opened, the program should catch the exception and print an error message to the console.
# If the data in the file is not in the correct format ie if there are missing fields or fields are not in the correct order the program should catch the exception and print an error message to the console.
# If the program is unable to calculate the average age eg if there are no people in the file the program should catch the exception and print an error message to the console.
# The output should be written to the output.txt file in the following format: "The average age is XX where XX is the average age rounded to the nearest integer.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
