Exemplo n.º 1
0
            "\nHow many questions do you want per game (1 to 10)? ")
        while True:
            try:
                num = int(numPrompt)
                break
            except:
                print("You did not enter a valid number, please try again")
                numPrompt = input(
                    "\nHow many questions do you want per game (1 to 10)? ")

        if game == 1:
            mg.noOfQuestions = num
            printInstructions(mathInstructions)
            score += mg.generateQuestions()
        else:
            bg.noOfQuestions = num
            printInstructions(binaryInstructions)
            score += bg.generateQuestions()

        print("\nYour current score is %d" % (score))
        userChoice = int(input("\nPress enter to continue or -1 to end: "))

    updateUserScore(newUser, name, str(score))

except Exception as e:
    exc_type, exc_obj, exc_tb = sys.exc_info()
    fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
    print("An unknown error occured. Program will exit.")
    print("Error: {0} at line {1} in file: {2}".format(e, exc_tb.tb_lineno,
                                                       fname))
Exemplo n.º 2
0
            game = input("\nMath Game (1) or Binary Game (2)?: ")

        numPrompt = input("\nHow May Questions do you want per game (1 to 10)?: ")
        while True:
            try:
                num = int(numPrompt)
                break
            except:
                print("you did not enter a valid number. Please try again.")
                numPrompt = input("\nHow May Questions do you want per game (1 to 10)?: ")

            if game == '1':
                mg.noOfQuestions = num
                printInstructions(mathInstructions)
                score = score + mg.generateQuestions()
            else:
                bg.noOfQuestions = num
                printInstructions(binaryInstructions)
                score = score +bg.generateQuestions()

            print ("\nYour current score is %d." %(score))

            userChoice = input("\nPress Enter to Continue or -1 to end: ")

    updateUserScore(newUser, userName, str(score))

except Exception as e:
    print ("An unknown error pccurred. Program will exit.")
    print("Error: ", e)