Advertisement
Guest User

Untitled

a guest
Dec 19th, 2016
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. # First course work for Udemy "Become a Professional Python Programmer" training
  2.  
  3. import statistics
  4.  
  5. CorrectUsername = "Admin"
  6. CorrectPassword = "999"
  7. studentDict = {}
  8.  
  9.  
  10. def add_student():
  11. name_to_add = str(input('Student name: '))
  12. grade_to_add = int(input('Grade: '))
  13. if name_to_add not in studentDict:
  14. studentDict[name_to_add] = []
  15. studentDict[name_to_add].append(grade_to_add)
  16. else:
  17. studentDict[name_to_add].append(grade_to_add)
  18. print(studentDict)
  19.  
  20.  
  21. def remove_student():
  22. name_to_remove = str(input('Student name: '))
  23. if name_to_remove in studentDict:
  24. del studentDict[name_to_remove]
  25. print(studentDict)
  26.  
  27.  
  28. def average_grade():
  29. name_avg = str(input('Student name: '))
  30. if name_avg in studentDict:
  31. print('\nAverage grade: ', statistics.mean(studentDict[name_avg]))
  32.  
  33.  
  34. def authorization():
  35. loop = True
  36. while loop:
  37. username = input('Please, enter your username: ')
  38. if username == CorrectUsername:
  39. password = input('Please enter your password: ')
  40. if password == CorrectPassword:
  41. print('Logged in successfully as ' + username)
  42. loop = False
  43. else:
  44. print('Password incorrect!')
  45. else:
  46. print('Username incorrect!')
  47.  
  48.  
  49. def menu():
  50. trigger = True
  51. while trigger:
  52. print("""
  53. [1] - Enter Grades\n
  54. [2] - Remove Student\n
  55. [3] - Student Average Grades\n
  56. [4] - Exit\n
  57. What would you like to do today? (Enter a number: )
  58. """)
  59. answer = input('What would you like to do? ')
  60. if answer == '1':
  61. add_student()
  62. elif answer == '2':
  63. remove_student()
  64. elif answer == '3':
  65. average_grade()
  66. elif answer == '4':
  67. trigger = False
  68. else:
  69. print('You enter non-valid value, please try again!')
  70.  
  71. authorization()
  72. menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement