sun_angle.sun_angle()   A
last analyzed

Complexity

Conditions 3

Size

Total Lines 8
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 8
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
def sun_angle(time):
2
    hour, minute = time.split(':')
3
    hour = int(hour)
4
    minute = int(minute)
5
    converted_time = (hour - 6) * 60 + minute
6
    if converted_time < 0 or converted_time > 12 * 60:
7
        return "I don't see the sun!"
8
    return round(converted_time / (12 * 60) * 180, 2)
9
10
11
if __name__ == '__main__':
12
    print("Example:")
13
    print(sun_angle("07:00"))
14
15
    # These "asserts" using only for self-checking
16
    # and not necessary for auto-testing
17
    assert sun_angle("07:00") == 15
18
    assert sun_angle("01:23") == "I don't see the sun!"
19
    print("Coding complete? Click 'Check' to earn cool rewards!")
20