Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1f64385

Browse files
Merge pull request avinashkranjan#2268 from ishita-43/master
Quiz_Game
2 parents b2a36b2 + cc86e77 commit 1f64385

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

‎Quiz_Game/Readme.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
# Quiz Game
3+
4+
This project is to create an Quiz Game using python in which the user can answer the question and view there score using list data-structure and functions.
5+
6+
List for storing the data and functions for defining there logic of game playing.
7+
8+
## Usage
9+
10+
* Copy the code to your system.
11+
12+
* Run the code on python terminal and enjoy the game.
13+
14+
## Output
15+
16+
User can view there score in the end and can also play the game again.
17+
18+
ScreenShot[https://i.postimg.cc/Kj6gNbM1/Select-C-Windows-py-exe-18-07-2023-23-03-08.png]
19+
20+
## Author
21+
22+
Written by [ishita-43](https://www.github.com/ishita-43)
23+
24+
The project was built as a contribution during [GSSOC'23](https://gssoc.girlscript.tech/).

‎Quiz_Game/quiz.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
2+
# List of questions for quiz
3+
4+
questions =[
5+
'who is the developer of Python Language',
6+
'when did india gets independence',
7+
'what is the Indian currency',
8+
'Who is World first cloned human baby',
9+
'who is the founder of Hinduism'
10+
]
11+
12+
# list of answers for above questions
13+
14+
answers = [
15+
'Guido Van',
16+
'1947',
17+
'INR',
18+
'Eve',
19+
'No Specific'
20+
]
21+
22+
# List of options for above questions
23+
24+
options= [
25+
['Dennis Ritchie','Alan Frank','Guido Van','Albert'],
26+
['1947','1995','1950','1957'],
27+
['DOLLARS','YEN','EURO','INR'],
28+
['Erik','Maria','Sophie','Eve'],
29+
['Mahavira Swami','Mahatma Buddha','No Specific','Prophet Mohammed']
30+
]
31+
32+
# Quiz Game | Designed by Ishita
33+
34+
# Defining function for game playing
35+
36+
def play_game(username,questions,answers,options):
37+
print("Hello,", username, "welcome to the QUIZ game")
38+
print("All the Best for the Game :>")
39+
score = 0
40+
for i in range(5):
41+
current_questions = questions[i]
42+
# print(questions[i])
43+
correct_answer = answers[i]
44+
current_question_options = options[i]
45+
print("Questions:" ,current_questions)
46+
for index,each_options in enumerate(current_question_options):
47+
print(index+1,") ",each_options,sep='')
48+
user_answer_index = int(input("Please enter your choice(1,2,3,4): "))
49+
user_answer = current_question_options[user_answer_index-1]
50+
if user_answer== correct_answer:
51+
print("correct answer")
52+
score = score +100
53+
else:
54+
print("wrong answer")
55+
break
56+
print("Your final score is", score)
57+
return username,score
58+
59+
# Defining function for viewing the score
60+
61+
def view_scores(names_and_scores):
62+
for name,score in names_and_scores.items():
63+
print(name,"has scored",score)
64+
65+
# Defining the function for start of the score
66+
67+
def quiz(questions,answers,options):
68+
names_and_scores = {}
69+
while True:
70+
print("Welcome to the quiz game")
71+
print("1) Play\n2) View Scores\n3) Exit")
72+
choice=int(input("Please enter your choice: "))
73+
if choice == 1:
74+
username =(input("Please enter your name: "))
75+
username,score = play_game(username,questions,answers,options)
76+
names_and_scores[username] = score
77+
elif choice ==2:
78+
view_scores(names_and_scores)
79+
elif choice ==3:
80+
break
81+
else :
82+
print("Your choice is not correct")
83+
84+
# Program execution starts from here
85+
86+
quiz(questions,answers,options)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /