Python Forum
Assignment to make a multiple choice game
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Assignment to make a multiple choice game
#1
Hi, so for school I had to make a multiple choice game. I was wondering if this program that ive created would be get a good mark. It is graded on the proper usage of for loops and if statements. (just the basics). I also added the usage of a class. Although I don't know if that will help. If you guys have any pointers to make my code more compact or efficient, due tell. Thanks!

import time

# list of prompts
prompts = [
    "What is the color of an apple? \n(a) red \n(b) blue \n(c) purple",
    "What is the color of an banana? \n(a) green \n(b) yellow \n(c) orange",
    "What is the color of an strawberry? \n(a) red \n(b) blue \n(c) green",
]

# question class
class Questions:
    def __init__(self, prompt, answer):
        self.prompt = prompt
        self.answer = answer

questions = [Questions(prompts[0], "a"),
             Questions(prompts[1], "b"),
             Questions(prompts[2], "a"),
]

score = 0

# main loop
for item in questions:
    print(item.prompt)
    answer = input("Insert your answer: ")
    if answer == item.answer: # check if input corresponds with the answer assigned to each prompt.
        print("\nYou got it correct!\n")
        score += 1
    else:
        print("\nYou got it wrong!\n")

ask = True
print(f"You got {score}/3 correct!")

# ask the user if he wants to close the game
if ask:
    answer = input("Do you want to continue? \n yes \n no \n")
    if answer == "n" or answer == "No" or answer == "no":
        print("Thank you for playing!")
        time.sleep(1)

    
Reply
#2
I'd give you a good grade.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I am attempting to make a car booking system for my assignment aboo 5 11,980 Aug-08-2023, 12:50 PM
Last Post: loganmary689
  Need help with my assignment please - game of Solitaire Muzz 6 6,615 Sep-28-2021, 07:36 PM
Last Post: Underscore
  How to make a variable contain multiple values stevenjwilliams83 10 3,512 Apr-30-2020, 07:22 AM
Last Post: pyzyx3qwerty
  Coding Python to make a game similar to Tic-Tac-Toe AdamJae 3 2,140 Oct-23-2019, 03:29 PM
Last Post: jefsummers
  Using random.choice v.v Dawkinz 8 3,507 Aug-31-2019, 04:42 PM
Last Post: Dawkinz
  How to hold a program in the turtle (Tic-Tac-Toe game assignment) kmchap 1 4,560 May-17-2018, 05:39 PM
Last Post: j.crater
  School Work Assignment: Snake Game DarksideMoses 6 5,133 Apr-29-2018, 10:56 PM
Last Post: DarksideMoses
  Just some second choice answers help please ajaY 6 5,083 Apr-07-2017, 08:25 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020