Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,26 @@
|
|||
import random
|
||||
|
||||
inclusive_range = (1, 100)
|
||||
|
||||
print("Guess my target number that is between %i and %i (inclusive).\n"
|
||||
% inclusive_range)
|
||||
target = random.randint(*inclusive_range)
|
||||
answer, i = None, 0
|
||||
while answer != target:
|
||||
i += 1
|
||||
txt = input("Your guess(%i): " % i)
|
||||
try:
|
||||
answer = int(txt)
|
||||
except ValueError:
|
||||
print(" I don't understand your input of '%s' ?" % txt)
|
||||
continue
|
||||
if answer < inclusive_range[0] or answer > inclusive_range[1]:
|
||||
print(" Out of range!")
|
||||
continue
|
||||
if answer == target:
|
||||
print(" Ye-Haw!!")
|
||||
break
|
||||
if answer < target: print(" Too low.")
|
||||
if answer > target: print(" Too high.")
|
||||
|
||||
print("\nThanks for playing.")
|
||||
Loading…
Add table
Add a link
Reference in a new issue