Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # First course work for Udemy "Become a Professional Python Programmer" training
- import statistics
- CorrectUsername = "Admin"
- CorrectPassword = "999"
- studentDict = {}
- def add_student():
- name_to_add = str(input('Student name: '))
- grade_to_add = int(input('Grade: '))
- if name_to_add not in studentDict:
- studentDict[name_to_add] = []
- studentDict[name_to_add].append(grade_to_add)
- else:
- studentDict[name_to_add].append(grade_to_add)
- print(studentDict)
- def remove_student():
- name_to_remove = str(input('Student name: '))
- if name_to_remove in studentDict:
- del studentDict[name_to_remove]
- print(studentDict)
- def average_grade():
- name_avg = str(input('Student name: '))
- if name_avg in studentDict:
- print('\nAverage grade: ', statistics.mean(studentDict[name_avg]))
- def authorization():
- loop = True
- while loop:
- username = input('Please, enter your username: ')
- if username == CorrectUsername:
- password = input('Please enter your password: ')
- if password == CorrectPassword:
- print('Logged in successfully as ' + username)
- loop = False
- else:
- print('Password incorrect!')
- else:
- print('Username incorrect!')
- def menu():
- trigger = True
- while trigger:
- print("""
- [1] - Enter Grades\n
- [2] - Remove Student\n
- [3] - Student Average Grades\n
- [4] - Exit\n
- What would you like to do today? (Enter a number: )
- """)
- answer = input('What would you like to do? ')
- if answer == '1':
- add_student()
- elif answer == '2':
- remove_student()
- elif answer == '3':
- average_grade()
- elif answer == '4':
- trigger = False
- else:
- print('You enter non-valid value, please try again!')
- authorization()
- menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement