




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
This python script provides functions to create, update, delete, and display student records along with calculating percentages and plotting marks distribution in the form of a bar chart. It uses a dictionary to store student records and matplotlib library for graph visualization.
Typology: Study notes
1 / 8
This page cannot be seen from the preview
Don't miss anything!
#Student Marks Management import matplotlib.pyplot as plt
students = {} def create_student_record(name, rollno, maths, hindi, english, computer, science, sst): students[rollno] = { 'name': name, 'maths': maths, 'hindi': hindi, 'english': english, 'computer': computer, 'science': science, 'sst': sst } print("Student record successfully saved.")
def get_all_student_records(): return students def calculate_percentage(record): total_marks = sum([record['maths'], record['hindi'], record['english'], record['computer'], record['science'], record['sst']]) percentage = (total_marks / 600) * 100 return percentage def plot_student_graph(rollno): if rollno in students: record = students[rollno] percentages = [record['maths'], record['hindi'], record['english'], record['computer'], record['science'], record['sst']] subjects = ['Maths', 'Hindi', 'English', 'Computer', 'Science', 'SST']
def delete_student_record(rollno): if rollno in students: del students[rollno] print(f"Student with Roll No {rollno} deleted successfully.") else: print(f"Student with Roll No {rollno} not found.") def display_student_marks(rollno): if rollno in students: record = students[rollno] print(f"Student Name: {record['name']}") print(f"Roll No: {rollno}") print("Subject-wise Marks:") for subject, marks in record.items(): if subject not in ['name']: print(f"{subject}: {marks}") else: print(f"Student with Roll No {rollno} not found.")
def main(): while True: print("\nMenu:") print("1. Enter student details") print("2. Calculate percentage") print("3. Plot student graph") print("4. Update student marks") print("5. Delete student record") print("6. Display student marks") print("7. Close program") choice = input("Enter your choice: ") if choice == '1': name = input("Enter the name of the student: ") rollno = int(input("Enter the roll number of the student: ")) maths = float(input("Enter the marks for Maths: "))
print(f"{record['name']} (Roll No: {rollno}): {percentage:.2f}%") elif choice == '3': rollno = int(input("Enter the roll number of the student to plot the graph: ")) plot_student_graph(rollno) elif choice == '4': rollno = int (input("Enter the roll number of the student whose marks you want to update: ")) subject = input ("Enter the subject (maths/hindi/english/computer/science/sst): ").lower() new_marks = float(input(f"Enter the new marks for {subject}: ")) update_student_marks(rollno, subject, new_marks) elif choice == '5': rollno = int(input("Enter the roll number of the student whose record you want to delete: ")) delete_student_record(rollno) elif choice == '6':
rollno = int(input("Enter the roll number of the student to display marks: ")) display_student_marks(rollno) elif choice == '7': print ("Closing the program. Goodbye!") break else: print("Invalid choice. Please enter a valid option.") if name == "main": main()