# Creating modules
# Arithmetic operations
# arithopns.py
def fnadd(a,b):
return a+b
def fnsub(a,b):
return a-b
def fnmul(a,b):
return a*b
def fndiv(a,b):
return a/b
def fnmod(a,b):
return a%b
def fntruncdiv(a,b):
return a//b
# Main program
# importing modules
from arithopns import *
a = eval(input("Enter value: "))
b = eval(input("Enter value: "))
print("Sum =",fnadd(a,b))
print("Difference =",fnsub(a,b))
print("Product =",fnmul(a,b))
print("Division =",round(fndiv(a,b),4))
print("Modulo reminder =",fnmod(a,b))
print("Truncation division =",fntruncdiv(a,b))
"""
Sample output
>python modpgmAO.py
Enter value: 7
Enter value: 6
Sum = 13
Difference = 1
Product = 42
Division = 1.1667
Modulo reminder = 1
Truncation division = 1
"""
No comments:
Post a Comment
Don't be a silent reader...
Leave your comments...
Anu