Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion maths/prime_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,20 @@ def is_prime(number: int) -> bool:
True
>>> is_prime(67483)
False
>>> is_prime(16.1)
Traceback (most recent call last):
...
AssertionError: is_prime() only accepts positive integers
>>> is_prime(-4)
Traceback (most recent call last):
...
AssertionError: is_prime() only accepts positive integers
"""

# precondition
assert isinstance(number, int) and (
number >= 0
), "'number' must been an int and positive"
), "is_prime() only accepts positive integers"
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you change this assert to a ValueError instead?


if 1 < number < 4:
# 2 and 3 are primes
Expand Down