Store Student Data

Store Student Data

Wood Crust International School conducts a talent search test for the middle schools students.  The management wants to store students’ names and their scores in the test in a file for their future references.  You are asked to write a Python program to read names and scores of the participants and to store them in a file. Use simple write() to accomplish this task.

Note: File name should be “output_data.txt”

Sample Input:

Enter number of students: 3

For student1

Enter name: Harshika

Enter the score: 98

For student2

Enter name: Laya

Enter the score: 99

For student3

Enter name: Johan

Enter the score: 100output_data.txt will contain:

Name: Harshika Score: 98
Name: Laya Score: 99
Name: Johan Score: 100

Code :-

n=int(input("Enter number of students: "))
file=open('output_data.txt','w')
for i in range(1,n+1):
    print("Student"+str(i))
    name=input("Enter name: ")
    score=input("Enter the score: ")
    line="Name: "+name+" "+"Score: "+score
    file.write(line+"\n")
file.close()

1 thought on “Store Student Data”

  1. This is the right website for anyone who wants to find out about this topic.
    You understand a whole lot its almost hard to argue with you (not that I actually will
    need to…HaHa). You definitely put a new spin on a topic that’s been written about for a long time.

    Excellent stuff, just wonderful!

Leave a Comment

Your email address will not be published. Required fields are marked *

x