Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def getData(x,y):
- return random.randint(x,y)
- def inRange(n,x,y): # x <= n <= y
- return (x <= n and n <= y)
- #Main Program
- target = getData(1,100)
- guess = int(input("Enter your guess: "))
- if inRange(guess,1,100):
- if guess < target:
- print("too low.")
- elif guess > target:
- print("too high.")
- else:
- print("Congrat.")
- else:
- print("Sorry, out of range.")
Advertisement
Add Comment
Please, Sign In to add comment