tronds

Random number guess game in Python

Jul 20th, 2012
369
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. #-------------------------------------------------------------------------------
  2. # Name:        Random number guess game
  3. # Purpose:     Create a random number and let user guess it
  4. #
  5. # Author:      tronds
  6. #
  7. # Created:     19.07.2012
  8. # Copyright:   (c) tronds 2012
  9. # Licence:     <your licence>
  10. #-------------------------------------------------------------------------------
  11. #!/usr/bin/env python
  12.  
  13. start = int(raw_input ("Enter your startpoint: "))
  14. end = int(raw_input("Enter your endpoint: "))
  15.  
  16. import random
  17. randnum = random.randrange(start,end)
  18. userguess = int(raw_input("Whats your guess?"))
  19. while randnum != userguess:
  20.     userguess = int(raw_input("Want another guess? Enter it here!"))
  21.     print "Your guess didn't match the random number"
  22.     print "Your guess was", userguess
  23.  
  24. print "Congratulations, your guess was correct !"
Advertisement
Comments
  • Comment was deleted
Add Comment
Please, Sign In to add comment