-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: work-experience-main
Are you sure you want to change the base?
Conversation
pass | ||
class ValueOdd(Exception): | ||
pass | ||
class TotalOdd(Exception): |
There was a problem hiding this comment.
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(">")) |
There was a problem hiding this comment.
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'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
num1 = int(input(">")) | |
num1: float = input("Enter a positive even digit") |
class TotalOdd(Exception): | ||
pass | ||
|
||
def calculator(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def calculator(): | |
def calculator() -> None: |
|
||
def test_if_inputs_and_total_valid_return_user_inputs(): | ||
with patch("builtins.input", side_effect = [6,8]): | ||
calculator() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calculator() | |
assert calculator() == 14 |
Addresses #7