I have found a similar question. The solution mentioned there was:
int(hashlib.sha256(block_header + userID).hexdigest(), 16) / float(2**256)
You conver the hash into an integer, then divide that integer by 2**256. This gives you a decimal from 0 to 1 that can be compared to a random.random() to get the prize.