You are on page 1of 19

A lab project report on

“QUIZ USING BASIC PYTHON”


Submitted as a part of

Python Programming Lab


Submitted by

S. No Name Roll number

1 K.SURENDER BABU 21311A04G5

Under the supervision of


Dr. Latha sahukar
Assistant professor
ECE department

Department of Electronics & Communication Engineering


Sreenidhi Institute of Science & Technology
(An Autonomous Institution affiliated to
JNTUH) Yamnampet, Ghatkesar, Hyderabad
– 501301. (2023-24)

Sreenidhi Institute of Science and Technology

Yamnampet, Ghatkesar, Hyderabad, 501 301

1
CERTIFICATE

This is to certify that the lab project report on “ QUIZ USING BASIC PYTHON” in
python submitted by K.SURENDER BABU (21311A04G5) is a record of boanfide work
carried out by them in the academic year 2023-24 under our guidance and evaluation.

2
Declaration and Acknowledgement

We hereby declare that the work described to “QUIZ USING BASIC PYTHON” submitted
by us is the work on our own effort and has not been submitted elsewhere.

We are thankful to Dr. Latha sahukar madam, Assistant Professor, ECE Department,
Sreenidhi Institute of Science and Technology, Yamnampet, Ghatkesar, for providing the
initiative to this report and giving us valuable and timely suggestions for our work.

We convey our sincere thanks to Dr. S. P. V. Subba Rao sir, Head of the Department (ECE),
Sreenidhi Institute of Science and Technology, Yamnampet, Ghatkesar, for his kind
cooperation in the completion of this work.

We even convey our sincere thanks to Prof. C. V. Tomy sir, Executive Director and Dr. T.
Ch.
Siva Reddy sir, Principal, Sreenidhi Institute of Science and Technology, Yamnampet,
Ghatkesar, for their kind cooperation in the completion of the lab project report on
generating QR code using Python.

Finally, we extend our gratitude to all teachers, non-teaching staff, friends and family, who
helped us complete this project directly or indirectly.

Place:Hyderabad

Submitted by:K.SURENDER

3
INDEX

S. No Description Page No.

1 Description 6

2 Program 6

3 Output of the Program 10

4 Explanation 12

5 Example model 13

6 Step by Step process 13

7 Limitations 14

8 Future advancements 14

9 Conclusion 14

10 References 15

4
DESCRIPTION
This project is all about a quiz which is developed using basic python programming like if, else
statements. This is the program of quiz game which test our IQ. First statement for greeting
(Welcome). Asking for interest if player text "yes" i.e., only start. If player text "no" i.e., quit &
end the game. Initial score is equal to zero before starting answering the given questions. Display
questions from 1 to 10. For every question this python program automatically checks if the player
entered answer is correct or not if it corrects i.e., display correct else display in correct. If and only
if player answer is correct i.e., only score will be incremented else no change in score (no-negative
percentage). After completing all the 10 questions it displays how many questions do you attempt
correctly out of 10 and also display over-all percentage. Final statement ends with thanks greeting.

5
PROGRAM: -
def welcome_message():

print("WELCOME TO QUIZ! :) Nothing is impossible, the word itself says I am possible\


n\n\n")

def play_game():

gaming = input("Do you want to play? (yes/no) ")

if gaming.lower() != 'yes':

quit()

print("Okay! Let’s start the game :)\n\n")

def ask_question(question, correct_answer):

user_answer = input(question).lower() if

user_answer == correct_answer:

print("CORRECT\n")

return 1

else:

print("IN-CORRECT\n")

return 0

def display_result(score):

print("You got", str(score), "questions correct :)\n")

print("You got", str((score / 10) * 100), "%\n\n")

print("\t\t (: Thank you for Playing:)\n\n")

print("\t\t\t\t\t\t Project by K.SURENDER BABU")

LIBRARY FUNCTION:

import quiz_library

def main():

quiz_library.welcome_message()

quiz_library.play_game()

6
score = 0 # initial score

score += quiz_library.ask_question("1. python in Telugu? (Ans: Koṇḍaciluva) is it correct?


(yes/no) \n ", "yes")

score += quiz_library.ask_question("2. What will you actually find at the end of every
rainbow? (Single letter) \n ", "w")

score += quiz_library.ask_question("3. What belongs to you but gets used by everyone else
more than you? (Think) \n", "name")

score += quiz_library.ask_question("4. What goes up as soon as the rain comes down? (**)
\n", "umbrella")

score += quiz_library.ask_question("5. Which room has no walls? (Think)\n ",


"mushroom")

score += quiz_library.ask_question("6. Where is an ocean with no water? (^^ap) \n ",


"map")

score += quiz_library.ask_question("7. How many rings make up the Olympic Games


Symbol? (Number)\n ", "5")

score += quiz_library.ask_question("8. The water in the ocean is salty? (yes/no) \n ",


"yes")

score += quiz_library.ask_question("9. How many sides are there in a circle? (**) \n ",
"0")

score += quiz_library.ask_question("10. There are 5 apples in the bag. How many do you
have if you take away three apples? (number)\n ", "2")

quiz_library.display_result(score)

if __name__ == "__main__":

main()

7
OUTPUT: -

WEL-COME TO QUIZ! :) Nothing is impossible, the word itself says I am possible

Do you want to play?

yes

Okay! Let’s start the game :)

1.python in Telugu? (Ans: Koṇḍaciluva (is it correct i.e., type yes else no)

yes

CORRECT

2. What will you actually find at the end of every rainbow? (Single letter)

CORRECT

3.What belongs to you but gets used by everyone else more than you? (Think)

name

CORRECT

4.What goes up as soon as the rain comes down? (**) umbrella

CORRECT

5.Which room has no walls? (Think)

mushroom

CORRECT

8
6.Where is an ocean with no water? (^^ap)

map

CORRECT

7.How many rings make up the Olympic Games Symbol? (Number)

CORRECT

8.The water in the ocean is salty? (yes/no)

yes

CORRECT

9.How many sides are there in a circle? (**)

CORRECT

10.There are 5 apples in the bag. How many do you have if you take away three apples?
(number)

CORRECT

You got 10 questions correct :)

You got 100.0 %

(: Thank you for Playing :)

9
FLOWCHART:
+------------------+

| Start |

+------------------+

+----------+

| Display |

| Welcome |

| Message |

+----------+

+-------------+

| Ask User |

| to Play? |

+-------------+

10
+------------------+

| User's Choice |

| (yes/no) |

+------------------+

No | Yes

+---------+

| Quit |

+---------+

+---------------+

| Initialize |

| Score |

+---------------+

+---------------+

| Loop over |

| Questions |

+---------------+

V +---------------+

| Ask Question |

+---------------+

11
|

+---------------+

| Check Answer |

+---------------+

+---------------+

| Display |

| Result |

+---------------+

+----------------+

| Loop Complete |

+----------------+

+----------------+

| Display |

| Thank-You |

+----------------+

V +------------------+

| End |

12
EXPLAINATION: -

• This is the program of quiz game which test our IQ.


• First statement for greeting (Welcome).
• Asking for interest if player text "yes" i.e., only start.
• If player text "no" i.e., quit & end the game.
• Initial score is equal to zero before starting answering the given questions.

• Let’s start the game.


• Display questions from 1 to 10. For every question this python program automatically
checks if the player entered answer is correct or not if it corrects i.e., display correct
else display in correct.
• If and only if player answer is correct i.e., only score will be incremented else no
change in score (no-negative percentage).
• After completing all the 10 questions it displays how many questions do you attempt
correctly out of 10 and also display over-all percentage.
• Final statement ends with thanks greeting.

13
EXAMPLE MODEL: -

14
STEPS FOR EXECUTING THE PROGRAM

The program is saved in the following process:

1. Open the notepad in your laptop or desktop


2. Do not forget to download the IDE from the online which is used as interpreter to
executing the code.
3. Then start writing the code in the Notepad
4. NOTE: Write the program very carefully try to write it without errors and do the
follow the steps of program that are required in the python.
5. Then save the file with .py extension.
6. Open in IDE the file and execute in the program then you see the errors and work on
it.

15
LIMITATION
• The solutions to the questions in the quiz may be not actually know to the users.
• The programmer needs to have code the program without any syntax or logical errors.
• The users have no option to clear their response once they have submitted or entered
the answer to the question.
• The users cannot see the remaining questions without completing the recent question.
• The previous answers cannot be changed.

16
FUTURE ADVANCEMENTS
• Make it multiplayer - Try modifying this game so that more than one player can
enjoy this game at once. You can do this by simply adding an additional for loop
which will contain the names of the players and score of each player is stored
separately. The player with the highest score will win the game.

• Use MCQ format - Not just quiz, you can also use it conduct MCQ tests. All you
have to do is modify the print function to print the multiple answers and the player
will have to guess the right answer.

• Use an API - Make use of an interesting API to automatically fetch questions from
the web so you do not have to get into the hassle of creating the questions and
answers on your own.

17
CONCLUSION
From this project one can understand the basic operations used in the python programming.
Using those basic we can build a program. This is the project is basically a basic quiz which
is developed using if, else conditions and doing mathematical calculations for the average
score.

18
REFERENCES
Real Python. (2022, November 11). Build a Quiz Application With Python.

https://realpython.com/python-quiz-application/

GeeksforGeeks. (2022, April 20). Python - MCQ Quiz Game using Tkinter.

https://www.geeksforgeeks.org/python-mcq-quiz-game-using-tkinter/

19

You might also like