0% found this document useful (0 votes)
9 views6 pages

Python Quiz Game Code Overview

The document contains a Python quiz game with three modules: Anagram, World, and Mental Maths, where players answer questions to earn points. Each module has specific questions and scoring rules, with penalties for incorrect answers. Additionally, there is a turtle graphics section that demonstrates how to draw a square using the Python turtle library.

Uploaded by

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

Python Quiz Game Code Overview

The document contains a Python quiz game with three modules: Anagram, World, and Mental Maths, where players answer questions to earn points. Each module has specific questions and scoring rules, with penalties for incorrect answers. Additionally, there is a turtle graphics section that demonstrates how to draw a square using the Python turtle library.

Uploaded by

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

Quiz Game coding in Python:

#angram module

def anagram():

points=0

print("Welcome to anagram room")

print("I am going to give you two anagram to solve")

print("Enter your answer in Uppercase letters only")

ans1=input("What kind of fruit PEPLA?")

if ans1=="APPLE":

print("Well done. You have gained 20 points.")

points=points+20

else:

print("Sorry wrong answer. Lose 5 points")

points=points-5

print("Enter your answer in lowercase letters only")

ans2=input("What kind of flower minjaes")

if ans2=="jasmine":

print("Well done. You scored 20 points")

points=points+20

else:

print("Sorry wrong answer. Lose 5 points")

points=point-5

print("Your total points=",points)

# World room module

def world():

print("Welcome to World room")

points=0

print("you have been transported to portugal")

print("Please type answers in capital letters only")


ans1=input("what is the capital city of Portugal?")

ans2=input("What is the currency used in Portugal?")

if ans1=="LISBON" and ans2=="EURO":

print("Well done: You have gained 30 points")

points=points+30

elif ans1=="LISBON" or ans2=="EURO":

print("One answer is correct. You have gained 15 points.")

points=points+15

else:

print("Sorry wrong answers Lose 5 points.")

points=points-5

print("you have been transported to USA")

print("Please type answers in capital letters only")

ans1=input("what is the capital city of USA?")

ans2=input("What is the currency used in USA?")

if ans1=="WASHINGTON" and ans2=="DOLLAR":

print("Well done: You have gained 30 points")

points=points+30

elif ans1=="WASHINGTON" or ans2=="DOLLAR":

print("One answer is correct. You have gained 15 points.")

points=points+15

else:

print("Sorry wrong answers Lose 5 points.")

points=points-5

print("Your total points=",points)

#Mental maths module

def mentalmaths():

points=0

print("Welcome to Mental Maths room")


print("you will be askesd a mental arithmetic questions:")

num1=[Link](1,10)

num2=[Link](1,10)

crctanswer=num1+num2

print("What is", num1,"plus", num2)

ans1=int(input("Enter your answer here:"))

if ans1==crctanswer:

print("Well done you have gained 20 points")

points=points+20

else:

print("Sorry that is wrong answer. you lose 5 points")

points=points-5

num1=[Link](1,10)

num2=[Link](1,10)

crctanswer=num1+num2

print("What is", num1,"*", num2)

ans1=int(input("Enter your answer here:"))

if ans1==crctanswer:

print("Well done you have gained 20 points")

points=points+20

else:

print("Sorry that is wrong answer. you lose 5 points")

points=points-5

print("Your total points=",points)

#Game Welcome module

def welcome():

print("Welcome to my program")

print(name,"Please choose a puzzle room to enter.")

print("1. The Anagram Room\n 2. The World Room\n 3. The Mental Maths
room ")

choice=input("Enter your choice 1/2/3 now:")

if choice == '1':

score=anagram()

elif choice=='2':

score=world()

else:

score=mentalmaths()

import random

print(" WELCOME TO THE QUIZ GAME")

name=input("enter your name:")

age=int(input("enter your age:"))

minage=8

if age<8:

print("sorry you are too young to play this game ")

else:

print("Let the game begin")

welcome()

Write a Python Program to draw a square using Python turtle library

import turtle

[Link](3)

[Link](100)

[Link](90)

[Link](100)

[Link](90)

[Link](100)

[Link](90)

[Link](100)
[Link](90)

Quiz Game coding in Python:

#angram module

def anagram():

points=0

print("Welcome to anagram room")

print("I am going to give you two anagram to solve")

print("Enter your answer in Uppercase letters only")

ans1=input("What kind of fruit PEPLA?")

if ans1=="APPLE":

print("Well done. You have gained 20 points.")

points=points+20

else:

print("Sorry wrong answer. Lose 5 points")

points=points-5

print("Enter your answer in lowercase letters only")

ans2=input("What kind of flower minjaes")

if ans2=="jasmine":

print("Well done. You scored 20 points")

points=points+20

else:

print("Sorry wrong answer. Lose 5 points")

points=point-5

print("Your total points=",points)

# World room module

def world():

Common questions

Powered by AI

The function-based architecture contributes to easier code maintenance by encapsulating different parts of the game logic within functions, making the codebase more organized and manageable. Each function represents a discrete unit of the game, such as handling the quiz logic for a specific room. This separation allows for individual modifications without affecting the entire program structure. Debugging and updating are more straightforward, as isolated functions can be adjusted or fixed independently .

The quiz game utilizes modular programming by defining distinct functions for each room, such as 'anagram,' 'world,' and 'mentalmaths.' This modularity allows each part of the game to be developed, tested, and modified independently. It enhances code reusability, readability, and maintainability. For example, changes to the anagram room logic do not affect the mental maths room, and new modules can be added without interfering with the existing setup .

User feedback in the quiz game is primarily delivered through print statements, which immediately inform players of their performance after each question. This direct and swift feedback loop maintains engagement, reinforces correct responses, and allows players to learn from mistakes by adjusting their strategies in real-time. While functional, this approach could be enhanced with more sophisticated feedback mechanisms such as hints or explanations for wrong answers, encouraging learning and adaptation .

To enhance the replayability of the quiz game, strategies could include adding a larger pool of questions to reduce repetition, dynamically adjusting difficulty levels based on player performance, and introducing new thematic rooms. Implementing a scoring leaderboard and achievement system could engage competitive and goal-oriented players. Additionally, incorporating personal feedback and hints based on past performances can encourage improvement and repeated play .

The use of random number generation in the Mental Maths room enriches the gaming experience by providing variety and unpredictability in arithmetic challenges. By generating random numbers for mathematical problems, the game ensures that each question is unique, preventing memorization and encouraging genuine mental computation skills. This variability keeps players engaged and tests their ability to quickly solve different problems under pressure .

The game's age-check mechanism, which restricts participation to those ages 8 and above, aims to tailor content to an audience capable of handling the cognitive challenges presented. However, this could impact inclusivity by excluding younger players who might be interested or capable, especially those who excel beyond their age group. It also sets a lower skill threshold, which may not fully represent the diverse cognitive abilities of children under 8 .

Designing a quiz game with separate modules focused on different areas such as geography, language through anagrams, and mental arithmetic offers diverse educational benefits. It promotes learning in multiple disciplines, enhances cognitive flexibility, and improves problem-solving skills. The geography module expands geographical knowledge, the anagram section boosts language and pattern recognition skills, and the mental arithmetic module strengthens mathematical reasoning and computation abilities .

The quiz game code handles errors primarily by guiding user input through clear instructions, such as specifying uppercase or lowercase input. However, the code lacks robust error handling for invalid inputs like non-string responses or out-of-bound selections for the room choice. It focuses more on straightforward if-else logic to manage correct or incorrect answers, with feedback provided directly through print statements but without complex exception handling for user input errors .

Providing specific instructions for input formats in a quiz game is important to ensure that the program correctly interprets users' responses. This prevents misunderstandings due to input variations and allows for accurate assessment of answers. The game specifies the use of uppercase for certain answers to avoid errors related to case sensitivity in string comparisons, thus enhancing user experience and fairness in scoring .

The quiz game is designed with several modules, each representing a different themed room such as the Anagram Room, World Room, and Mental Maths Room. In each room, players are presented with different types of questions and challenges. The players have chances to answer questions in one room and accumulate points, which they carry over to subsequent rooms. The design uses conditional checks and point updates to ensure multiple attempts at getting correct answers and accrue points, thereby encouraging continuous engagement across different sections of the game .

You might also like