python newbie
Chris
chris at cmb-enterprises.com
Sun Apr 7 21:35:02 EDT 2002
In article <Xns91E989929996CRASXnewsDFE1 at 130.133.1.4>,
Philip Swartzleonard <starx at pacbell.net> wrote:
> def percent_chance( percentage ):
> "Assumes percentage as number 0-100"
> if random.random() > (percentage / 100.0):
> return 1
> else:
> return 0
Might more concisely be written as:
def percent_chance( percentage ):
return random.random() > (percentage / 100.0)
More information about the Python-list
mailing list