SHARE
TWEET

Untitled

a guest Oct 21st, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2.  
  3.  
  4. def checkValue(guess, mysteryNumber, count):
  5.     if guess < 0 or guess > 10:
  6.         return count, 'Invalid guess'
  7.     if guess == mysteryNumber:
  8.         return count, 'Win'
  9.     if guess < mysteryNumber:
  10.         return count, 'Too Low'
  11.     if guess > mysteryNumber:
  12.         return count, 'Too High'
  13.  
  14.  
  15. def getMysteryNumbers():
  16.     return random.randint(1, 10), random.randint(1, 10)
  17.  
  18.  
  19. def getGuess(user):
  20.     return int(input("{}: Guess a number between 1-10: ".format(user)))
  21.  
  22.  
  23. def checkResult(result):
  24.     count, msg = result
  25.     print(msg)
  26.     if msg == 'Win':
  27.         return True, count
  28.     return False, count
  29.  
  30.  
  31. def evaluate(user, count):
  32.     userGuess = getGuess(user)
  33.     result = checkValue(userGuess, m0, count)
  34.     ans, msg = checkResult(result)
  35.     print(msg)
  36.     return ans
  37.  
  38.  
  39. if __name__ == "__main__":
  40.     m0, m1 = getMysteryNumbers()
  41.     print(m0)
  42.     count = 0
  43.     for i in range(0, 3):
  44.  
  45.         user = 'User1'
  46.         result = evaluate(user, count)
  47.         if result:
  48.             break
  49.  
  50.         user = 'User2'
  51.         result = evaluate(user, count)
  52.         if result:
  53.             break
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top