Advertisement
Guest User

python program

a guest
Dec 15th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. #!/bin/python3
  2.  
  3. def PodawanieOcen():
  4.     a = int(input("Podaj liczbe 2: "))
  5.     b = int(input("Podaj liczbe 3: "))
  6.     c = int(input("Podaj liczbe 4: "))
  7.     d = int(input("Podaj liczbe 5: "))
  8.     lista_ocen = [a, b, c, d]
  9.     return lista_ocen
  10.  
  11.  
  12. def SredniaOcen(oceny):
  13.     suma = 0
  14.     liczba_ocen = sum(oceny)
  15.     for i in range(len(oceny)):
  16.         suma += (i+2) * oceny[i]
  17.  
  18.     srednia = float(suma) / float(liczba_ocen)
  19.     return srednia
  20.  
  21.  
  22.  
  23. def Wyswietlanie(oceny, sredniaOcen):
  24.     print("Liczba 2: {}. Liczba 3: {}. Liczba 4: {}. Liczba 5: {}".format(oceny[0], oceny[1], oceny[2], oceny[3]))
  25.     print("Srednia ocen wynosi: {}".format(sredniaOcen))
  26.  
  27.  
  28. def SrednieOceny():
  29.     oceny = PodawanieOcen()
  30.     sredniaOcen = SredniaOcen(oceny)
  31.     Wyswietlanie(oceny, sredniaOcen)
  32.  
  33.  
  34. def main():
  35.     SrednieOceny()
  36.  
  37.  
  38. if __name__=="__main__":
  39.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement