"""
CSCI 145 Day 5 - conditionals (solutions)
"""


# ---------- Part 1: predict, then check ----------

# --- snippet A ---
x = 7
if x % 2 == 0:
    print("even")
else:
    print("odd")
# odd

# --- snippet B ---
score = 72
if score >= 90:
    print("A")
elif score >= 80:
    print("B")
elif score >= 70:
    print("C")
else:
    print("below C")
# C

# --- snippet C ---
x = 0
if x > 0:
    print("positive")
if x == 0:
    print("zero")
print("done")
# zero
# done


# ---------- Part 2: write the code ----------

def classify_temperature(temp):
    """
    Return a description of the weather based on temperature (Fahrenheit).

    Params: temp (int or float) -- the temperature in Fahrenheit
    Returns (str):
        "freezing"  if temp < 32
        "cold"      if 32 <= temp < 50
        "mild"      if 50 <= temp < 70
        "warm"      if 70 <= temp < 85
        "hot"       if temp >= 85
    """
    if temp < 32:
        return "freezing"
    elif temp < 50:
        return "cold"
    elif temp < 70:
        return "mild"
    elif temp < 85:
        return "warm"
    else:
        return "hot"


def classify_temperature_and_wind(temp, wind):
    """
    Like classify_temperature, but also takes a wind speed (mph) and
    returns "dangerously cold" instead of "freezing" or "cold" when
    the temp is less than 50 and wind speed is 20 mph or higher.
    Otherwise, returns exactly what classify_temperature(temp) returns.

    Params:
        temp (int or float) -- the temperature in Fahrenheit
        wind (int or float) -- the wind speed in mph
    Returns (str): a weather description, as above
    """
    if temp < 50 and wind >= 20:
        return "dangerously cold"
    else:
        return classify_temperature(temp)


print(classify_temperature(20))     # freezing
print(classify_temperature(45))     # cold
print(classify_temperature(60))     # mild
print(classify_temperature(78))     # warm
print(classify_temperature(90))     # hot

print(classify_temperature_and_wind(25, 25))    # dangerously cold
print(classify_temperature_and_wind(25, 5))     # freezing
