Saturday, 17 October 2026
PastThree rungs, one idea. Solving rung 1 counts. Climb as far as you can.
Two Temperature Scales
functions + changing scales
Celsius into Fahrenheit
Write a function called to_fahrenheit
Multiply the Celsius value by 9, divide by 5 using whole-number division //, then add 32. So 100 becomes 212. Any fraction is thrown away, and negative values follow the same steps.
Examples
| Input | Output |
|---|---|
| 100 | 212 |
| 0 | 32 |
| -40 | -40 |
| 37 | 98 |
There are extra hidden tests, so make it work in general, not just for these.
Back the other way
Write a function called to_celsius
Now go the opposite direction: take 32 away, multiply by 5, then divide by 9 with //. So 212 becomes 100. Because fractions get thrown away both times, converting a number one way and back does not always land on the number you started with.
Examples
| Input | Output |
|---|---|
| 212 | 100 |
| 32 | 0 |
| -40 | -40 |
| 98 | 36 |
There are extra hidden tests, so make it work in general, not just for these.
The warmest reading
Write a function called warmest
readings is a list of small lists, each holding a number and either "C" or "F" to say which scale it is in. Return the warmest reading, still as its own [number, scale] list. Compare them all in Fahrenheit using the rung 1 steps, and if two readings are equally warm return the one that comes first in the list. An empty list returns None.
Examples
| Input | Output |
|---|---|
| [[100, "C"], [100, "F"]] | [100, "C"] |
| [[0, "C"], [100, "F"]] | [100, "F"] |
| [] | None |
| [[37, "C"], [98, "F"]] | [37, "C"] |
There are extra hidden tests, so make it work in general, not just for these.
Finish Rung 1 and today counts. Rungs 2 and 3 are there if you want to push further.