Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math;
- class Punkt:
- def wyswietl(self):
- print(self.x, ";", self.y)
- def do_zera(self):
- c=math.sqrt(self.x*self.x+self.y*self.y)
- print("odelglosc od srodka wynosi:",c)
- def move(self,x2,y2):
- self.x+=x2;
- self.y+=y2;
- def move_to(self,x2,y2):
- self.x=x2;
- self.y=y2;
- def odleglosc_od(self,x2,y2):
- dx = self.x - x2
- dy = self.y - y2
- dl = math.sqrt(dx * dx + dy * dy)
- print("odelglosc wynosi ", dl)
- def main():
- p=Punkt()
- k=Punkt()
- p.x=1
- p.y=2
- k.x=3
- k.y=4
- dx=k.x-p.x
- dy=k.y-p.y
- dl = math.sqrt(dx * dx + dy * dy )
- print("dlugosc ", dl)
- print(p.x,";",p.y,";",k.x,";",k.y,";")
- p.wyswietl()
- p.do_zera()
- p.move(1,2)
- p.wyswietl()
- p.move_to(1,2)
- p.wyswietl()
- p.odleglosc_od(11,2)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement