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

Adds calculator which errors on negative numbers or odd numbers #9

Open
wants to merge 2 commits into
base: work-experience-main
Choose a base branch
from

Conversation

olliesilvester
Copy link
Owner

Addresses #7

@olliesilvester olliesilvester changed the title Positive calculator Adds calculator which errors on negative numbers or odd numbers Jul 10, 2024
@olliesilvester olliesilvester changed the base branch from main to work-experience-main July 10, 2024 09:23
pass
class ValueOdd(Exception):
pass
class TotalOdd(Exception):
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We worked out that this can never happen, so can delete this part


def calculator():
try:
num1 = int(input(">"))
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicer for the message to say 'enter a float'

Copy link
Owner Author

@olliesilvester olliesilvester Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
num1 = int(input(">"))
num1: float = input("Enter a positive even digit")

class TotalOdd(Exception):
pass

def calculator():
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def calculator():
def calculator() -> None:


def test_if_inputs_and_total_valid_return_user_inputs():
with patch("builtins.input", side_effect = [6,8]):
calculator()
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
calculator()
assert calculator() == 14

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

Successfully merging this pull request may close these issues.

1 participant