Advertisement
adrianwii

Untitled

Apr 13th, 2025
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. class Uczen:
  2.     def __init__(self, name):
  3.         self.name = name
  4.         self.oceny = []
  5.  
  6.     def dodaj_ocene(self, ocena):
  7.         self.oceny.append(ocena)
  8.  
  9.     def policz_srednia(self):
  10.         suma = 0
  11.         for ocena in self.oceny:
  12.             suma += ocena
  13.  
  14.         return suma/len(self.oceny)
  15.  
  16.  
  17. from uczen import Uczen
  18.  
  19. uczen = Uczen("Adrian")
  20. print(uczen.name)
  21.  
  22.  
  23. uczen.dodaj_ocene(5)
  24. uczen.dodaj_ocene(1)
  25. uczen.dodaj_ocene(3)
  26.  
  27. print(uczen.oceny)
  28. print(uczen.policz_srednia())
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement