73.1k views
0 votes
Write a program to create a data file "ADD.DAT" to store name, class, and marks in 5 subjects of 20 different students.

User Rretzbach
by
7.9k points

1 Answer

2 votes

Final answer:

To create the 'ADD.DAT' file to store data for 20 different students, you can write a program in a programming language like Python. The program prompts you to enter the name, class, and marks for each student and stores them in the file in a comma-separated format.

Step-by-step explanation:

To create the 'ADD.DAT' file to store data for 20 different students, you can write a program in a programming language like Python. Below is an example of how you can accomplish this:

# Open the file in write mode
with open('ADD.DAT', 'w') as file:
# Iterate over 20 students
for i in range(20):
# Get student's name, class, and marks in 5 subjects
name = input('Enter student name: ')
class_name = input('Enter student class: ')
marks = []
for j in range(5):
marks.append(int(input(f'Enter marks in subject {j+1}: ')))
# Write the data to the file
file.write(f'{name},{class_name},{','.join(map(str, marks))}\\')

This program prompts you to enter the name, class, and marks for each student and stores them in the 'ADD.DAT' file in a comma-separated format.

User Dmitreyg
by
8.1k points