Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Developer.Implement chain for #57 #61

Open
desjoerd-test-bot bot opened this issue Mar 1, 2024 · 1 comment
Open

Developer.Implement chain for #57 #61

desjoerd-test-bot bot opened this issue Mar 1, 2024 · 1 comment

Comments

@desjoerd-test-bot
Copy link

Write the code to implement the calculator logic

Copy link
Author

#!/bin/bash

Create the source code file

touch calculator.py

Add code to the source code file

cat << EOF > calculator.py

Calculator class

class Calculator:
def add(self, num1, num2):
return num1 + num2

def subtract(self, num1, num2):
    return num1 - num2

def multiply(self, num1, num2):
    return num1 * num2

def divide(self, num1, num2):
    if num2 == 0:
        raise ValueError("Cannot divide by zero")
    return num1 / num2

Create an instance of the calculator

calc = Calculator()

Test the calculator

print(calc.add(5, 10))
print(calc.subtract(15, 7))
print(calc.multiply(3, 4))
print(calc.divide(20, 5))
EOF

Print the contents of the source code file

cat calculator.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

0 participants