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

I Was Already Practicing Scrum Without Realizing It ❤️ | My CSM Journey 🚀

  https://youtube.com/shorts/26z3QNQSyc0 Hi. So uh as you may know that I'm Adita Johan who is working as a scrum master as part of the ...