Created
April 5, 2012 11:57
-
-
Save codeinthehole/2310347 to your computer and use it in GitHub Desktop.
Pick winners
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import time | |
def pick_winners(candidates, num_winners): | |
for i in range(num_winners): | |
time.sleep(1) | |
winner = random.choice(candidates) | |
print "Winner %d: %s" % (i+1, winner) | |
candidates.remove(winner) | |
print "\nSorry %s\n" % ", ".join(candidates) | |
py_candidates = ['Andre', | |
'Eleni', | |
'Phil', | |
'Andrew Ingram', | |
'Alex', | |
'Becky', | |
'Gump', | |
'Anthony', | |
'Kura', | |
'Matus'] | |
print 'Picking python winners' | |
pick_winners(py_candidates, 6) | |
php_candidates = ['Marek', | |
'Duncan', | |
'Natalia', | |
'Miloud'] | |
print 'Picking PHP winners' | |
pick_winners(php_candidates, 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment