Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Makeup3Mod1.py
- # Restructuring this code to use a list
- # The input function returns a string not an int
- # print ("Please enter your first guess between 1 and 100")
- # Guess1 = input()
- #
- # print ("Please enter your second guess 1 and 100")
- # Guess2 = input()
- #
- # print ("Please enter your third guess 1 and 100")
- # Guess3= input ()
- Guess = [] # Create an empty list
- place = ["first", "second", "third"] # This list is used with the prompt
- for i in range(3):
- prompt = "Please enter your {} guess 1 and 100: ".format(place[i])
- value = input(prompt)
- Guess.append(int(value))
- #========================================
- # Makeup3Mod2.py
- from random import seed
- from random import randint
- seed(1)
- #Restructuring this code to use a list
- # generate some integers
- # Rand1 = randint(0, 100)
- # Rand2 = randint(0, 100)
- # Rand3 = randint(0, 100)
- Rand = [] # Create an empty list
- for i in range(3):
- value = randint(0, 100)
- Rand.append(value)
- print(Rand)
- #========================================
- # Makeup3Mod3.py
- import Makeup3Mod2
- import Makeup3Mod1
- # This code makes no sense
- # if Makeup3Mod1.Guess1 != Makeup3Mod2.Rand1:
- # if Makeup3Mod1.Guess1 != Makeup3Mod2.Rand2:
- # if Makeup3Mod1.Guess1 != Makeup3Mod2.Rand3:
- # if Makeup3Mod1.Guess2 != Makeup3Mod2.Rand1:
- # if Makeup3Mod1.Guess2 != Makeup3Mod2.Rand2:
- # if Makeup3Mod1.Guess2 != Makeup3Mod2.Rand3:
- # if Makeup3Mod1.Guess3 != Makeup3Mod2.Rand1:
- # if Makeup3Mod1.Guess3 != Makeup3Mod2.Rand2:
- # if Makeup3Mod1.Guess3 != Makeup3Mod2.Rand3:
- # print ("Nice try, but you are incorrect")
- #
- # else:
- #
- # print ("Good Job!")
- # Using a pair of for loops to do the comparison
- # winnerflag is used to signal a winning number has been matched
- winnerflag = False
- for i in range(3):
- if winnerflag:
- break
- for j in range(3):
- if Makeup3Mod1.Guess[i] == Makeup3Mod2.Rand[j]:
- print("Good Job!")
- winnerflag = True
- break
- if not winnerflag:
- print("Nice try, but you are incorrect")
- print ("Thanks for playing!")
- #========================================
- # Makeup3Main.py
- print ("Welcome to the 3 number Lotto!")
- print ("In a moment, you will have the chance to enter 3 different numbers and try to to guess the winning 3!")
- # First two imports are not needed in main because they are imported in the third module
- # import Makeup3Mod1
- # import Makeup3Mod2
- import Makeup3Mod3
Advertisement
Add Comment
Please, Sign In to add comment