Zagadnienia do przedmiotu 'Wstęp do programowania w naukach przyrodniczych'

    #!/usr/bin/env python2
    import math
    from random import random
class P3D :
    x = 0
    y=0
    z=0
    def init(self, xi,yi,zi) :
        self.x = xi
        self.y = yi
        self.z = zi
    def print_me(self) :
        print(“x: %7.3f y: %7.3f z: %7.3f” % (self.x,self.y,self.z))
    def d(self,x2,y2,z2) :
        d = x2 - self.x
        d2 = dd
        d = y2 - self.y
        d2 += dd
        d = z2 - self.z
        d2 += dd
        return math.sqrt(d2)
    def d_p3d(self,p) :
        d = p.x - self.x
        d2 = dd
        d = p.y - self.y
        d2 += dd
        d = p.z - self.z
        d2 += dd
        return math.sqrt(d2)
punkt1 = P3D(0,1,2)
punkt2 = P3D(-1,2,3)
punkt1.print_me()
punkt2.print_me()
print punkt1.d(0,1,2), punkt2.d_p3d(punkt1)
punkty = []
for i in range(10) :
    p = P3D(random(),random(),random())
    punkty.append(p)
for i in range(10) :  
for j in range(10) : print punkty[i].d_p3d(punkty[j])