0% found this document useful (0 votes)
11 views23 pages

Cs Project Devesh

Uploaded by

amarjeetayush599
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)
11 views23 pages

Cs Project Devesh

Uploaded by

amarjeetayush599
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
You are on page 1/ 23

RANIDIHA, GORAKHPUR

Session – 2024-25
COMPUTER SCIENCE

Project Report On

Quiz Competition

Submitted by Submitted to:


Name- Devesh Nishad Mr.Brijesh Singh Sir
Class- XII A (PGT)
Roll no.- Computer Science
CERTIFICATE

The project report entitled “QUIZ COMPETITION”


Submitted by Devesh Nishad of class XII Science for the
CBSE Senior Secondary Examination 2024-25, Class XII for
Computer Science at SANSKRITI PUBLIC SCHOOL, Ranidiha
Near Divya Nagar, Khorabar, Gorakhpur has been
examined.

Sig.Internal Examiner Sig.External Examiner

Principal’s Signature

School_Stamp
D E C L A R AT I O N

I hereby declare that the project work entitled


“Quiz Competition”, submitted to Department of
Computer Science, SANSKRITI PUBLIC SCHOOL,
Ranidiha Near Divya Nagar, Khorabar, Gorakhpur is
prepared by me.

Devesh Nishad

Class XII (Science)


ACKNOWLEDGEMENT

I would like to express a deep sense of thanks & gratitude to my


Project guide Mr. Brijesh Kumar Singh sir for guiding me
immensely through the course of the project. He always evinced
keen interest in my work. His constructive advice & constant
motivation have been responsible for the successful completion of
this project.
I also thanks to my parents for their motivation &
support. I must thanks to my class mates for their timely help &
support for completion of this project.
Last but not the least I would like to thanks all those who
had helped directly and indirectly towards the completion of this
project.

Devesh Nishad
Class: XII A
CONTENTS

1. USER DEFINED MODULE FUNCTION

2. TEXT FILE

4. SOURCE CODE

5. INPUT/OUTPUT INTERFACE

6. BIBLIOGRAPHY
MODULE FUNCTIONS
A. json

B. random

C. getpass

D. Play()

E. Quize_question()

F. CreateAccount()

G. loginAccount

H. logout()

I. rules()

J. About()
Python Overview
Python is a versatile, high-level programming
language known for its simplicity and readability.
It is widely used in web development, data
analysis, artificial intelligence, and application
development. Python’s rich ecosystem of libraries
makes it an excellent choice for building projects
like a Quiz Competition system.

Key Features of Python:


Ease of Learning and Use: Python has a clean and
simple syntax, making it ideal for beginners and
experts alike.

Extensive Libraries: Libraries such as Tkinter,


Django, and Flask help in creating graphical and
web-based quiz systems.
Platform Independent: Python can run on various
platforms like Windows, macOS, and Linux
without requiring major changes to the code.

Community Support: Python’s large community


ensures ample resources for troubleshooting and
extending functionalities.
Hardware Requirements

The hardware requirements for running a Quiz


Competition project depend on its complexity and
scale. Here are the general requirements:

Minimum Requirements:

Processor: Dual-core (e.g., Intel Core i3 or


equivalent)
RAM: 4 GB

Storage: 500 MB of free space for project files and


dependencies

Display: Standard monitor with at least 1024x768


resolution

Input Devices: Keyboard and mouse


Recommended Requirements:

Processor: Quad-core or higher (e.g., Intel Core


i5/i7 or AMD Ryzen)

RAM: 8 GB or more (especially for larger datasets


or web-based systems)

Storage: 1 GB of free space for additional plugins,


libraries, and project scalability

Network: Stable internet connection for online


quizzes or fetching resources from the web
Software Requirements

A Quiz Competition Project involves certain


software tools and frameworks. Below are the
necessary components:

Operating System:

Windows 10/11, macOS, or any modern Linux


distribution (e.g., Ubuntu, Fedora)

Python Environment:
Python Version: Python 3.9 or higher

Package Manager: pip (comes with Python


installation)
IDE/Text Editor:
Preferred: PyCharm, VS Code, or Jupyter
Notebook

Alternatives: Sublime Text, Atom, or Notepad++


Libraries and Frameworks:
Tkinter: For creating desktop-based quiz
applications

Flask/Django: For web-based quiz systems

SQLite or MySQL: For database management

Other Dependencies:
Pandas (data management)
Requests (API integration)
Matplotlib (optional, for result visualization)

Web Browser (if needed):


Latest versions of Chrome, Firefox, or Edge for
accessing online quiz interfaces.
Version Control (optional):
Git for managing the project codebase and
collaboration.
SOURCE CODE
import json
import random
import getpass

user = []

def play():
print("\n==========QUIZ START==========")
score = 0
with open("assets/questions.json", 'r+') as f:
j = json.load(f)
for i in range(10):
no_of_questions = len(j)
ch = random.randint(0, no_of_questions-1)
print(f,'\nQ{i+1} {j[ch]["question"]}\n')
for option in j[ch]["options"]:
print(option)
answer = input("\nEnter your answer: ")
if j[ch]["answer"][0] == answer[0].upper():
print("\nYou are correct")
score+=1
else:
print("\nYou are incorrect")
del j[ch]
print(f,'\nFINAL SCORE: {score}')

def quizQuestions():
if len(user) == 0:
print("You must first login before adding questions.")
elif len(user) == 2:
if user[1] == "ADMIN":
print('\n==========ADD QUESTIONS==========\n')
ques = input("Enter the question that you want to add:\n")
opt = []
print("Enter the 4 options with character initials (A, B, C,
D)")
for _ in range(4):
opt.append(input())
ans = input("Enter the answer:\n")
with open("assets/questions.json", 'r+') as f:
questions = json.load(f)
dic = {"question": ques, "options": opt, "answer":
ans}
questions.append(dic)
f.seek(0)
json.dump(questions, f)
f.truncate()
print("Question successfully added.")
else:
print("You don't have access to adding questions. Only
admins are allowed to add questions.")

def createAccount():
print("\n==========CREATE ACCOUNT==========")
username = input("Enter your USERNAME: ")
password = getpass.getpass(prompt= 'Enter your PASSWORD: ')
with open('assets/user_accounts.json', 'r+') as user_accounts:
users = json.load(user_accounts)
if username in users.keys():
print("An account of this Username already exists.\nPlease
enter the login panel.")
else:
users[username] = [password, "PLAYER"]
user_accounts.seek(0)
json.dump(users, user_accounts)
user_accounts.truncate()
print("Account created successfully!")

def loginAccount():
print('\n==========LOGIN PANEL==========')
username = input("USERNAME: ")
password = getpass.getpass(prompt= 'PASSWORD: ')
with open('assets/user_accounts.json', 'r') as user_accounts:
users = json.load(user_accounts)
if username not in users.keys():
print("An account of that name doesn't exist.\nPlease create an
account first.")
elif username in users.keys():
if users[username][0] != password:
print("Your password is incorrect.\nPlease enter the correct
password and try again.")
elif users[username][0] == password:
print("You have successfully logged in.\n")
user.append(username)
user.append(users[username][1])

def logout():
global user
if len(user) == 0:
print("You are already logged out.")
else:
user = []
print("You have been logged out successfully.")

def rules():
print('''\n==========RULES==========
1. Each round consists of 10 random questions. To answer, you must press
A/B/C/D (case-insensitive).
Your final score will be given at the end.
2. Each question consists of 1 point. There's no negative point for wrong
answers.
3. You can create an account from ACCOUNT CREATION panel.
4. You can login using the LOGIN PANEL. Currently, the program can only
login and not do anything more.
''')

def about():
print('''\n==========ABOUT US==========
This project has been created by Ritika Saroj and his team.
It is a basic Python Project for my class XII C.''')
ifname == " main ":
choice = 1
while choice != 7:
print('\n=========WELCOME TO QUIZ
MASTER==========')
print(' --------------------------------------- ')
print('1. PLAY QUIZ')
print('2. ADD QUIZ QUESTIONS')
print('3. CREATE AN ACCOUNT')
print('4. LOGIN PANEL')
print('5. LOGOUT PANEL')
print('6. SEE INSTRUCTIONS ON HOW TO PLAY THE
GAME')
print('7. EXIT')
print('8. ABOUT US')
choice = int(input('ENTER YOUR CHOICE: '))
if choice == 1:
play()
elif choice == 2:
quizQuestions()
elif choice == 3:
createAccount()
elif choice == 4:
loginAccount()
elif choice == 5:
logout()
elif choice == 6:
rules()
elif choice == 7:
break
elif choice == 8:
about()
else:
print('WRONG INPUT. ENTER THE CHOICE AGAIN')
INPUT / OUTPUT INTERFACE
BIBLIOGRAPHY

1. Sumita Arora (Python)

2. www.python.com

3. chatGPT

You might also like