← Lesson
Min, Max, Percent, and Clip
Joeven
Run
Reset
Python loads on first run
def clip(x, lo, hi): return min(hi, max(lo, x)) scores = [0.91, 0.12, 0.40, 0.77] print("best", max(scores)) print("worst", min(scores)) print("keep if >= 0.35", [s for s in scores if s >= 0.35]) passed = 29 total = 32 rate = passed / total print("rate", round(rate, 3)) print("percent", round(100 * rate, 1)) print("clip 1.2 to [0,1]", clip(1.2, 0, 1)) print("clip -0.1 to [0,1]", clip(-0.1, 0, 1)) print("clip 0.4 to [0,1]", clip(0.4, 0, 1)) step = 3 max_steps = 8 print("under budget", step < max_steps) print("tokens left", max(0, 800 - 950))
Run to execute this in your browser. Nothing is sent to a server.