Popular Posts

Monday, September 14, 2020

Python Beginner: Building a Multiple Choice Quiz

 Hello, Developer! 😄

Today, we will make a "Multiple Choice Quiz" program. This program displays questions with multiple-choice. If the user input the correct answer, the program will count the correct answer number and display another questions until there is no more questions in the question array.

I showed all Multiple Choice Quiz program codes and execution results as follows.


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

Building a Multiple Choice Quiz.py

from Question import Question

question_prompts = [
"What Color are apples?\n(a) Red/Green\n(b) Purple\n(c) Orange\n\n",
"What Color are bananas?\n(a) Teal/n\a(b) Magenta\n(c) Yellow\n\n",
"What Color are strawberries?\n(a) Yellow\n(b) Red\n(c) Blue\n\n"

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

def run_test(questions):
score = 0
for question in questions:
answer = input(question.prompt)
if answer == question.answer:
score += 1
print("You got " + str(score) + "/" + str(len(questions)) + "correct")


Execution Result

Can you see the same result at your PC? Congratulations! Now you can use object, function, loop, input and output functions in the Python.

Let's see you again at the next post, Python developer! 😊



  1. Thanks for sharing nice information with us. i like your post and all you share with us is uptodate and quite informative, i would like to bookmark the page so i can come here again to read you, as you have done a wonderful job. choice carts

  2. Looking forward to reading more. Great blog post. Really Great.
    am i in love quiz


Python - Web crawling exercises

Hello Python developer! How are you? Hope you've been good and had wonderful time with Python. There are 10 Python requests module exerc...