cs project
cs project
PROJECT REPORT ON
“__________________”
ROLL NO :
NAME :
CLASS :
1
TABLE OF CONTENTS
1 Certificate
2 Acknowledgement
3 Introduction
5 Proposed system
8 Flowchart
9 Source Code
10 Output Screens
12 Requirements
13 Bibliography
2
Certificate
This is to certify that ___________________________________ student of class XII
(Science) has successfully prepared the report on the Project entitled
“__________________________________________”under the guidance of Mrs.
Bhuvanalakshmi (PGT Computer Science). The report is the result of his efforts &
endeavours. The report is found worthy of acceptance as final Project report for the
subject Computer Science of class XII (Science).
Signature of Principal
3
Acknowledgement
Apart from the efforts of me, the success of any project depends largely on the encouragement and
guidelines of many others. I take this opportunity to express my gratitude to the people who have been
instrumental in the successful completion of this project.
I express deep sense of gratitude to almighty God for giving me strength for the successful completion
of the project.
I express my deep sense of gratitude to the luminary The Principal, Nathella Vidhyodaya,
Ambattur has been continuously motivating and extending their helping hand to us.
I express my sincere thanks to the academician The Co ordinators, Nathella Vidhyodaya, Ambattur,
for constant encouragement and the guidance provided during this project.
My sincere thanks to M.Bhuvanalakshmi, A guide, Mentor all the above a friend, who critically reviewed
my project and helped in solving each and every problem, occurred during implementation of the project
4
Introduction
The Quiz Game is an interactive program designed to test and improve a player’s general
knowledge. In this game, the player is asked a series of multiple-choice questions
covering a variety of topics. Each question has four possible answers, and the player must
select the correct one to score points. This game encourages learning in a fun and
engaging way, challenging players to expand their knowledge base while competing for
high scores.
Players receive instant feedback on each answer, which helps reinforce learning and
enables them to track their progress. At the end of the game, players can view their scores
and compare them with previous high scores to see how well they performed.
The program saves high scores to track the top-performing players, motivating players to
improve and challenge themselves further.
Example:
The Quiz Game can be played multiple times, with questions randomly shuffled each
time for a unique experience. After each quiz session, the player's score is saved, and the
top scores are displayed. This feature encourages replayability and fosters a competitive
spirit among players.
5
❖ Python Overview:-
❖ Features of Python:-
1. Easy:-
Python is very easy to learn and understand; using this Python tutorial, any beginner
can understand the basics of Python.
2. Interpreted:-
It is interpreted (executed) line by line. This makes it easy to test and debug.
3. Object Oriented:-
The Python programming language supports classes and objects.
5. Portable:-
Since it is open source, we can run Python on Windows, Mac, Linux, or any other
platforms. Our programs will work without needing to the changed for every machine.
7. Large Library:-
Python provides us with a large standard library. We can use it to implement a
variety of functions without reinventing the wheel every time. We just pick the code we
need and continue, allowing us to focus on other important tasks.
❖ Advantages of Python:-
1. Extensible:-
2. Portable
3. Free & Open-Source
4. Readable
5. Embeddable
6. Improved Productivity
7. Simple and Easy
8. Object Oriented
9. Interpreted
10. Extensive Libraries
1. Point your web browser to the download page on the Python website
(www.python.org).
2. Select the latest Windows x86 MSI Installer and click the link todownload the
.msi installer.
3. Run the installer.
4. Select „Install for all users‟ and click the Next > button.
5. Keep the default option (C:\Python32\) as the destination directory andclick Next
> again.
6. Don't make any changes in the „Customize Python 3.2.3‟ dialog, justclick Next
> again.
7. Click Yes if asked if this program should be allowed to install softwareon your
system.
8. Click the Finish button when installation completes.
7
❖ About MySql:-
8
Objective of the project
The objective of this project is to let the students apply the programming
knowledge of a real-world situation/problem and exposed the students to how
programming skills help in developing good software.
9
Proposed System
Our project aims to create a Quiz Game in Python. This project showcases Python's
simplicity and versatility, with its easy-to-understand syntax, user-friendly interface, and
rapid development process.
This project also demonstrates the use of data management techniques to store and retrieve
quiz questions and high scores. In earlier days, managing data involved extensive
paperwork, but modern software solutions like Python and MySQL have made this process
simpler and faster. With MySQL, we can efficiently store a database of quiz questions and
track high scores for each player, enabling players to save their achievements and view top
scores.
Using MySQL allows for reliable data handling and prevents the loss of information,
saving time and effort. The combination of Python and MySQL provides an efficient and
seamless experience in managing the game’s data.
This system design highlights the ease and flexibility of using Python and MySQL
together to create an engaging, data-driven Quiz Game.
GAME
USER INTERFACE DATABASE
10
System Development Life Cycle(SDLC)
The System Development Life Cycle is used in the construction of the
serverappliance.
PLANNING ANALYSIS
SUPPORT DESIGN
IMPLEMENTATION
11
The module used and their purposes.
1. The Random Module
a. random() :-
For integers, there is a uniform selection from a range.
For a sequence, there is a uniform selection of a random
element. The syntax for using this function
is, random. random()‟.
.
2. MySql.connector module:-
a. cursor ( ):-
A database cursor is a useful control structure for a database
connectivity. Normally when we connect to a database from within a
script/program, then the query gets sent to the server, where it gets
executed, and the set of records retrieved as per the query is sent over
to the connection.
b. connect ( ):-
After we have installed the Python MySql connector, we can write
Python scripts using MySql.connector library that can connect to
MySql databases from within Python.
Next, we need to establish a connection to a MySql database using
the connect() function of mysql.connector package.
12
<connection-object>=mysql.connector.connect(
host=<host- name>,
user=<username>,
passwd=<password>
[,database=<database>])
c. execute ( ):-
This method is used to execute an SQL statement. Once we have
created a cursor, we can execute the SQL query using the execute()
function with the cursor object.
For example,
If we want to view all the records of table data which is a table in the
database test to which we established a connection, we can execute SQL
query “select * from data” by writing:
13
Flow-chart
START
Retrieve questions
from database
Display questions
with multiple-
choice options
14
SourceCode
import os
def start_quiz():
questions = [
{
"question": "What is the capital of France?",
"options": ["a) Paris", "b) London", "c) Rome", "d) Madrid"],
"answer": "a"
},
{
"question": "Which planet is known as the Red Planet?",
"options": ["a) Earth", "b) Mars", "c) Jupiter", "d) Saturn"],
"answer": "b"
},
{
"question": "Who discovered America in 1492?",
"options": ["a) Ferdinand Magellan", "b) Marco Polo", "c) Christopher
Columbus", "d) Vasco da Gama"],
"answer": "c"
},
{
"question": " In which year did World War II end?",
"options": ["a) 1942", "b) 1945", "c) 1948", "d) 1950"],
"answer": "b"
}
score = 0
For i, q in enumerate(questions):
print(f"\nQuestion {i + 1}: {q['question']}")
for option in q["options"]:
print(option)
15
print(f"\nQuiz complete! Your score is: {score}/{len(questions)}")
def save_high_score(score):
name = input("Enter your name for the high score board: ").strip()
with open("high_scores.txt", "w") as file:
file.write(f"{name}: {score}\n")
print("Your score has been saved!")
def view_high_scores():
if os.path.exists("high_scores.txt"):
print("\nHigh Scores:")
with open("high_scores.txt", "a") as file:
scores = file.readlines()
for line in scores:
print(line.strip())
else:
print("No high scores yet! Play the game to set a high score.")
def main_menu():
while True:
print("\nWelcome to the Quiz Game!")
print("1. Start Quiz")
print("2. View High Scores")
print("3. Exit")
choice = input("Enter your choice: ")
if choice == '1':
start_quiz()
elif choice == '2':
view_high_scores()
elif choice == '3':
print("Thanks for playing!")
break
else:
print("Invalid choice! Please select again.")
16
Output Screens
17
If someone enters the wrong option it will show the correct answer.
I can also see the high scores after finishing the game.
18
Limitations and Future Scope
❖ Limitations:-
• Only one player can play at a time.
• It does not provide a timing system.
• The number of questions are limited.
❖ Future Scope:-
• The number of player can be more than one at a time.
• Timing system can be provided.
• Many more interesting questions can be generated through AI
19
Requirements
❖ Hardware required:-
❖ Software required:-
20
Bibliography
1. www.wikipedia.com
2. www.slideshare.net
3. www.geeksforgeeks.org
4. www.google.com
5. Computer Science with Python by Peerthi Arora Class XIIth(Book)
21
Thank You.
22