from math import * print("This program will determine the surface area and volume represented in a solid sphere. ") class Spheres: def __init__(self, r): self.radius = radius self.area = 0 self.volume = 0 def getRadius(self): return self.radius def surfaceArea(self): r = self.radius self.area = 4 * 3.14 * (r*r) return (self.area) def getVolume(self): r = self.radius self.volume = (4/3) * 3.14 * (r * r * r) return (self.volume) def main(): r = input("Please Enter the Radius of the Sphere: ") s = Spheres(r) print("the volume of the sphere is: ", s.surfaceArea()) print("The surface area of the sphere is: ", s.volume()) if __name__ == '__main__': main()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question