Python - Programming Language
This course covers the basics of programming in Python. Work your way through the videos and we'll teach you everything you need to know to start your programming journey!

Building A Quiz

Lesson 32
Author : Mike Dane
Last Updated : October, 2017


Copyclass Question:
     def __init__(self, prompt, answer):
          self.prompt = prompt
          self.answer = answer

question_prompts = [
     "What color are apples?\n(a) Red/Green\n(b)Orange",
     "What color are bananas?\n(a) Red/Green\n(b)Yellow",

questions = [
     Question(question_prompts[0], "a"),
     Question(question_prompts[1], "b"),

def run_quiz(questions):
     score = 0
     for question in questions:
          answer = input(question.prompt)
          if answer == question.answer:
               score += 1
     print("you got", score, "out of", len(questions))