Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN PYTHON (Class Average: Reading Student Records from a txt File). read the grades.txt file from the previous exercise. Display the data in tabular format.

IN PYTHON

(Class Average: Reading Student Records from a txt File). read the grades.txt file from the previous exercise. Display the data in tabular format.

previous exercise:

"""store a student name and their grades in three subject in a file"""

import os

try: # open a file with name grads with open("grades.txt", "w") as file: while True: # input student name first_name = input("Enter student's first name (or 'q' to quit): ") if first_name == 'q': break last_name = input("Enter student's last name: ") #input student grades try: test1 = int(input("Enter student's test 1 grade: ")) test2 = int(input("Enter student's test 2 grade: ")) test3 = int(input("Enter student's test 3 grade: ")) #remove error except ValueError: print("Invalid input. Please enter a numerical grade.") continue # Write student name and grade to file file.write(f"{first_name},{last_name},{test1},{test2},{test3} ")

except FileNotFoundError: print("File not found. Please check the file path and try again.") except: print("An error occurred. Please try again.")

(please without the pretty table method and show output as well

)

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

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