fork download
  1. from random import randint
  2.  
  3. class Square(object):
  4. name = "Kvadrat"
  5. side = 0
  6.  
  7. def side_a(self):
  8. self.side = randint(1,10)
  9. return self.side
  10.  
  11. def area(self):
  12. return self.side_a() ** 2
  13.  
  14. def random_text(self):
  15. return "Side: %d, area: %d" % (self.side, self.area())
  16.  
  17. s = Square()
  18. print(s.random_text())
  19. print(s.random_text())
  20. print(s.random_text())
  21. print(s.random_text())
Success #stdin #stdout 0.03s 12312KB
stdin
Standard input is empty
stdout
Side: 0, area: 4
Side: 2, area: 4
Side: 2, area: 9
Side: 3, area: 36