Advertisement
dimkiriaoks

low, high, sum, mean

Nov 10th, 2021
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. def lowestHighestSum(students):
  2.     sum = 0
  3.     mean = 0
  4.     lowest = students[0]
  5.     highest = students[len(students)-1]
  6.     for i in range(len(students)):
  7.         sum += students[i]
  8.         if lowest > students[i]:
  9.             lowest = students[i]
  10.         if highest < students[i]:
  11.             highest  = students[i]
  12.         if highest < lowest:
  13.             highest, lowest = lowest, highest
  14.     mean = sum /len(students)
  15.     return lowest, highest, sum , mean
  16.  
  17.  
  18. lowest = 0
  19. highest = 0
  20. sum = 0
  21. mean = 0
  22.  
  23. students = [10, 3, 6 , 7, 9, 5, 4]
  24. lowest, highest, sum, mean = lowestHighestSum(students)
  25. print("The scores list is: ", students)
  26. print(f"lowest: {lowest}, highest: {highest}, sum: {sum}, mean: {mean}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement