Skip to content

Commit

Permalink
updated is_positive.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Luyando-Chitindi committed Dec 29, 2024
1 parent 4628091 commit f94e33e
Showing 1 changed file with 28 additions and 48 deletions.
76 changes: 28 additions & 48 deletions solutions/is_positive.py
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

0 comments on commit f94e33e

Please sign in to comment.