Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Kareiman committed Jan 12, 2025
2 parents 26e3146 + afb55bf commit d57bff0
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions solutions/convert_hours_to_minutes.py
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

0 comments on commit d57bff0

Please sign in to comment.