When Python evaluates
), first it evaluates
; second, it assigns this argument value to the
local parameter of
spin); third, it applies
suite of statements is executed, ending with return 1 or return 0; fourth,
this result returned to the calling statement so that it can finish it's
We would use this function like this.
s = random.randrange(37)
# 0 <= s <= 36, single-0 roulette
if s == 0:
print s, "odd"
print s, "even"
We evaluate a function named random.randrange to create a random
clause handles the
s is zero. The first
clause evaluates our
odd function. To do this
evaluation, Python must set
spin to the value of
s and execute the suite of statements that are the body
odd. The suite of statements will return either
False. Since the
clauses handle zero and
odd cases, all that is left is for
s to be even.