22import getpass
33
44#root password is something you set when you install mysql on your system
5- #the default may be blank; I use python123 for testing
6- dbconn = my .connect (host = '127.0.0.1' ,port = 3306 ,user = 'root' , password = 'python123 ' , db = 'students' )
5+ #the default may be blank; I use python123 for testing (old server was root/python123)
6+ dbconn = my .connect (host = '127.0.0.1' ,port = 33067 ,user = 'root' , password = '' , db = 'students' )
77
88#print(dbconn)
99cursor = dbconn .cursor ()
3636dbconn .close ()
3737
3838#print(users)
39- print ("STUDENTS" )
40- print (students )
41- print ("FACULTY" )
42- print (faculty )
39+ # print("STUDENTS")
40+ # print(students)
41+ print ("FACULTY user account for testing: " )
42+ print (faculty [ 1 ][ 1 ], faculty [ 1 ][ 2 ] )
4343#print(users[1][1],users[1][2])
4444
4545#print(grades)
6262
6363#now define functions
6464def enterGrades ():
65- nameToEnter = input ('Student name: ' )
66- gradeToEnter = input ('Grade: ' )
67-
68- if nameToEnter in students [1 ]:
69- print ('Adding grade for' + nameToEnter )
70- students [nameToEnter ].append (float (gradeToEnter )) #float will have a .0
71- print (str (nameToEnter )+ ' now has these grades:' )
72- print (students [nameToEnter ])
73- else :
74- print ('Student not found. Please check your spelling or go back and add if new.' )
65+ listStudents ()
66+ thisStudentID = input ('Enter the student ID: ' )
67+ gradeToEnter = input ('Grade to enter (eg. 98.3): ' )
68+ studentIndex = int (thisStudentID )- 1
69+ print ('Adding grade for ' + students [studentIndex ][1 ])
70+ #students[studentIndex].append(float(gradeToEnter)) #float will have a .0
71+ print (students [studentIndex ][1 ]+ ' now has these grades:' )
72+
7573
7674def removeStudent ():
7775 nameToRemove = input ('Who do you want to remove? ' )
@@ -82,6 +80,13 @@ def removeStudent():
8280 else :
8381 print ('Student not found.' )
8482
83+ def listStudents ():
84+ for student in students :
85+ thisStudent = ""
86+ for item in student :
87+ thisStudent += str (item ) + " "
88+ print (thisStudent )
89+
8590def averageStudents ():
8691 for student in students :
8792 grades = students [student ]
@@ -133,6 +138,4 @@ def main():
133138 else :
134139 print ('Invalid password.' )
135140 else :
136- print ('User not found.' )
137- else :
138- print ('Invalid user. Check your spelling.' )
141+ print ('User not found.' )
0 commit comments