Python Quiz Project

#Quiz Game
score = 0
total_questions = 0

answer = print(input("Do you want to play a game? (y/n) :"))
if answer == 'y':
    answer = print(input("Python requires semicolons(;) at the end of each statement? (T/F):"))
    if answer == 'f':
        score += 1
        print("Correct!")
    else: 
        print("Incorrect!")
        score -= 1
    answer = print(input("What keyword defines a function? (Case Sensitive)"))
    if answer == 'def':
        print("Correct!")
        score += 1
    else:
        print("Incorrect")
        score -= 1
    answer = print(input("What keyword defines a while loop? (Case Sensitive)"))
    if answer == 'while':
        score += 1
        print("Correct!")
    else: 
        print("Incorrect!")
        score -= 1
else: 
    print("ok then :(")

This is just repeating the first print statement over and over, can anyone help?

do not put input inside print, I guess there is some weird interaction there

It’s doing the same thing

#Quiz Game
score = 0
total_questions = 0

answer = input("Do you want to play a game? (y/n) :")
if answer == 'y':
    answer = input("Python requires semicolons(;) at the end of each statement? (T/F):")
    if answer == 'f':
        score += 1
        print("Correct!")
    else: 
        print("Incorrect!")
        score -= 1
    answer = input("What keyword defines a function? (Case Sensitive)")
    if answer == 'def':
        print("Correct!")
        score += 1
    else:
        print("Incorrect")
        score -= 1
    answer = input("What keyword defines a while loop? (Case Sensitive)")
    if answer == 'while':
        score += 1
        print("Correct!")
    else: 
        print("Incorrect!")
        score -= 1
else: 
    print("ok then :(")

how are you testing your code?

it works. But you should fix the case sensitive bug of the first question.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.