Start a new Python script and write some suitable input commands to store three items of data into three variables: Student Name, Coursework Mark, and Exam Mark. The inputs for coursework mark and exam mark should be validated as a value in the range 0-100%.
- Add new student records
- Show all student records
- Delete a student record
- Dislay overall average coursework mark
- Display overall average exam mark
- Display all aggregate marks
- Display overall average aggregate mark
- Exit
I need to delete student records and a student name from the list but dont know how to this in this situation. Does anyone know how to solve this?
This is my method to solve the problem, but I don't know how to manage problem.
studentlist=[]
menu=1
while menu!=0:
print ("""
1. Add new student records
2. Show all student records
3. Delete a student record
4. Dislay overall average coursework mark
5. Display overall average exam mark
6. Display all aggregate marks
7. Display overall average aggregate mark
0. Exit
Plese select an option
""")
menu=int(input(""))
if menu==1:
promptdict1 = {'name': 'Enter a students name: ', \
'cmark': 'Enter the students coursework mark: ', \
'emark': 'Enter the students exam mark: '}
studentlist.append({'name': input(promptdict1['name']), \
'cmark': int(input(promptdict1['cmark'])), \
'emark': int(input(promptdict1['emark']))})
print(studentlist[-1])
elif menu==2:
promptdict2 = {'name': 'Name:', \
'cmark': 'Courswork mark:', \
'emark': 'Exam mark:'}
for student in studentlist:
print(promptdict2['name'], student['name'])
print(promptdict2['cmark'], student['cmark'])
print(promptdict2['emark'], student['emark'], '\n')
elif menu==3:
name=input("Enter a students name: ")
for n in studentlist:
if n['name']==name:
studentlist.remove(n)
elif menu==4:
total=0
total_students=len(studentlist)
for n in studentlist:
total+=n['cmark']
print("Overall average coursework mark: "+str(total/total_students))
elif menu==5:
total=0
total_students2=len(studentlist)
for n in studentlist:
total+=n['emark']
print("Overall average Exam mark: "+str(total/total_students2))
elif menu==0:
break