def answerChecker(): dmUtil.returnKey() print("=======================") print("DATAMAN Problem Checker") print("=======================") progRun = True #Program loop while progRun == True: print("Let's check your math!") print("What kind of problem is it? \n1.+ \n2.- \n3.x \n4.Exit") choice = dmUtil.getUserInput() if choice == 1: doAddProblem() elif choice == 2: doSubProblem() elif choice == 3: doMulProblem() elif choice == 4: progRun = False else: print("Enter a valid option!")
def datamanCalculator(): dmUtil.returnKey() print("==================") print("DATAMAN Calculator") print("==================") progRun = True #Program loop while progRun == True: print("Let's do some math!") print("What kind of problem is it? \n1.+ \n2.- \n3.x \n4.Exit") choice = dmUtil.getUserInput() if choice == 1: doAddProblem() elif choice == 2: doSubProblem() elif choice == 3: doMulProblem() elif choice == 4: progRun = False else: print("Enter a valid option!")
def again(): print("\nWould you like to do another one?") print("1. Yes \n2. No") choice = dmUtil.getUserInput() dmUtil.returnKey() # Repeat selection if choice == 1: return True # Quit selection elif choice == 2: return False
def guessTheNumberGame(): dmUtil.returnKey() print("===================") print("DATAMAN Number Game") print("===================") # Create random number randomNumber = random.randint(1,100) # Create a counter for the number of guesses. guessCounter = 0 # Create a bool for gameover status. gameOver = False print("I'm thinking of a number...between 1 and 100....Take a guess!") # Create loop using bool to control it. while gameOver == False: # Get a guess from the user. userNumber = dmUtil.getUserInput() # Add one to the counter. guessCounter = guessCounter + 1 # Evaluate the user guess. if userNumber > randomNumber: dmUtil.returnKey() print("Too high... Try again!") elif userNumber < randomNumber: dmUtil.returnKey() print("Too Low... Try again!") else: dmUtil.returnKey() print("That's right! You guessed ", randomNumber, "in only ", guessCounter, "tries!") # Set the game over controller to end the loop gameOver = True
def popQuiz(): dmUtil.returnKey() # Bool to control game state gameLoop = True print("================") print("DATAMAN Pop Quiz") print("================") while gameLoop == True: # Generatr randoms needed for numbers and operator number1 = getRandomNumber() number2 = getRandomNumber() operator = getRandomOperator() # Assign string values for operator if operator == 0: operatorChar = "+" questionPrompt = str(number1) + " " + operatorChar + " " + str( number2) + " = " answer = number1 + number2 elif operator == 1: operatorChar = "-" questionPrompt = str(number1) + " " + operatorChar + " " + str( number2) + " = " answer = number1 - number2 else: operatorChar = "X" questionPrompt = str(number1) + " " + operatorChar + " " + str( number2) + " = " answer = number1 * number2 print(questionPrompt) userAnswer = dmUtil.getUserInput() while userAnswer != answer: print("Not quite...Try again!") print(questionPrompt) userAnswer = dmUtil.getUserInput() dmUtil.returnKey() print("That's right!") print(questionPrompt, answer) # Go again question gameLoop = again()