Advertisement
Guest User

Untitled

a guest
Mar 17th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.79 KB | None | 0 0
  1. from statistics import mean as m
  2.  
  3. SDict = {'Jeff':[78,88,93],
  4.          'Alex':[92,76,88],
  5.          'Sam': [89,92,93]}
  6.  
  7. admins = {'Jenny':'8675309',
  8.           'Jimmy':'Hendrix'}
  9.  
  10. def home():
  11.    
  12.     print('''\n Welcome to Inner City Schools!
  13.    [1] - Enter grades.
  14.    [2] - Remove a student.
  15.    [3] - Student average grades.
  16.    [4] - Exit
  17.    ''')
  18.  
  19.    
  20.     action = input('\n''What would you like to do?: ')
  21.  
  22.     if action == '1':
  23.         print('You have chosen to enter grades''\n')
  24.         addGrade()
  25.  
  26.     elif action == '2':
  27.         print('You have chosen to remove a student.''\n')
  28.         removeStudent()
  29.        
  30.     elif action == '3':
  31.         StAvg()
  32.        
  33.     elif action == '4':
  34.         print('Goodbye.')
  35.         exit()
  36.        
  37.     else:
  38.         print('Please try again.')
  39.        
  40.    
  41. def addGrade():
  42.     student = input('Please enter student name: ')
  43.     grade = input('Please enter '+student+'\'s grade: ')
  44.  
  45.     if student in SDict:
  46.         print('Adding grade...')
  47.         SDict[student].append(float(grade))
  48.     else:
  49.         print('No student by that name.')
  50.        
  51.     print(SDict)
  52.  
  53.    
  54. def removeStudent():
  55.     student = input('Please enter student name: ')
  56.  
  57.     if student in SDict:
  58.         print('Removing student...')
  59.         del SDict[student]
  60.     else:
  61.         print('\n''No student by that name.''\n')
  62.        
  63.     print(SDict)
  64.  
  65. def StAvg():
  66.     for eachStudent in SDict:
  67.         gradeList = SDict[eachStudent]
  68.         avgGrade = m(gradeList)
  69.  
  70.         print(eachStudent,'Has an average grade of:', avgGrade)
  71.  
  72.  
  73. login = input('username: ')
  74. passw = input('Password: ')
  75.  
  76. if login in admins and admins [login] == passw:
  77.     print('Welcome',login)
  78.     while True:
  79.         home()
  80. else:
  81.     print('Invalid username or password')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement