Tuesday, July 22, 2025

WTP in python - Simple Calculator

 # Simple Calculator

# Ask the user to input two numbers and an operator (+, -, *, /) and perform the corresponding operation.


num1=float(input("Please enter the first number : "))

operator= input("Please enter (+,-,/,* ) : ")

num2=float(input("Please enter the second number :"))




if (operator=="+"):

    result=num1+num2

    print(f"{num1} + {num2} = {result}")


elif (operator=="-"):

    result=num1-num2

    print(f"{num1} - {num2} = {result}")


elif (operator=="/"):

    result=num1/num2

    print(f"{num1} / {num2} = {result}")


elif (operator=="*"):

    result=num1*num2

    print(f"{num1} * {num2} = {result}")


else:

    print("function not exsites as of now ")


No comments:

Post a Comment