二手产品经理

二手产品经理

THIS IS RENO

Learn Python Online in 100 Days - Week 3, Day 7

Record#

Today's exercise is a math game that uses a for loop to output calculation questions and keeps track of the final score.

CODE#

print("Math game!")
print()
score = 0
n1 = int(input("Enter the number you want to practice: "))
for i in range(1, 11):
    n0 = "{} * {} = ".format(i, n1)
    n2 = int(input(n0))
    if n2 == (i * n1):
        print("Correct, great job.")
        score += 1
    else:
        print("Oops, wrong answer. The correct answer is:", i * n1)

print("Your score is:", score, ".")
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.