CS Sub 3
CS Sub 3
ANIMAL QUIZ
Done by:
Akshay kannaa
Class : 12-B1
Contents
s.no
Description
1.
INTRODUCTION
2.
OBJECTIVE
3.
SOURCE CODE
4.
OUTPUT
5.
RESULT
6.
BIBLIOGRAPHY
PROJECT ON ANIMAL QUIZ
INTRODUCTION
This article, I’ll walk you through how to create a quiz game with Python. I will create an
animal quiz here
. This quiz game uses a function; a block of code with a name that performs a specific
task. A function allows you to use the same code several times, without having to type
everything each time. Python has a lot of built-in functions, but it also allows you to
create your functions.
OBJECTIVE
The Quiz game asks the player questions about animals. They have three chances to
answer each question you don’t want to take the quiz too difficult. Each correct answer
will score a point. At the end of the game, the program will reveal the player’s final score.
SOURCE CODE
check_guess(guess, answer):
global score still_guessing = True
attempt = 0 while still_guessing and
attempt < 3: if guess.lower() ==
answer.lower():
print("Correct Answer")
score = score + 1
still_guessing = False
else: if attempt < 2:
guess = input("Sorry Wrong Answer, try again")
attempt = attempt + 1 if attempt == 3:
print("The Correct answer is ",answer )
score = 0 print("Guess
the Animal")
guess1 = input("Which bear lives at the North Pole? ")
check_guess(guess1, "polar bear") guess2 =
input("Which is the fastest land animal? ")
check_guess(guess2, "Cheetah") guess3 =
input("Which is the larget animal? ")
check_guess(guess3, "Blue Whale") print("Your Score
is "+ str(score))
OUTPUT
RESULT
Thus the python program has been executed successfully and the output is verified.
BIBLIOGRAPHY
• http://python.mykvs.in/projects.php