0% found this document useful (0 votes)
4 views3 pages

Python Offline Quiz Game Project

CFEDGBDVDGDRF

Uploaded by

xexab49482
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Python Offline Quiz Game Project

CFEDGBDVDGDRF

Uploaded by

xexab49482
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Project Name: Offline Quiz Game Competition with Scoreboard

Semester: V
Subject: Python Programming
Members:
1. Harsh Nayak (230170111067)
2. Nemi Shah (230170111068)
3. Gaurav Ninave (230170111071)

Objective:
The objective of this project is to create a simple quiz program in Python that asks multiple-choice
questions, checks the user's answers, and shows their final score.
It demonstrates core Python concepts such as:
 Reading data from a JSON file
 Using functions
 Using loops and conditions
 Shuffling options using the random module
 Taking user input
 Clearing screen and adding delay
 Displaying results

Project Structure:

Offline-Quiz-Game/
├── [Link] # Main Python program that runs the quiz
├── [Link] # File containing all quiz questions, options, and answers
├── README (optional) # Information about how the project works
Source Code:
1. [Link]
import json
import random
import os
import time

def read_data():
with open("[Link]", "r") as file:
data = [Link](file)
return data

def question(data):
print("Question " + str(data["id"]))
print(data["question"])

[Link](data["choices"])
options = ["A", "B", "C", "D"]
choices = {options[i]: data["choices"][i] for i in
range(len(data["choices"]))}
for option, choice in [Link]():
print(" " + option + ". " + str(choice))

answer = input("Your answer: ")


if [Link]([Link]()) == data["answer"] or [Link]() ==
str(data["answer"]).lower():
print("Correct!")
return 1
else:
print("Incorrect, the correct answer is " + str(data["answer"]))
return 0

def main():
[Link]("cls")

total = 0
correct = 0

data = read_data()
for i in range(len(data)):
correct += question(data[i])
total += 1
[Link](1)
[Link]("cls")

print("You got " + str(correct) + " out of " + str(total))

main()
2. [Link]

[
{
"id": 1,
"question": "What is 1 + 1?",
"choices": [1, 2, 3, 4],
"answer": 2
},
{
"id": 2,
"question": "What is the fastest land animal?",
"choices": ["cheetah", "leopard", "lion", "tiger"],
"answer": "cheetah"
},
{
"id": 3,
"question": "Which metal is heavier between gold and silver?",
"choices": ["gold", "silver"],
"answer": "gold"
},
{
"id": 4,
"question": "What is the smallest among the world's oceans?",
"choices": ["Pacific Ocean", "Atlantic Ocean", "Indian Ocean",
"Arctic Ocean"],
"answer": "Arctic Ocean"
}
]

You might also like