jmooremcc

Python Lotto Test

Oct 17th, 2019
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.60 KB | None | 0 0
  1. # Makeup3Mod1.py
  2. # Restructuring this code to use a list
  3. # The input function returns a string not an int
  4. # print ("Please enter your first guess between 1 and 100")
  5. # Guess1 = input()
  6. #
  7. # print ("Please enter your second guess 1 and 100")
  8. # Guess2 = input()
  9. #
  10. # print ("Please enter your third guess 1 and 100")
  11. # Guess3= input ()
  12.  
  13. Guess = [] # Create an empty list
  14. place = ["first", "second", "third"] # This list is used with the prompt
  15.  
  16. for i in range(3):
  17.     prompt = "Please enter your {} guess 1 and 100: ".format(place[i])
  18.     value = input(prompt)
  19.     Guess.append(int(value))
  20.  
  21. #========================================
  22. # Makeup3Mod2.py
  23.  
  24. from random import seed
  25. from random import randint
  26.  
  27. seed(1)
  28. #Restructuring this code to use a list
  29. # generate some integers
  30. # Rand1 = randint(0, 100)
  31. # Rand2 = randint(0, 100)
  32. # Rand3 = randint(0, 100)
  33.  
  34. Rand = [] # Create an empty list
  35. for i in range(3):
  36.     value = randint(0, 100)
  37.     Rand.append(value)
  38.  
  39. print(Rand)
  40.  
  41. #========================================
  42. # Makeup3Mod3.py
  43.  
  44. import Makeup3Mod2
  45. import Makeup3Mod1
  46.  
  47. # This code makes no sense
  48. # if Makeup3Mod1.Guess1 != Makeup3Mod2.Rand1:
  49. #     if Makeup3Mod1.Guess1 != Makeup3Mod2.Rand2:
  50. #         if Makeup3Mod1.Guess1 != Makeup3Mod2.Rand3:
  51. #             if Makeup3Mod1.Guess2 != Makeup3Mod2.Rand1:
  52. #                 if Makeup3Mod1.Guess2 != Makeup3Mod2.Rand2:
  53. #                     if Makeup3Mod1.Guess2 != Makeup3Mod2.Rand3:
  54. #                         if Makeup3Mod1.Guess3 != Makeup3Mod2.Rand1:
  55. #                             if Makeup3Mod1.Guess3 != Makeup3Mod2.Rand2:
  56. #                                 if Makeup3Mod1.Guess3 != Makeup3Mod2.Rand3:
  57. #                                     print ("Nice try, but you are incorrect")
  58. #
  59. # else:
  60. #
  61. # print ("Good Job!")
  62.  
  63. # Using a pair of for loops to do the comparison
  64. # winnerflag is used to signal a winning number has been matched
  65. winnerflag = False
  66.  
  67. for i in range(3):
  68.     if winnerflag:
  69.         break
  70.     for j in range(3):
  71.         if Makeup3Mod1.Guess[i] == Makeup3Mod2.Rand[j]:
  72.             print("Good Job!")
  73.             winnerflag = True
  74.             break
  75.  
  76. if not winnerflag:
  77.     print("Nice try, but you are incorrect")
  78.  
  79. print ("Thanks for playing!")
  80.  
  81. #========================================
  82. # Makeup3Main.py
  83.  
  84. print ("Welcome to the 3 number Lotto!")
  85. print ("In a moment, you will have the chance to enter 3 different numbers and try to to guess the winning 3!")
  86.  
  87. # First two imports are not needed in main because they are imported in the third module
  88. # import Makeup3Mod1
  89. # import Makeup3Mod2
  90. import Makeup3Mod3
Advertisement
Add Comment
Please, Sign In to add comment