Skip to content

Instantly share code, notes, and snippets.

@hitesh83
Created May 25, 2017 09:19
Show Gist options
  • Save hitesh83/9562ce01577bf6b555bcce2c56be58c0 to your computer and use it in GitHub Desktop.
Save hitesh83/9562ce01577bf6b555bcce2c56be58c0 to your computer and use it in GitHub Desktop.
Basic Calc in Python
running = True
while running:
print("1 = Addition")
print("2 = Subtraction")
print("3 = Multiplication")
print("4 = Division")
print("5 = Exit program")
cmd = int(input("Enter number : "))
if cmd == 1:
print("Addition")
first = int(input("Enter first number :"))
secund = int(input("Enter secund number :"))
result = first + secund
print(first ,'+' ,secund ,'=' , result)
elif cmd == 2:
print("Subtraction")
first = int(input("Enter first number :"))
secund = int(input("Enter secund number :"))
result = first - secund
print(first ,"-" ,secund ,"=" , result)
elif cmd == 3:
print("Mmltiplication")
first = int(input("Enter first number :"))
secund = int(input("Enter secund number :"))
result = first * secund
print(first ,"*" ,secund ,"=" , result)
elif cmd == 4:
print("Division")
first = int(input("Enter first number :"))
secund = int(input("Enter secund number :"))
result = first / secund
print(first ,"/" ,secund ,"=" , result)
elif cmd == 5:
print("Quit!")
running = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment