forked from MIT-Emerging-Talent/ET6-practice-code-review
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/MIT-Emerging-Talent/ET6-fou…
- Loading branch information
Showing
1 changed file
with
47 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,47 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
""" | ||
A module for converting hours to minutes. | ||
Module contents: | ||
- convert_hours_to_minutes: calculates the time in minutes based on hours. | ||
Created on 31-12-2024 | ||
@author: Azza Omer | ||
""" | ||
|
||
|
||
def convert_hours_to_minutes(hour_wasted: int) -> int: | ||
""" | ||
Convert hours to minutes. | ||
Parameters: | ||
hour_wasted (int): The number of hours wasted. Must be a positive integer. | ||
Returns: | ||
int: The equivalent time in minutes. | ||
Examples: | ||
>>> convert_hours_to_minutes(1) | ||
60 | ||
>>> convert_hours_to_minutes(5) | ||
300 | ||
>>> convert_hours_to_minutes(12) | ||
720 | ||
>>> convert_hours_to_minutes(0) | ||
0 | ||
>>> convert_hours_to_minutes(3) | ||
180 | ||
>>> convert_hours_to_minutes("2") # Raises AssertionError | ||
Traceback (most recent call last): | ||
... | ||
AssertionError: hour_wasted must be an integer. | ||
>>> convert_hours_to_minutes(-5) # Raises AssertionError | ||
Traceback (most recent call last): | ||
... | ||
AssertionError: hour_wasted must be greater than or equal to 0. | ||
""" | ||
assert isinstance(hour_wasted, int), "hour_wasted must be an integer." | ||
assert hour_wasted >= 0, "hour_wasted must be greater than or equal to 0." | ||
minutes = hour_wasted * 60 | ||
return minutes |