2021-01-16 15:03:34 +04:00

30 lines
883 B
Python

# pkgmain5.py with with main function
import site
site.addsitedir('/Users/muasif/Google Drive/PythonForGeeks/source_code/chapter2/mypackages')
import masifutil
def my_main():
""" This is a main function which generates two random numbers and then apply calculator functions on them """
x = masifutil.random_2d()
y = masifutil.random_1d()
sum = masifutil.add(x,y)
diff = masifutil.subtract(x,y)
sroot = masifutil.sqrt(x)
log10x = masifutil.log(x)
log2x = masifutil.ln(x)
print("x = {}, y = {}".format(x, y))
print("sum is {}".format(sum))
print("diff is {}".format(diff))
print("square root is {}".format(sroot))
print("log base of 10 is {}".format(log10x))
print("log base of 2 is {}".format(log2x))
""" This is executed only if the special variable '__name__' is set as main"""
if __name__ == "__main__":
my_main()