File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1+ # This is a guess the number game.
2+ import random
3+ secretNumber = random .randint (1 ,20 )
4+ print ('I am thing of a number bertween 1 and 20' )
5+
6+ # Ask the player to guess 6 times.
7+ for guessesTaken in range (1 ,7 ):
8+ print ('Take a guess' )
9+ guess = int (input ())
10+ if guess < secretNumber :
11+ print ('Your guess is too low' )
12+ elif guess > secretNumber :
13+ print ('Your guess is too high' )
14+ else :
15+ break #This condition is the correct guess!
16+
17+ if guess == secretNumber :
18+ print ('Good job! You guessed my number in ' + str (guessesTaken ) + 'guesses!' )
19+ else :
20+ print ('Nope. The number I was thinking of was ' + str (secretNumber ))
21+
Original file line number Diff line number Diff line change 11def spam (divideBy ):
2- return 42 / divideBy
2+ try :
3+
4+ return 42 / divideBy
5+ except ZeroDivisionError :
6+ print ('Error: Invalid argument.' )
37
48print (spam (2 ))
59print (spam (12 ))
You can’t perform that action at this time.
0 commit comments