-
-
Save WaleedAlrashed/5df9c2d103312845de2747c1f75ff2ab to your computer and use it in GitHub Desktop.
simple calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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