Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math;
- class Punkt:
- def __init__(self,x=None,y=None):
- self.x=int(input("podaj x")) if(x is None) else x
- self.y = int(input("podaj y")) if(y is None) else y
- def wyswietl(self):
- print(self.x, ";", self.y, ";", self.z)
- 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)
- class punkt3d(Punkt):
- def __init__(self,x=None,y=None,z=None):
- self.z=int(input("podaj z")) if(z is None) else z;
- super().__init__(x,y)
- def main():
- '''p1= Punkt(1,2)
- print(p1.x," ", p1.y)
- p2= Punkt(1)
- print(p2.x," ", p2.y)'''
- p3=punkt3d();
- print(p3.x, " ", p3.y, " ", p3.z)
- p4 = punkt3d(1);
- print(p4.x, " ", p4.y, " ", p4.z)
- p5 = punkt3d(1,2);
- print(p5.x, " ", p5.y, " ", p5.z)
- p6 = punkt3d(1,2,3);
- print(p6.x, " ", p6.y, " ", p6.z)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement