Advertisement
Maszi

zadanie 1 str 59

Jan 19th, 2020
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. def dodanieOceny():
  2.     ilosc = int(input("Ile ocen wprowadzić: "))
  3.     i=0
  4.     while i<ilosc:
  5.         nowaOcena = int(input("Podaj ocenę: "))
  6.         if nowaOcena >=2 and nowaOcena <=5:
  7.             oceny.append(nowaOcena)
  8.         i+=1
  9.  
  10. def zaliczenieSemestru():
  11.     i=0
  12.     while i<len(oceny):
  13.         if oceny[i]>=3:
  14.             i+=1
  15.             if i==2:
  16.                 print("Student ma zaliczony semestr")
  17.         else:
  18.             print("Student ma nie zaliczony semestr")
  19.             break
  20.  
  21. def oblicz_srednia(oceny):
  22.     suma=0
  23.     i=0
  24.     while i<len(oceny):
  25.         suma+=oceny[i]
  26.         i+=1
  27.     srednia = suma/len(oceny)
  28.     print("Średnia studenta wynosi: ", srednia)
  29.    
  30. def sortowanie():
  31.     oceny.sort()
  32.  
  33. def wyswietlenieOcen():
  34.     print(oceny)
  35.  
  36. oceny = []
  37. dodanieOceny()
  38. zaliczenieSemestru()
  39. oblicz_srednia(oceny)
  40. sortowanie()
  41. wyswietlenieOcen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement