Advertisement
programusy

kod6

Nov 30th, 2022 (edited)
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. import math;
  2.  
  3. class Punkt:
  4. def wyswietl(self):
  5. print(self.x, ";", self.y)
  6. def do_zera(self):
  7. c=math.sqrt(self.x*self.x+self.y*self.y)
  8. print("odelglosc od srodka wynosi:",c)
  9. def move(self,x2,y2):
  10. self.x+=x2;
  11. self.y+=y2;
  12. def move_to(self,x2,y2):
  13. self.x=x2;
  14. self.y=y2;
  15. def odleglosc_od(self,x2,y2):
  16. dx = self.x - x2
  17. dy = self.y - y2
  18. dl = math.sqrt(dx * dx + dy * dy)
  19. print("odelglosc wynosi ", dl)
  20.  
  21.  
  22.  
  23. def main():
  24. p=Punkt()
  25. k=Punkt()
  26.  
  27. p.x=1
  28. p.y=2
  29. k.x=3
  30. k.y=4
  31. dx=k.x-p.x
  32. dy=k.y-p.y
  33. dl = math.sqrt(dx * dx + dy * dy )
  34. print("dlugosc ", dl)
  35. print(p.x,";",p.y,";",k.x,";",k.y,";")
  36. p.wyswietl()
  37. p.do_zera()
  38. p.move(1,2)
  39. p.wyswietl()
  40. p.move_to(1,2)
  41. p.wyswietl()
  42. p.odleglosc_od(11,2)
  43.  
  44.  
  45. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement