# Library of Math functions collected in a class called Math
class Math:
pi = 3.14
def CircleArea(radius):
return Math.pi*radius*radius
def Circumference(radius):
return 2*Math.pi*radius
def RectangleArea(height,width):
return height*width
# main program that used Math functions from the Math class
r = 3
area = Math.CircleArea(r)
print("Circle with radius " + str(r) + " has area " + str(area))
print("")
h = 3
w = 4
area = Math.RectangleArea(h,w)
print("Rectangle with height " + str(h) + " and width " + str(w) + " has area " + str(area))
# do we want the public having access to our pi? ya why not
print()
print(Math.pi)
print()
# do we want the public to edit pi? No way...
print("Changing pi to 20")
Math.pi = 20
r = 1
area = Math.CircleArea(r)
print("Circle with radius " + str(r) + " has area " + str(area))