Skip to content

Commit

Permalink
calculator
Browse files Browse the repository at this point in the history
  • Loading branch information
Karby25 committed Dec 10, 2024
0 parents commit 15dc42e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM python:3.9-slim

WORKDIR /app
COPY . /app

CMD ["python", "app.py"]
34 changes: 34 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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()

0 comments on commit 15dc42e

Please sign in to comment.