Last active
October 20, 2016 13:36
-
-
Save BeOleg/782ff6bd67b4fd372ca6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# 1. Create a Python function that gets an integer between 1 - 12 (as an hour) and returns the exact time in hours | |
# and minutes at which the hands of the clock overlap at this hour | |
# (for example, for 1, the result will be close to 1:06) | |
# 2. create a unit test for this function, using 'assert', or the Python 'unittest' framework | |
# 3. [BONUS] | |
# a. add also seconds calculation to the return value of the function. | |
# b. calculate the angle of the hands in 360 degrees system | |
# taking 12:00 (noon, midnight) as a point of reference | |
# ATTENTION: You do not need to import any modules to implement this task | |
# declaration: | |
def hour_overlap(hour): | |
#implement body of the method | |
mins = None | |
secs = None | |
angle = None | |
# INSERT YOUR CODE HERE | |
return { | |
"hours": hour, | |
"mins": mins, #int | |
"secs": secs, #int | |
"min_angle": angle # float | |
} | |
def test_dict_instance(): | |
try: | |
res = hour_overlap(1) | |
assert isinstance(res, dict) | |
except AssertionError as e: | |
print("Oh, snap! the test has failed. exception: {}").format(e) | |
def your_test_one(): | |
raise AssertionError | |
def your_test_two(): | |
raise AssertionError | |
if __name__ == '__main__': | |
for i in range(1, 12): | |
print(hour_overlap(i)) | |
test_dict_instance() | |
your_test_one() | |
your_test_two() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment