Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. count = int(30)
  2. #This was made to calculate 30 students' marks, in order to change amount of input needed,change value in count.
  3. print("Each will be entered one per line")
  4. scoreList = []
  5. nameList=[]
  6. for i in range (1, count+1):
  7. nameList.append(input("Enter Name:"))
  8. while True:
  9. if all(x.isalpha() or x.isspace() for x in nameList[i-1]):
  10. break
  11. del (nameList[i-1])
  12. nameList.append(input("Please enter letters only:"))
  13. while True:
  14. try:
  15. scoreList.append(int(input("Enter Computer Science Marks:")))
  16. while (scoreList[i-1]) >100 or (scoreList[i-1])<0:
  17. del (scoreList[i-1])
  18. scoreList.append(int(input("Please Retry with a valid number:")))
  19. break
  20. except ValueError:
  21. print("PLease Retry with a Valid number:")
  22. fmt = '{:<30}{:<20}'
  23. print(fmt.format("Name Entered:","Comp Science Marks Entered:"))
  24. for g, (name, score) in enumerate(zip(nameList, scoreList)):
  25. print(fmt.format(name, score))
  26. print("Thank you the results are:")
  27. mysum = sum(scoreList)
  28. average = 1.0*mysum / count
  29. print ("Total : ",str(mysum))
  30. print ("Average: ",str(average))
  31. print ("Lowest : ",str(min(scoreList)))
  32. print ("Highest: ",str(max(scoreList)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement