Python Dates and Times in Python Let's Build a Timed Quiz App The Quiz Class

invalid syntax on quiz app

See code below. when i try to import Quiz, i get the "syntax error: invalid syntax" with the carrot pointing to the "print" on the third to last line - print("It took you {} seconds total"...

When i tried deleting that piece of code, i got the following error: "unexpected EOF error while parsing"

Thanks in advance for your help!

Kathryn

class Quiz:

questions = []
answers = [] 

def __init__(self):
    question_types = (Add, Multiply)
    # generate 10 random questions with numbers from 1 to 10
    for _ in range(10):
        num1 = random.randint(1, 10)
        num2 = random.randint(1, 10)
        question = random.choice(question_types)(num1, num2)
        self.questions.qppend()
    # add these questions into self.questions

def take_quiz(self):

    pass

def ask(self, question):

    pass

def total_correct(self):
    #return the number of total correct answers
    total = 0
    for answer in self.answers:
        if answer[0]:
            total += 1
    return total

def summary(self):
    # print how many you got right and the total # of questions. 5/10
    print("You got {} out of {} right.".format(
            self.total_correct(), len(self.questions
    ))
    print("It took you {} seconds total.".format(
            (self.end_time-self.start_time).seconds
    ))

2 Answers

Hannu Shemeikka
Hannu Shemeikka
16,799 Points

Hi,

You are missing the ending parenthesis in

print("You got {} out of {} right.".format(
        self.total_correct(), len(self.questions))

Add one more ) to the ending of this line and try again.

There's a spelling error on line

self.questions.qppend()

It should be

self.questions.append()

Thanks so much! that worked