Skip to content

Instantly share code, notes, and snippets.

@WaleedAlrashed
Created October 26, 2024 06:53
Show Gist options
  • Save WaleedAlrashed/5df9c2d103312845de2747c1f75ff2ab to your computer and use it in GitHub Desktop.
Save WaleedAlrashed/5df9c2d103312845de2747c1f75ff2ab to your computer and use it in GitHub Desktop.
simple calculator
x = float( input( "enter first number\t\t" ) )
y =float(input("enter second number\n"))
operation = input("choose an operation (+ , - , * , /): ")
if operation == '+':
result = x + y
elif operation == '-':
result = x - y
elif operation == '*':
result = x * y
elif operation == '/':
result = x / y if y != 0 else "Cannot divide by zero!"
else:
result = "invalid operation"
print(f"Result of {x} {operation} {y} is: {result}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment