Skip to content

Commit

Permalink
is number odd
Browse files Browse the repository at this point in the history
  • Loading branch information
azziimm7 committed Jan 8, 2025
1 parent 740e74b commit e6d28c4
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions solutions/is_number_odd.py
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)

0 comments on commit e6d28c4

Please sign in to comment.