Basic calculator made with python...
Basic calculator made with python...
So basically made this calculator by using If , Else and Elif conditions in Python...
while(True):
print("Actions available\n('+','-','*','**','/')")
a=int(input("Enter your first number\n"))
sign=input("Enter operator\n")
b=int(input("Enter your second number\n"))
if sign=='+':
print("Your addition is",a+b)
elif sign=='-':
print("Your subtraction is",a-b)
elif sign=='/':
print("Your division is", a / b)
elif sign=='*':
print("Your multiplication is", a * b)
elif sign=='**':
print("Your power is", a ** b)
else:
print("Error! Unexpected sign or values")
opinion=input("For using this calculator again enter yes and for exit press enter or type exit\n")
opinion.upper()
if opinion=="yes":
continue
else:
print("Thanks for using this calculator")
break
print("Actions available\n('+','-','*','**','/')")
a=int(input("Enter your first number\n"))
sign=input("Enter operator\n")
b=int(input("Enter your second number\n"))
if sign=='+':
print("Your addition is",a+b)
elif sign=='-':
print("Your subtraction is",a-b)
elif sign=='/':
print("Your division is", a / b)
elif sign=='*':
print("Your multiplication is", a * b)
elif sign=='**':
print("Your power is", a ** b)
else:
print("Error! Unexpected sign or values")
opinion=input("For using this calculator again enter yes and for exit press enter or type exit\n")
opinion.upper()
if opinion=="yes":
continue
else:
print("Thanks for using this calculator")
break
I have also made a calculator which works perfectly but is a risky calculator because it gives wrong or pre set answer for some specific values..
print("This is a risky calculator")
x=int(input("Enter first number:"))
sign=input("Enter your function:")
y=int(input("Enter the second number:"))
if sign=='-':
if x==10 and y==5:
print("Your subtraction is",6)
else:
print("Your subtraction is", (x) - (y))
elif sign=='+':
if x==56 and y==9 :
print("Your addition is",77)
else:
print("Your addition is", (x) + (y))
elif sign=='*':
if x==45 and y==3 :
print("Your multiplication is",555)
else:
print("Your multiplication is", (x) * (y))
elif sign=='/':
if x==56 and y==6 :
print("Your division is",4)
else:
print("Your division is", (x) / (y))
else:
print("Error! Unexpected sign or values")
print("How many marks you got after using this calculator")
You can also run this code and do some basic calculations and I have
also used while(True) functions by user's choice to run this program again
and again..
Comments
Post a Comment