-
-
Notifications
You must be signed in to change notification settings - Fork 49.8k
Add simple is_even algorithm #14061
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
base: master
Are you sure you want to change the base?
Add simple is_even algorithm #14061
Conversation
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.
Pull request overview
This PR adds a new is_even algorithm to the maths directory that determines whether an integer is even using the modulo operator.
- Introduces a simple
is_even()function with type hints - Uses the modulo operator (
n % 2 == 0) to check for evenness - Includes basic documentation describing the function's purpose
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def is_even(n: int) -> bool: | ||
| """ | ||
| Check whether a number is even. | ||
|
|
||
| :param n: Integer number | ||
| :return: True if even, False otherwise | ||
| """ | ||
| return n % 2 == 0 |
Copilot
AI
Dec 31, 2025
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.
The function is missing doctests, which are required according to the project's CONTRIBUTING.md guidelines. All functions must include doctests that pass automated testing. Please add example test cases in the docstring showing the function's behavior with various inputs (e.g., positive even numbers, positive odd numbers, zero, and negative numbers).
| """ | ||
| Check whether a number is even. | ||
|
|
||
| :param n: Integer number | ||
| :return: True if even, False otherwise | ||
| """ |
Copilot
AI
Dec 31, 2025
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.
The docstring is missing a URL reference to Wikipedia or another similar explanation. According to the project's CONTRIBUTING.md, all new algorithms must include at least one URL that points to Wikipedia or another similar explanation. Consider adding a reference such as https://en.wikipedia.org/wiki/Parity_(mathematics) at the beginning of the docstring or as a module-level docstring.
| :param n: Integer number | ||
| :return: True if even, False otherwise | ||
| """ | ||
| return n % 2 == 0 |
Copilot
AI
Dec 31, 2025
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.
The file is missing the standard doctest execution block that is present in other similar files in the maths directory. Please add the following at the end of the file to enable doctest execution:
if name == "main":
import doctest
doctest.testmod()
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.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| @@ -0,0 +1,16 @@ | |||
| def is_even(n: int) -> bool: | |||
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.
Please provide descriptive name for the parameter: n
Describe your change:
Checklist: