#GO OVER A THOUSAND [2] from commonFunctions import int_input repeating = True while repeating: total = 0 while total < 1000: total += int_input("Please enter a number: ") print("The total so far is {}.".format(total)) if total > 1000: print("Well done on going over a thousand.") while True: userRepeat = input("Do you want to repeat? \nEnter Y/N: ").lower() if userRepeat == "y": break elif userRepeat == "n": repeating = False break else: print("Enter valid input.")
from random import randint from commonFunctions import int_input repeating = True while repeating: chuckNorris = 10 player = 10 while True: numbers = [randint(1,1000),randint(1,1000)] secretNumber = randint(0,1) print("The two numbers are {} and {}.".format(numbers[0],numbers[1])) chuckGuess = randint(0,1) while True: userGuess = int_input("Please select the first or second number. Enter 1 or 2: ") - 1 if userGuess == 0 or userGuess == 1: break if secretNumber == userGuess: player += 1 else: player -= 1 if secretNumber == chuckGuess: chuckNorris += 1 else: chuckNorris -= 1 print("Chuck Norris has {} points and you have {} points.".format(chuckNorris, player))
#THREE NUMBER LOTTERY [7] from random import randint from commonFunctions import int_input repeating = True while repeating: gettingData = True while gettingData: numbers = [] print("Please enter three different numbers between.") for i in range(3): numbers.append(None) while True: numbers[i] = int_input("Please enter number {}: ".format(i+1)) if numbers[i] >= 1 and numbers[i] <= 10: break if numbers[0] in numbers[1:]: print("Please make sure the numbers are different.") elif numbers[1] == numbers[0] or numbers[1] == numbers[2]: print("Please make sure the numbers are different.") elif numbers[2] in numbers[:2]: print("Please make sure the numbers are different.") else: print("You entered {}.".format(numbers)) while True: print("Is this correct?") isCorrect = input("Enter Y/N: ").lower() if isCorrect == "y": gettingData = False
#EVERRANDOM [3-5] from random import randint from commonFunctions import int_input repeating = True while repeating: gettingData = True while gettingData: lowestValue = int_input("Please enter the lowest value: ") highestValue = int_input("Please enter the highest value: ") print("You selected a random number between {} and {}.".format(lowestValue, highestValue)) while True: isInformationCorrect = input("Is the above information correct. Enter Y/N: ").lower() if isInformationCorrect == "y": gettingData = False break elif isInformationCorrect == "n": break else: print("Enter Y/N.") print() randomNumber = randint(lowestValue, highestValue) if randomNumber == 7: print("Well done you go the lucky number - 7.") else: print(randomNumber) print() while True:
#DOUBLE IT FUNCTION [2+1] from commonFunctions import int_input def doubleIt(number): return number * 2 repeating = True while repeating: userNumber = int_input("Please enter a decimal number: ") print(doubleIt(userNumber)) print() while True: print("Do you want to repeat?") repeat = input("Enter Y/N: ").lower() if repeat == "y": break elif repeat == "n": repeating = False break
#NUMBER 15 BLOWS THE DEATH STAR[5] from commonFunctions import int_input missileTarget = 15 repeating = True while repeating: gettingData = True while gettingData: while True: attempts = int_input("Please enter a number between one and six of attempts you want: ") if attempts >= 1 and attempts <= 6: break print("You selected {} attempts.".format(attempts)) while True: isInformationCorrect = input("Is the above information correct. Enter Y/N: ").lower() if isInformationCorrect == "y": gettingData = False break elif isInformationCorrect == "n": break else: print("Enter Y/N.") print() for i in range(attempts): while True: guess = int_input("Please enter a number between one and twenty to blow up the death star: ") if guess >= 1 and guess <= 50: break
#WHICH IN THE LIST [1] from commonFunctions import int_input strings = ["Alpha", "Gamma", "Beta"] repeating = True while repeating: while True: itemNumber = int_input("Please select a number between ") - 1 if itemNumber >= 0 and itemNumber <= 2: break print(strings[itemNumber]) print() while True: userRepeat = input("Do you want to repeat? \nEnter Y/N: ").lower() if userRepeat == "y": break elif userRepeat == "n": repeating = False break else: print("Enter valid input.")
def largest(numbers): numbersSorted = sorted(numbers) return numbersSorted[-1] def smallest(numbers): numbersSorted = sorted(numbers) return numbersSorted[0] repeating = True while repeating: gettingData = True while gettingData: numbers = [0,0,0] for i in range(3): numbers[i] = int_input("Enter number {}: ".format(i+1)) for i in range(3): print(numbers[i], end=" ") print() print("Is this correct?") while True: dataCorrect = input("Enter Y/N: ").lower() if dataCorrect == "y": gettingData = False break elif dataCorrect == "n": break print("The smallest number is {}.".format(smallest(numbers))) print("The largest number is {}.".format(largest(numbers)))
# COMPUTER GUESSING [3] from commonFunctions import int_input from random import randint repeating = True while repeating: gettingData = True while gettingData: userNumber = int_input("Please enter a number between 1 and 100: ") if userNumber >= 1 and userNumber <= 100: print("You entered {}.".format(userNumber)) isInputCorrect = input("Please enter Y/N: ").lower() if isInputCorrect == "y": gettingData = False elif isInputCorrect == "n": print() else: print("In what world is {} between 1 and 100?".format(userNumber)) lowValue = 1 maxValue = 100 guessing = 0 while guessing < 6: guess = randint(lowValue, maxValue) while True: print("Is your guess higher or lower than {} or is it correct.".format(guess)) isHigherOrLower = input("Enter H/L/C: ").lower() if isHigherOrLower == "h": lowValue = guess
def alienWorldCreator(): radiusKm = randint(3000, 100000) massKg = radiusKm * randint(1, 5) * (10 ** 24) if randint(0,1) == 1: isInhabited = True else: isInhabited = False color = [hex(randint(0,255)),hex(randint(0,255)),hex(randint(0,255))] return [radiusKm, massKg, isInhabited, color] repeating = True while repeating: gettingData = True while gettingData: numberOfPlanets = int_input("Enter the number of planets in the solar system: ") print() print("Is the above correct?") while True: dataCorrect = input("Enter Y/N: ") if dataCorrect == "y": gettingData = False break elif dataCorrect == "n": break solarSystem = [] for i in range(numberOfPlanets): solarSystem.append(alienWorldCreator())