forked from lyon1066/RBNA-CoLAB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGuess-the-Number.py
38 lines (30 loc) · 984 Bytes
/
Guess-the-Number.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# CoLAB paired programming code 2019
# By the Pythons
#
# This code is from paired programming workshops
# --Verified basic function
#
# Contact John T Haworth for questions
guessesTaken = 0
guess = 0
name = input("What is your name? ")
import random
for X in range (1):
number = (random.randint(1,51))
int (random.randint(1,51))
print('Well, ' + name + ', I am thinking of a number between 1 and 50.')
while guessesTaken < 6 and guess != number:
print('Take a guess.')
guess = input()
guess = int(guess)
guessesTaken = guessesTaken + 1
if guess < number:
print('Your guess was too low')
if guess > number:
print('Your guess was too high')
if guess == number:
guessesTaken = str(guessesTaken)
print('Good Job, ' + name + '! You guessed my number in ' + guessesTaken + ' guesses!')
if guess != number:
number = str(number)
print('Nope. The number I was thinking of was ' + number)