online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
print("Welcome to the multiplication math quiz!") print("In this quiz there will be 5 equations.") print("Good Luck!\n") from random import randint import sys, os used = ["None*None"] gi, gcorrect = 0, 0 equations = 5 # number of equations to ask per game def clear(): os.system("cls" if os.name == "nt" else "clear") while True: correct = 0 for _ in range(equations): gi += 1 tries = 0 x, y = None, None while "{}*{}".format(x, y) in used: if tries > 99: print("I think I asked all the numbers. Thanks for playing!") sys.exit(1) x, y = randint(1,10), randint(0,10) tries += 1 used.append("{}*{}".format(x, y)) answer = input("How much is {} * {}? ".format(x, y)) try: answer = int(answer) except: pass sys.stdout.write("\033[F") print("\rHow much is {} * {}? {}".format(x, y, answer), end="") if answer == x * y: print("\tGreat! {} is correct! :-)".format(answer)) correct += 1 gcorrect += 1 else: print("\tSorry... The correct answer is {}.".format(x * y)) print("\nYou got {}/5: {:0.1f}% correctness.".format(correct, correct*100/5)) choice = input("Hit Enter to play again or send any letter to quit: ") if choice == "": clear() else: if gi > equations: clear() print("Your global score was {}/{}: {:0.1f}% correctness.".format(gcorrect, gi, gcorrect*100/gi)) break #M# keyboard input, random integer, integer concatenate, system/os call, clear console and previous line, carriage return, list check/append, iteration, integer input check, error prevention, format number/percentage

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue