migrate to git.charlotte.sh
This commit is contained in:
commit
fbd588721e
412 changed files with 13750 additions and 0 deletions
17
python-csi160/week04/week04_labs/croce_week04_lab_04.py
Normal file
17
python-csi160/week04/week04_labs/croce_week04_lab_04.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
#4. Implement a random number guessing game. The computer will pick a number at random from
|
||||
# 0-9, the user will be asked to guess the number. Inform the user if they get the answer correct.
|
||||
|
||||
from random import randint
|
||||
|
||||
def random_number_game():
|
||||
num = randint(0,9)
|
||||
guess = int(input("random number guess(0-9): "))
|
||||
if guess == num:
|
||||
print("correct! you win")
|
||||
else:
|
||||
print("incorrect, the anser was", num)
|
||||
|
||||
|
||||
random_number_game()
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue