def test_sphere_volume(): s = Sphere(3) assert s.volume == 4 / 3 * pi * (3 ** 3) # Volume should not be able to be set try: s.volume = 10 except AttributeError: pass else: assert False
def test_sphere(): """ tests sphere area and volume to a relative tolerance to one one-hundredth. tests ability to change sphere volume and calculate correct resulting volume and radius. :return: None """ s1 = Sphere(15) assert str(s1) == "Sphere with radius: 15.000000" assert repr(s1) == "Sphere(15)" assert isclose(s1.volume, 943, rel_tol=.01) assert isclose(s1.area, 2827.43, rel_tol=.01) s1.volume = 7 assert isclose(s1.volume, 7, rel_tol=.01) assert isclose(s1.radius, 1.29, rel_tol=.01) s2 = Sphere.from_diameter(18) assert s2.radius == 9
def test_sphere_vol(): s = Sphere(4) print(s.volume()) assert s.volume() == 268.082573106329
def test_sphere_volume(): s = Sphere(5) print(s.volume()) assert s.volume() == 654.4984694978737
def test_volume(): s1 = Sphere(4) assert s1.volume() == 268.082573106329
def test_volume(): s1 = Sphere(10) assert round(s1.volume(), 2) == 4186.67
def test_sphere(): example = Sphere(2) assert example.volume() == (4/3)*pi*8
def test_sphere(): s = Sphere(4) assert s.volume() == (4 / 3) * math.pi * 4**3 assert s.surface_area() == 4 * math.pi * 4**2
def sphere_test(): s = Sphere(2) assert s.volume() == (4 / 3) * math.pi * 2**3 assert s.surfuce_area() == 4 * math.pi * 2**2