Question: - Python Write some code that will do the following: Read the data from StudentNames.txt Prompt the user to enter each students test grade Write

- Python

Write some code that will do the following:

Read the data from StudentNames.txt

Prompt the user to enter each students test grade

Write the students names and their grades to StudentsAndGrades.txt

Example program run:

Please enter the grade for Harry Potter: 89

Please enter the grade for Ron Weasley: 76

Please enter the grade for Hermione Granger: 94

Please enter the grade for Draco Malfoy: 82

Please enter the grade for Neville Longbottom: 90

Please enter the grade for Luna Lovegood: 92

Example data in StudentsAndGrades.txt:

Harry Potter, 89

Ron Weasley, 76 ...

* This is What I have done but receive error message...

def main(): student_name=open('StudentNames.txt', 'r') student_grade=open('StudentsAndGrades.txt', 'w') for students in student_name: grade=int(input('Please enter the grade for ', student_name, ': ', sep='')) student_grade.write(student_name + ',' + grade + ' ') student_name.close() student_grade.close()

main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!