Create A Simple Calculator In Python


Hi there 

Today I will tell you how to make a calculator in python with simple steps.
Below is the code to make a calculator. Feel free to use it.
Thank You! 






#Calculator In Python

def sum(num1 , num2):
    result = num1 + num2
    print("Ans: " , result)


def min(num1 , num2):
    result2 = num1 - num2
    print("Ans: " , result2)


def mul(num1 , num2):
    result3 = num1 * num2
    print("Ans: " , result3)


def div(num1 , num2):
    result4 = num1 / num2
    print("Ans: " , result4)


def rem(num1 , num2):
    result5 = num1 % num2
    print("Ans: " , result5)

num1 = float(input("Enter A Number: "))
num2 = float(input("Enter second number: "))
operator = input("Enter Operator(+ , -, *, / ,%): ")

if (operator == "+"):
    sum(num1 , num2)
   
elif (operator == "-"):
    min(num1 , num2)


elif (operator == "*"):
    mul(num1 , num2)


elif (operator == "/"):
    div(num1 , num2)


elif (operator == "%"):
    rem(num1 , num2)

else:
    print("Invalid Operator")    



Watch The complete Step-By-Step Video On YouTube


Click To Watch Video

Comments

Post a Comment