Created
March 5, 2014 21:59
-
-
Save wkta/9377519 to your computer and use it in GitHub Desktop.
#MonthOfCode day 4 - error
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
# imports the sleep function; it will add some suspense | |
from time import sleep | |
import random | |
score = 0 | |
reasonable_player = False | |
print '*** tough guy simulator ***' | |
invite_msg = 'so you want to play the russian roulette, hu?' | |
while(not reasonable_player): | |
# this inner loop aims at validating the answer | |
valid_answer = False | |
while(not valid_answer): | |
print invite_msg,'y/n' | |
answer = raw_input() | |
if( not ('y'==answer or 'n'==answer)): | |
print 'answer y or n, come on!' | |
continue | |
valid_answer=True | |
if('n'==answer): | |
reasonable_player=True | |
continue | |
print 'you press the trigger, slowly...' | |
sleep( 1) #waits 1sec | |
# 6-bullets revolver simulation | |
if( random.choice( range(1,6)) == 1): | |
print '*BAM*!' | |
raise Exception('FATAL ERROR!') | |
print '*CLICK* nothing happens. Jesus.' | |
score += 1 | |
invite_msg = 'want more thrill, though guy?' | |
# displays score + comment | |
comment = ( | |
'Grow some balls, man!' if (score<3) else ( | |
'Not bad, I respect that!' if (score<5) else ( | |
'Hail to the king! You freak!' | |
) | |
) | |
); | |
print 'you achieved a score of:',str(score)+'.',comment |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think a
rm -rf
is missing somewhere ;-)