if randval > perc:
EMPTY <= you don't need the lines like this, they don't do anything
return EMPTYAnd you can test for less-than-or-equal in one test
elif randval <= perc:
return PERSONin fact since one of the tests has to be true you can just use else:
if randval > perc:
return EMPTY
else:
return PERSONKent
Kooser, Ara S wrote:
Kent and Max. Thank you very much. It works fine now.
Ara
perc = raw_input("Please enter a threshold between 0-1. ") perc = float(perc)
def percolation(perc): randval = random.random() print randval PERSON, EMPTY = '*', '.' if randval > perc: EMPTY return EMPTY elif randval < perc: PERSON return PERSON elif randval == perc: PERSON return PERSON
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
