-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
34 lines (28 loc) · 767 Bytes
/
app.py
File metadata and controls
34 lines (28 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def add(a, b):
return a + b
def subtract(a, b):
return a - b
def multiply(a, b):
return a * b
def divide(a, b):
if b != 0:
return a / b
else:
return "Division by zero error"
def main():
print("Simple Python Calculator")
a = float(input("Enter first number: "))
b = float(input("Enter second number: "))
operation = input("Enter operation (+, -, *, /): ")
if operation == '+':
print(f"Result: {add(a, b)}")
elif operation == '-':
print(f"Result: {subtract(a, b)}")
elif operation == '*':
print(f"Result: {multiply(a, b)}")
elif operation == '/':
print(f"Result: {divide(a, b)}")
else:
print("Invalid operation")
if __name__ == "__main__":
main()