File size: 767 Bytes
a9814b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def convert_temperature(temp_c: float, unit: str) -> int:
    if unit == "f":
        return int((temp_c * 9 / 5) + 32)
    elif unit == "s":
        return int(temp_c + 273.15)
    return int(temp_c)


def convert_wind_speed(speed_kmh: float, unit: str) -> int:
    if unit == "f":
        return int(speed_kmh * 0.621371)  # km/h to mph
    elif unit == "s":
        return int(speed_kmh / 3.6)  # km/h to m/s
    return int(speed_kmh)


def convert_visibility(vis_km: float, unit: str) -> int:
    if unit == "f":
        return int(vis_km * 0.621371)  # km to miles
    return int(vis_km)


def convert_precip(precip_mm: float, unit: str) -> float:
    if unit == "f":
        return round(precip_mm * 0.0393701, 2)  # mm to inches
    return round(precip_mm, 2)