Advertisement
Guest User

Untitled

a guest
Dec 9th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. import statistics
  2. admin = {"admin":"ninja"}
  3.  
  4. studentDict = {'Jeff':[78,88,83],
  5. 'Alex':[42,76,88],
  6. 'Sam':[89,92,93]}
  7. def enterGrades():
  8. nametoEnter = input("Student Name : ")
  9. gradetoEnter = input("Grade : ")
  10.  
  11. if nametoEnter in studentDict:
  12. print("Adding Grade...")
  13. studentDict[nametoEnter] = (int(gradetoEnter))
  14. else:
  15. print("Student does not exist.")
  16.  
  17. def removeStudent():
  18. studentToRemove = input("What student would you like to delete?")
  19. if studentToRemove in studentDict:
  20. del studentDict[studentToRemove]
  21. print("removeing student")
  22. else:
  23. print("we did not find that student")
  24. def studentAverage():
  25. peeraverage = input("What is the student you want to check?")
  26. if peeraverage in studentDict:
  27. print("getting average")
  28. avg = statistics.mean(studentDict[peeraverage])
  29. print(avg)
  30.  
  31. def addStudent():
  32. studentToAdd = input("What is the student you want to add?")
  33. if studentToAdd in studentDict:
  34. print("it appears that you have a copy, please enter a different name.")
  35. else:
  36. newstudentgrades = input("what is the person grades?")
  37. studentDict[studentToAdd] = (int(newstudentgrades))
  38. print('adding grades')
  39. def listStudents():
  40. for key in studentDict.keys():
  41. print("Student: {}".format(key))
  42.  
  43. def main():
  44. print("""
  45. [1] - Enter Grades
  46. [2] - Delete Students
  47. [3] - Average Grade
  48. [4] - Exit
  49. [5] - Add Student
  50. [6] - List Students
  51. """)
  52.  
  53. action = str(input("what is your command?"))
  54.  
  55. if action == '1':
  56. enterGrades()
  57. elif action == '2':
  58. removeStudent()
  59. elif action == '3':
  60. studentAverage()
  61. elif action == '4':
  62. exit()
  63. elif action == '5':
  64. addStudent()
  65. elif action == '6':
  66. listStudents()
  67. else:
  68. print("you didn't enter a correct command.")
  69.  
  70. login = input('Username: ')
  71. passw = input('Password: ')
  72. if login in admin:
  73. if admin[login] == passw:
  74. print("welcome")
  75. while True:
  76. main()
  77. else:
  78. print("wrong password.")
  79. else:
  80. print("wrong username")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement