Friday, January 8, 2021

Python code for simple operational calculator

First Method:


n1=float(input("Enter number1:"))

n2=float(input("Enter number2:"))

sign=input("Enter sign:")

if sign=='+':

    print("Answer=",n1+n2)

elif sign=='-':

    print("Answer=",n1-n2)

elif sign=='*':

    print("Answer=",n1*n2)

elif sign=='/':

    print("Answer=",n1/n2)

else:

    print("Invalid sign")


Second Method: 


n1=float(input("Enter number1:"))

n2=float(input("Enter number2:"))

sign=input("Enter sign:")

if sign=='+':

    n=n1+n2

elif sign=='-':

    n=n1-n2

elif sign=='*':

    n=n1*n2

elif sign=='/':

    n=n1/n2

else:

    print("Invalid sign")

print("Answer=",n)

No comments:

Post a Comment

Finding Direction: Navigating Career Goals and Life Aspirations

  Finding Direction: Navigating Career Goals and Life Aspirations Life often presents us with a myriad of choices, and the path to fulfillme...