[ create a new paste ] login | about

Link: http://codepad.org/C8hvzTuf    [ raw code | fork | 1 comment ]

Python, pasted on Dec 25:
import random
exclusive = 0

def bad(thing_name, chance):
    x = random.random()
    if x < chance:
    	print (thing_name)
    	if thing_name in ("The person is in prison", "The person is on probation", "The person is in a nursing home", "The person is unemployed"):
        	exclusive = 1		
        
bad("The person is in prison", 0.01)
bad("The person experienced domestic abuse this year", 0.01)
bad("The person was sexually abused as a child", 0.1)
bad("The person was physically abused as a child", 0.2)
bad("The person has been raped", 0.09)
bad("The person has chronic pain", 0.2)
bad("The person is clinically depressed", 0.07)
bad("The person is cognitively disabled", 0.02)
bad("The person has schizophrenia", 0.01)
bad("The person has dementia", 0.02)
bad("The person is wheelchair-bound", 0.01)
bad("The person is an alcoholic", 0.07)
bad("The person is a heroin addict", 0.005)

if exclusive == 0:
	bad("The person is on food stamps", 0.20)
if exclusive == 0:
    bad("The person is unemployed", 0.05)
if exclusive == 0:
    bad("The person is on disability", 0.03)
if exclusive == 0:
	bad("The person is on probation", 0.02)
if exclusive == 0:
    bad("The person is in a nursing home", 0.01)


Create a new paste based on this one


Comments:
posted by skynet4ever on May 25
A comment from your Blog:
Mike says:
December 25, 2015 at 5:36 am

Small bug in your python script: `exclusive` will never be 1 at the end because it’s set as a local variable. You need `global exclusive` at the top of `bad`.
reply