All challenges

Today's challenge

Three rungs, one idea. Solving rung 1 counts. Climb as far as you can.

Scores In Range

if/else + valid ranges

Rung 1Daily goal5 points

Is that score allowed

Write a function called is_valid_score

A score counts as valid when it is 0 or more and 100 or less. Return True for a valid score and False for anything outside that range. Both 0 and 100 are allowed.

Examples

InputOutput
50True
0True
100True
101False

There are extra hidden tests, so make it work in general, not just for these.

Solution unlocks when today's challenge closes.

Rung 2Bonus7 points

Say what is wrong

Write a function called check_score

Instead of True or False, return a word for what happened: "too low" when the score is below 0, "too high" when it is above 100, and "ok" when it is allowed.

Examples

InputOutput
50"ok"
-1"too low"
101"too high"
0"ok"

There are extra hidden tests, so make it work in general, not just for these.

Solution unlocks when today's challenge closes.

Rung 3Bonus10 points

Pull them into range

Write a function called clamp_scores

Go through the list and return a new list where every score that is too low becomes 0 and every score that is too high becomes 100. Scores already in range are left exactly as they are, so [50, -1, 101] becomes [50, 0, 100]. An empty list returns an empty list.

Examples

InputOutput
[50, -1, 101][50, 0, 100]
[][]
[0, 100][0, 100]
[-5, -5][0, 0]

There are extra hidden tests, so make it work in general, not just for these.

Solution unlocks when today's challenge closes.

Finish Rung 1 and today counts. Rungs 2 and 3 are there if you want to push further.