๐Ÿ PyQuest๐Ÿญ Function Factory ยท โš–๏ธ Functions That Decide
โญ 0 XP๐Ÿ Python is waking upโ€ฆ

Functions That Decide โš–๏ธ

Now mix return with if and your function becomes a little brain that gives different answers for different inputs.

def judge(score):
    if score >= 90:
        return "๐Ÿฅ‡ Gold!"
    elif score >= 70:
        return "๐Ÿฅˆ Silver!"
    else:
        return "Keep practicing!"

print(judge(95))    # โžœ ๐Ÿฅ‡ Gold!
print(judge(72))    # โžœ ๐Ÿฅˆ Silver!
print(judge(30))    # โžœ Keep practicing!

Remember: the moment a return runs, the function stops right there and hands that answer back. The other branches never even get looked at.

The big rule: make sure every path has a return. If a score sneaks through with no return, your function hands back None โ€” Python's way of saying "uhh, nothing?"

Your mission

You're judging a talent show.

  1. Build a function judge(score) with one parameter
  2. Use if / elif / else inside it, with these cutoffs:
    • 90 or more โžœ return a top-prize verdict
    • 70 or more โžœ return a middle verdict
    • anything lower โžœ return an encouraging message
  3. Call it at least 3 times with different scores and print each verdict

The words are yours โ€” make the verdicts funny! ๐ŸŽค

Your code

Press โ–ถ Run to see what your code does!