0% found this document useful (0 votes)
6 views30 pages

Project

The document outlines a Python program for managing student records, including functionalities for adding, viewing, updating, and deleting student information. It features user authentication and calculates minimum, maximum, and average marks for each student. The program is menu-driven and allows for easy interaction with the student data.

Uploaded by

shriaditrigaur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views30 pages

Project

The document outlines a Python program for managing student records, including functionalities for adding, viewing, updating, and deleting student information. It features user authentication and calculates minimum, maximum, and average marks for each student. The program is menu-driven and allows for easy interaction with the student data.

Uploaded by

shriaditrigaur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 30

STRING

1.

2.
3.

4.
5.

6.
LIST
1.

2.
3.
5.

6.
7.

8.
Tuples
1.

2.

3.
4.

5.
6.

7.
8.
Dictionary
1.

2.
3.

4.
5.

6.
Modules
1.

2.

3.

4.
5.
Project Work

Topic: Annual Examination Result


Code:
import random

# ID and password for authentication


users = {
"admin": "password123",
"teacher": "teacherpass"
}

#dictionary with Admission No as the key


students = {}
def display_students():
print("\n----- Student Records -----")
print("ID\tName\t\tMin Marks\tMax Marks\tAvg Marks")
print("------------------------------------------------------------")
for admission_no, record in students.items():
min_marks = min(record['marks'])
max_marks = max(record['marks'])
avg_marks = sum(record['marks']) / len(record['marks'])
print(str(admission_no) + "\t" + record['name'] + "\t" + str(min_marks) + "\t\t" +
str(max_marks) + "\t\t" + str(round(avg_marks, 2)))
#if user is authorized
def authenticate():
user_id = input("Enter ID: ")
password = input("Enter Password: ")
#ID and password
if users.get(user_id) == password:
print("Welcome " + user_id + "!")
return True
else:
print("Invalid authorization!")
return False
# Main program
def main():
authorized = False
while not authorized:
authorized = authenticate()
while True:
# menu driven program
print("\n===== Student Record System =====")
print("1. Add Student Record")
print("2. View All Student Records")
print("3. Update Student Record")
print("4. Delete Student Record")
print("5. Find Student by Admission Number")
print("6. Exit")
choice = input("Enter your choice: ")
# to add a new student
if choice == "1":
name = input("Enter Student Name: ")
admission_no = random.randint(1000, 9999)
subjects = ["Math", "Physics", "Chemistry", "English", "Computer Science"]
marks = []
for subject in subjects:
while True:
mark = input("Enter marks in " + subject + ": ")
if mark.isdigit() and 0 <= int(mark) <= 100:
marks.append(int(mark))
break
else:
print("Invalid marks! Please enter a valid number between 0 and 100.")
# Store the student details in the dictionary using admission number as the key
students[admission_no] = {"name": name, "marks": marks}
print("Student record added successfully with Admission No: " + str(admission_no))
continue

# to view all student records


elif choice == "2":
display_students()
continue

# to update a student record


elif choice == "3":
admission_no = int(input("Enter Admission Number to update: "))
if admission_no in students:
name = input("Enter new name: ")
marks = []
for subject in ["Math", "Physics", "Chemistry", "English", "Computer Science"]:
while True:
mark = input("Enter new marks in " + subject + ": ")

# Check if the marks are valid


if mark.isdigit() and 0 <= int(mark) <= 100:
marks.append(int(mark))
break
else:
print("Invalid marks! Please enter a valid number between 0 and 100.")
students[admission_no] = {"name": name, "marks": marks}
print("Record updated successfully for Admission No: " + str(admission_no))
else:
print("Student with this Admission Number not found!")
continue

# to delete a student's record


elif choice == "4":
admission_no = int(input("Enter Admission Number to delete: "))
if admission_no in students:
del students[admission_no]
print("Record deleted successfully for Admission No: " + str(admission_no))
else:
print("Student with this Admission Number not found!")
elif choice == "5":
admission_no = int(input("Enter Admission Number to find: "))
if admission_no in students:
student = students[admission_no]
min_marks = min(student['marks'])
max_marks = max(student['marks'])
avg_marks = sum(student['marks']) / len(student['marks'])

# Display the student details


print("\n----- Student Details -----")
print("Admission Number: " + str(admission_no))
print("Name: " + student['name'])
print("Marks: " + ', '.join(map(str, student['marks'])))
print("Min Marks: " + str(min_marks))
print("Max Marks: " + str(max_marks))
print("Average Marks: " + str(round(avg_marks, 2)))
else:
print("Student with this Admission Number not found!")
continue

#to exit the program


elif choice == "6":
print("Exiting... Thank you!")
break
else:
print("Invalid choice! Please try again.")

# Run the program


main()

Output:
Enter ID: admin
Enter Password: password123
Welcome admin!

===== Student Record System =====


1. Add Student Record
2. View All Student Records
3. Update Student Record
4. Delete Student Record
5. Find Student by Admission Number
6. Exit
Enter your choice: 1
Enter Student Name: Aditri
Enter marks in Math: 77
Enter marks in Physics: 67
Enter marks in Chemistry: 68
Enter marks in English: 75
Enter marks in Computer Science: 79
Student record added successfully with Admission No: 6656

===== Student Record System =====


1. Add Student Record
2. View All Student Records
3. Update Student Record
4. Delete Student Record
5. Find Student by Admission Number
6. Exit
Enter your choice: 1
Enter Student Name: Nabiya
Enter marks in Math: 78
Enter marks in Physics: 65
Enter marks in Chemistry: 68
Enter marks in English: 67
Enter marks in Computer Science: 79
Student record added successfully with Admission No: 9277

===== Student Record System =====


1. Add Student Record
2. View All Student Records
3. Update Student Record
4. Delete Student Record
5. Find Student by Admission Number
6. Exit
Enter your choice: 1
Enter Student Name: Aashi
Enter marks in Math: 74
Enter marks in Physics: 63
Enter marks in Chemistry: 64
Enter marks in English: 72
Enter marks in Computer Science: 69
Student record added successfully with Admission No: 3080

===== Student Record System =====


1. Add Student Record
2. View All Student Records
3. Update Student Record
4. Delete Student Record
5. Find Student by Admission Number
6. Exit
Enter your choice: 2

----- Student Records -----


ID Name Min Marks Max Marks Avg Marks
------------------------------------------------------------
6656 Aditri 67 79 73.2
9277 Nabiya 65 79 71.4
3080 Aashi 63 74 68.4

===== Student Record System =====


1. Add Student Record
2. View All Student Records
3. Update Student Record
4. Delete Student Record
5. Find Student by Admission Number
6. Exit
Enter your choice: 3
Enter Admission Number to update: 9277
Enter new name: Nabiya
Enter new marks in Math: 78
Enter new marks in Physics: 68
Enter new marks in Chemistry: 67
Enter new marks in English: 74
Enter new marks in Computer Science: 65
Record updated successfully for Admission No: 9277
===== Student Record System =====
1. Add Student Record
2. View All Student Records
3. Update Student Record
4. Delete Student Record
5. Find Student by Admission Number
6. Exit
Enter your choice: 2

----- Student Records -----


ID Name Min Marks Max Marks Avg Marks
------------------------------------------------------------
6656 Aditri 67 79 73.2
9277 Nabiya 65 78 70.4
3080 Aashi 63 74 68.4

===== Student Record System =====


1. Add Student Record
2. View All Student Records
3. Update Student Record
4. Delete Student Record
5. Find Student by Admission Number
6. Exit
Enter your choice: 4
Enter Admission Number to delete: 3080
Record deleted successfully for Admission No: 3080

===== Student Record System =====


1. Add Student Record
2. View All Student Records
3. Update Student Record
4. Delete Student Record
5. Find Student by Admission Number
6. Exit
Enter your choice: 2

----- Student Records -----


ID Name Min Marks Max Marks Avg Marks
------------------------------------------------------------
6656 Aditri 67 79 73.2
9277 Nabiya 65 78 70.4

===== Student Record System =====


1. Add Student Record
2. View All Student Records
3. Update Student Record
4. Delete Student Record
5. Find Student by Admission Number
6. Exit
Enter your choice: 5
Enter Admission Number to find: 6656

----- Student Details -----


Admission Number: 6656
Name: Aditri
Marks: 77, 67, 68, 75, 79
Min Marks: 67
Max Marks: 79
Average Marks: 73.2

===== Student Record System =====


1. Add Student Record
2. View All Student Records
3. Update Student Record
4. Delete Student Record
5. Find Student by Admission Number
6. Exit
Enter your choice: 6
Exiting... Thank you!

You might also like