Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.9 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
68b06e589bf2273243814771 Challenge 36: Thermostat Adjuster 29 challenge-36

--description--

Given the current temperature of a room and a target temperature, return a string indicating how to adjust the room temperature based on these constraints:

  • Return "heat" if the current temperature is below the target.
  • Return "cool" if the current temperature is above the target.
  • Return "hold" if the current temperature is equal to the target.

--hints--

adjust_thermostat(68, 72) should return "heat".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(adjust_thermostat(68, 72), "heat")`)
}})

adjust_thermostat(75, 72) should return "cool".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(adjust_thermostat(75, 72), "cool")`)
}})

adjust_thermostat(72, 72) should return "hold".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(adjust_thermostat(72, 72), "hold")`)
}})

adjust_thermostat(-20.5, -10.1) should return "heat".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(adjust_thermostat(-20.5, -10.1), "heat")`)
}})

adjust_thermostat(100, 99.9) should return "cool".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(adjust_thermostat(100, 99.9), "cool")`)
}})

adjust_thermostat(0.0, 0.0) should return "hold".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(adjust_thermostat(0.0, 0.0), "hold")`)
}})

--seed--

--seed-contents--

def adjust_thermostat(temp, target):

    return temp

--solutions--

def adjust_thermostat(temp, target):
    if temp < target:
        return "heat"
    elif temp > target:
        return "cool"
    else:
        return "hold"