-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
99 lines (76 loc) · 3.63 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
def main():
user_id = input("Enter student's ID: ")
test1 = float(input("Enter student's test1 score: "))
test2 = float(input("Enter student's test2 score: "))
test3 = float(input("Enter student's test3 score: "))
interim_test = float(input("Enter student's IA score: "))
exam_score = float(input("Enter student's exam score: "))
student_details = { user_id: {
"test1": test1,
"test2": test2,
"test3": test3,
"interim_test": interim_test,
"exam_score": exam_score
}}
with open("Student-details.txt", "w") as file:
file.write(f"\n Student_ID: {user_id}\n Test1_score: {test1}\n Test2_score: {test2}\n Test3_score: {test3}\n Interim_test_score: {interim_test}\n Exam_score: {exam_score}\n")
def add_student_details():
user_id = input("Enter student's ID: ")
test1 = float(input("Enter student's test1 score: "))
test2 = float(input("Enter student's test2 score: "))
test3 = float(input("Enter student's test3 score: "))
interim_test = float(input("Enter student's IA score: "))
exam_score = float(input("Enter student's exam score: "))
student_details.update({user_id: {
"test1": test1,
"tes2": test2,
"test3": test3,
"interim_test": interim_test,
"exam_score": exam_score
}})
with open("Student-details.txt", "a") as file:
file.write(f"\n Student_ID: {user_id}\n Test1_score: {test1}\n Test2_score: {test2}\n Test3_score: {test3}\n Interim_test_score: {interim_test}\n Exam_score: {exam_score}\n")
def read_details():
with open("Student-details.txt", "r") as file:
data = file.read().splitlines()
for line in data:
print(line)
print("\n")
def search_student_score():
id = input('Enter target student ID: ')
if id in student_details:
for key, value in student_details[id].items():
print(key," : ", value)
def update_student_details():
user_id= input('Enter target student ID: ')
if user_id in student_details:
test1=float(input("Enter test one score: "))
test2=float(input("Enter test two score: "))
test3=float(input("Enter test three score: "))
interim_test=float(input("Enter IA score: "))
exam_score=float(input("Enter examination score: "))
with open("Student-details.txt", "w") as file:
file.write(f"\n Student_ID: {user_id}\n Test1_score: {test1}\n Test2_score: {test2}\n Test3_score: {test3}\n Interim_test_score: {interim_test}\n Exam_score: {exam_score}\n")
def options():
print("1: View all students details \n2: Add the details of a student \n3: Add a new book to the database \n4: Update student details\n5: Close program")
opt = int(input("Choose your option: "))
while opt != 5:
if opt == 1:
read_details()
return options()
elif opt == 2:
add_student_details()
return options()
elif opt == 3:
search_student_score()
return options()
elif opt == 4:
update_student_details()
return options()
elif opt == 5:
break
else:
print("Invalid Input \nEnter 1-4")
return options()
options()
main()