# Library of Math functions collected in a class called Math
class Math:
__PI = 3.14 # private variable for PI public can't access
def CircleArea(radius): # putlic method that takes a radius as input
return Math.__PI*radius*radius # and returns the area the circle
def Circumference(radius): # public method that takes a radius as input
return 2*Math.__PI*radius # and returns the circumference of the circle
def RectangleArea(height,width): # public method that takes height and width as inputs
return height*width # and returns the area of the Rectangle
def PI(): # public method that takes no input
return Math.__PI # and returns the value of private value of __PI
# 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))
print()
# do we want the public (users of the Math Library) to have access to our __PI? ya why not
# do we want the public to alter PI? No
#
# the following will error because __PI is a private field in Math
# print(Math.__pi)
print(Math.PI()) # the public method PI() in the Math library returns 3.14
print()