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
1 parent
4628091
commit f94e33e
Showing
1 changed file
with
28 additions
and
48 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 |
---|---|---|
@@ -1,58 +1,38 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
""" | ||
A module for checking if a number is positive. | ||
Created on XX XX XX | ||
A module for checking if an integer is positive. | ||
Author: Luyando Chitindi | ||
Date: 12/22/2024 | ||
This module contains a function that deals with checking if a number is positive. | ||
The function will take an integer as an input and returns a boolean value indicating | ||
whether the number is greater than zero. | ||
Function: | ||
- is positive(number: int) -> bool | ||
Exceptions: | ||
-Raises TypeError if the input is not an integer. | ||
For Example: | ||
>>> is_positive(5) | ||
True | ||
>>> is_positive(-3) | ||
False | ||
>>> is_positive(0) | ||
False | ||
@author: Luyando .E. Chitindi | ||
""" | ||
|
||
|
||
def is_positive(number: int) -> bool: | ||
""" | ||
This will check if the number is positive. | ||
Arguments: | ||
number (int): The number to check if it is positive. | ||
Returns: | ||
bool: True if the number is positive, false otherwise. | ||
Raises: | ||
TypeError: If the argument that is provided is not an integer. | ||
Example: | ||
>>> is_positive(10) | ||
True | ||
>>> is_positive(-5) | ||
False | ||
>>> is_positive(0) | ||
False | ||
This checks if an integer is positive. | ||
Parameters: | ||
number: int, the number to check | ||
Returns -> bool: | ||
True if the number is positive, false otherwise. | ||
Raises: | ||
AssertionError: if the input is not an integer | ||
Example: | ||
>>> is_positive(4) | ||
True | ||
>>> is_positive(-3) | ||
False | ||
>>> is_positive(0) | ||
False | ||
>>> is_positive("hello") | ||
Traceback (most recent call last): | ||
... | ||
AssertionError: Input must be an integer. | ||
""" | ||
if not isinstance(number, int): | ||
raise TypeError("Input must be an integer.") | ||
assert isinstance(number, int), "Input must be an integer" | ||
return number > 0 |