Write a program to write data into binary file marks.dat anddisplay the records of students who scored more than 95marks.
Question
Write a program to write data into binary file marks.dat
and display the records of students who scored more than 95 marks.
Solution
Sure, here is a step-by-step guide to write a program that writes data into a binary file marks.dat and displays the records of students who scored more than 95 marks:
-
Import the necessary libraries or modules for file handling and data manipulation.
-
Define a class or structure to represent a student record. This class should have attributes such as name, roll number, and marks.
-
Create a list or array to store multiple student records.
-
Prompt the user to enter the number of student records they want to input.
-
Use a loop to iterate over the number of student records and prompt the user to enter the details for each student (name, roll number, and marks). Store these details in the student record object and add it to the list of student records.
-
Open the marks.dat file in binary write mode using the appropriate file handling function or method.
-
Iterate over the list of student records and write each record to the binary file using the appropriate file handling function or method. Make sure to convert the data into a binary format before writing.
-
Close the marks.dat file.
-
Reopen the marks.dat file in binary read mode.
-
Iterate over the records in the binary file and read each record. Convert the binary data back into the appropriate data format and check if the student's marks are greater than 95.
-
If the marks are greater than 95, display the student's details (name, roll number, and marks).
-
Close the marks.dat file.
That's it! You have now written a program that writes data into a binary file and displays the records of students who scored more than 95 marks.
Similar Questions
.Write a Python program to store marks scored in subject “Fundamental of DataStructure” by N students in the class and perform different operations.
Java Program To Accept the Marks of a Student and Find the Total Marks and Percentage
Write a program that displays the total students in each section.For example:Input ResultStudents.csvSectionA 2B 2C 3Name: StudentName, dtype: int64
Enter the student details using constructors with arguments. Then find the total marks of each student. If it is greater than 500 print pass ,else print fail.
If a student offered 12 subjects and the student's cumulative score is 1085. Write a program in python to show the student's average score.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.