Python 10 /5/8/2017


SUBMITTED BY: canonical

DATE: May 8, 2017, 6:03 p.m.

FORMAT: Python

SIZE: 1.3 kB

HITS: 458

  1. If you want more of my pastes visit: https://randompaste.000webhostapp.com/index.html
  2. --------------------------------------------------------------------------------------
  3. view my last post at: https://bitbin.it/leQ48C2W/
  4. --------------------------------------------------------------------------------------
  5. import random #You need to import the random module before you can use it
  6. def takeinput() :
  7. z = input()
  8. while z < 9 or z > 100 :
  9. z = input()
  10. return z
  11. def guess() : #Function definitions need a colon after them
  12. x = random.choice(range(1, 101)) ##The second argument to range() is the max + 1
  13. y = takeinput()
  14. while(y!=x) : #Indentation is needed for while
  15. print "Guess a number!"
  16. if y == x :#If's need colons after them
  17. print "You've won the game!"
  18. elif y > x :
  19. print "Try a bit lower."
  20. elif y < x :
  21. print "Go higher."
  22. y = takeinput()
  23. print "Welcome to the Stupid Useless Guess Game�! Would you like to try guessing your pick a number? Use 1 to guess or 2 to pick."
  24. option = input()
  25. if option == 1 :
  26. guess() #x and y have to already exist if you are going to use them as arguments
  27. elif option == 2 :
  28. #COOOOOOOOODE

comments powered by Disqus