Python Program How To Make a Simple Calculator
Python Program to Make a Simple Calculator
Example: Code Program
Output:
Example: Code Program
#This Function Add Two Number def add(a, b): return a+b #This Function Subtract 2nd Number to 1st def sub(a, b): return a - b #This Function Multiply Two Number def mul(a, b): return a*b #This Function Divide 1st Number in 2nd def div(a, b): return int(a/b) #This Function show Remainder def mod(a, b): return int(a%b) print("Plz Enter any Option") print("1-addition") print("2-Subtraction") print("3-Multiplication") print("4-Divide") print("5-Remainder") print("------------------------") while True: op = input("Enter Any Option:") print("------------------------") if("User Enter 1, 2,3,4"): x = int(input("Enter First Number:")) y = int(input("Enter Second Number:")) if op == '1': print(x, "+", y ,"=",add(x,y)) elif op == '2': print(x, "-" ,y, "=",sub(x,y)) elif op == '3': print(x, "*" ,y, "=",mul(x,y)) elif op == '4': print(x, "/" ,y, "=",div(x,y)) elif op == '5': print(x, "%" ,y, "=",mod(x,y)) break else: print("Invalid Option")
Post a Comment