2021xxxxx - (名前)

class Point: def init(self, x, y, z): self._x = x self._y = y self._z = z

def distance(self):
    return ((self._x ** 2) + (self._y ** 2) + (self._z ** 2)) ** 0.5

点(5,0,0)のオブジェクトを作成

point1 = Point(5, 0, 0) print('点(5,0,0)の原点からの距離:', point1.distance())

点(0,5,0)のオブジェクトを作成

point2 = Point(0, 5, 0) print('点(0,5,0)の原点からの距離:', point2.distance())

点(0,5,5)のオブジェクトを作成

point3 = Point(0, 5, 5) print('点(0,5,5)の原点からの距離:', point3.distance())

点(5,5,5)のオブジェクトを作成

point4 = Point(5, 5, 5) print('点(5,5,5)の原点からの距離:', point4.distance())

Python 3次元座標点クラス - 原点からの距離計算

原文地址: http://www.cveoy.top/t/topic/kCKZ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录