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