Skip to content

Commit 001ccc5

Browse files
authored
Add files via upload
1 parent a85cf02 commit 001ccc5

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

guessTheNumber.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+

zeroDivide.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
def spam(divideBy):
2-
return 42 / divideBy
2+
try:
3+
4+
return 42 / divideBy
5+
except ZeroDivisionError:
6+
print('Error: Invalid argument.')
37

48
print(spam(2))
59
print(spam(12))

0 commit comments

Comments
 (0)