Guest User

Untitled

a guest
Jul 16th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. # create a list of names and scores :
  4. studentScores = {'cheeky':100, 'arse':95, 'lankan':85}
  5.  
  6. # display items in the dictionary
  7. print(list(studentScores.keys()))
  8.  
  9. # variables to hold the values:
  10. # initalized to some dummy values
  11. minstudent = maxstudent = None
  12. minscore = maxscore = studentScores.values()[0]
  13.  
  14. for student, score in studentScores.items():
  15. if score >= minscore:
  16. maxscore = score
  17. maxstudent = student
  18. elif score <= maxscore:
  19. minscore = score
  20. minstudent = student
  21.  
  22. print('min student %s score %d' % (minstudent, minscore))
  23. print('max student %s score %d' % (maxstudent, maxscore))
  24.  
  25. # eof
Add Comment
Please, Sign In to add comment