Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

- 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

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

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions

Question

What is the message frequency?

Answered: 1 week ago

Question

What is the schedule for this project?

Answered: 1 week ago

Question

Who is responsible for this project?

Answered: 1 week ago