I have to create a modularized program that can find out the diameter, circumference, and area of a circle's radius. I'm sure many of you can notice I kind of winged this from a example given from my teacher. Instead of people pointing out the fact that I coded this wrong, could you please give me reasons for what I should do so I can better understand this concept?
import math
def main():
Radius = 0
Diameter = 0
Circumference = 0
Area = 0
Radius = GetRadius(Radius)
Diameter = SetDiameter(Radius, Diameter)
Circumference = SetCircumference(Radius, Circumference)
Area = SetArea(Radius, Area)
ShowResults(Radius, Diameter, Circumference, Area)
def GetRadius(myradius):
myradius = float(str(input("Enter your radius: ")))
return myradius
def SetDiameter(myradius, mydiameter):
mydiameter = myradius * 2
return mydiameter
def SetCircumference(myradius, mycircumference):
PIE = 3.14159
mycircumference = 2 * PIE * myradius
return mycircumference
def SetArea(myradius, myarea):
PIE = 3.14159
myarea = PIE * myradius * myradius
return myarea
def ShowResults(Radius, Diameter, Circumference, Area):
print("The Diameter is",mydiameter)
print("The Circumference is",mycircumference)
print("The Area is",myarea)
main()