def main(): print("This program calculates the volume and surface area of a sphere.") radius = eval(input("Please enter a radius: ")) sphere = Sphere(radius) print("The volume is", sphere.volume(), " and the surface area is", sphere.surfaceArea())
def main(): radius = getInputs() sphere = Sphere(radius) surface = sphere.surfaceArea() vol = sphere.volume() print("\nSurface Area: {0:0.3f} \nVolume: {1:0.3f}".format(surface, vol))
def main(): r = eval(input("What is the radius of your sphere? ")) s = Sphere(r) A = s.surfaceArea() V = s.volume() print("The volume of your sphere is {0:0.1f}.".format(V)) print("The area of your sphere is {0:0.1f}.".format(A))
def main(args): radius = int(args[1]) print("The radius of the sphere is %d" % (radius)) s1 = Sphere(radius) print("The surface area of sphere is ", s1.surfaceArea()) print("The volume of sphere is ", s1.volume())
def test_circle_initialization_str_repr_and_properties(self): s1 = Sphere(10) s2 = Sphere.from_diameter(40) assert type(s2) == Sphere self.assertEqual(s1.radius, 10.0) self.assertEqual(s1.diameter, 20.0) self.assertEqual(s2.radius, 20.0) self.assertEqual(s2.diameter, 40.0) s1.radius = 30 self.assertEqual(s1.diameter, 60.0) s2.diameter = 30 self.assertEqual(s2.radius, 15.0) self.assertEqual(str(s1), "Sphere with radius: 30.000") self.assertEqual(repr(s1), "Sphere(30.0)") self.assertEqual(round(s1.area), 11310) with pytest.raises(AttributeError) as error: s1.area = 50 assert "AttributeError: can't set attribute" in error self.assertEqual(round(s1.volume), 113097) with pytest.raises(AttributeError) as error: s1.volume = 50 assert "AttributeError: can't set attribute" in error
def test_volume(): s = Sphere(10) assert s.volume() == 4188.790204786391
from sphere import Sphere from guessing_game import GuessingGame s = Sphere(1) s.surface_area() s.volume() print(s) g = GuessingGame() g.reset_random() g.guess()