27 lines
777 B
Python
27 lines
777 B
Python
# pkgmain3.py with with main function
|
|
|
|
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() |