forked from MIT-Emerging-Talent/ET6-practice-code-review
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
""" | ||
A Module for determining whether a number is odd | ||
Module contents: | ||
- is_number_odd : determine if the number is odd or not | ||
created on 08/01/2025 | ||
@author: Azza Ibrahim | ||
""" | ||
def is_number_odd(number: int) -> bool: | ||
""" | ||
The function takes an intger input from the user, validate the input, | ||
and determine if the number is odd, if the input is not an intger, | ||
an error is raised. | ||
Parameters: | ||
number: the intger to be determined whether odd or not | ||
Return: | ||
bool: | ||
True: if he number is odd | ||
False: if the number is not | ||
Raises: | ||
AssertionError: if the input is not an int | ||
ValueError: if the input is empty | ||
Exmples: | ||
>>> is_number_odd(3) | ||
True | ||
>>> is_number_odd(2) | ||
False | ||
>>> is_number_odd() | ||
Input cannot be empty | ||
>>> is_number_odd(sss) | ||
Input must be an intger | ||
""" | ||
assert isinstance(number, int), "Input must be an intger" | ||
if not number: | ||
raise ValueError("Input cannot be empty") | ||
|
||
if number % 2 != 0: | ||
return True # Odd | ||
else: | ||
return False # Not odd (even) |