# Posted By

Tharix on 12/04/14

# Statistics

Viewed 407 times
Favorited by 0 user(s)

# Circle and sphere calculator

/ Published in: Python  A simple program to calculate the area and perimeter of a circle and to calculate the area and volume of a sphere.
Source is commented,

Copy this code and paste it in your HTML
`#Code by Tharix @ Snipplr#Importing modulesimport math print("Circle/Sphere calculator")print("Note: Pi is equal to",math.pi) #Getting the radius as inputr = int(input("Radius: ")) #Calculations based of the radiusd = r*2#_circle is the calculation, where pi is also calculatedPCirclePi = math.pi*r*2SCirclePi = math.pi*r**2#_npi is the calculation, where pi (as a symbol) is left inPCircleNPi = r*2SCircleNPi = r**2#Sphere areaSSpherePi  = 4*math.pi*(r**2)SSphereNPi = 4*(r**2)#Sphere volumeVSpherePi = 4/3*math.pi*(r**3)VSphereNPi = (r**3) #Outputprint(" ")#Diameterprint("d =",d)#Circle perimeterprint("P =","pi*{}".format(PCircleNPi),"or",PCirclePi)#Circle areaprint("Scircle =","pi*{}".format(SCircleNPi),"or",SCirclePi)#Sphere areaprint("Ssphere =","4*pi*{}".format(SSphereNPi)+"*{}".format(SCircleNPi),"or",SSpherePi)#Sphere volumeprint("Vsphere =","4/3*pi*{}".format(VSphereNPi),"or",VSpherePi)` Subscribe to comments