Introduction Are you ready to put your Python knowledge to the test? This simple Python quiz app challenges you with five multiple-choice questions on Python programming.
Five Multiple-Choice Questions: Each question has four options.
One Correct Answer per Question: Choose the correct option from (a), (b), (c), or (d).
Score Calculation: The app calculates your total score out of five.
Performance Feedback: Based on your score, you receive personalized feedback.
View Correct Answers: After completing the quiz, you can review the correct answers.
When you run the script, you’ll see the quiz instructions and be prompted to enter ‘yes’ to start. You’ll be asked to provide your name and login ID before beginning the quiz.
For each question, type your answer and press Enter. At the end of the quiz, your score is displayed, and you receive feedback based on your performance. If you wish, you can view the correct answers.
Here’s how the quiz works under the hood:
The quiz app utilizes a Question class to store the question prompt and the correct answer.
A list of Question objects is created, each containing a question and its respective correct answer.
The run_test() function loops through the questions, asks the user for input, and checks if their response is correct.
After answering all five questions, the user receives their total score, and based on it, they get one of the following messages:
0-2 correct answers: “Try again, Keep yourself updated”
3-4 correct answers: “WELL DONE!!”
5 correct answers: “EXCELLENT!!”
If the user wants, they can type ‘yes’ to see the correct answers after completing the quiz.
Submitted by Preetam Ashokkumar Patel (Preetam100832)
Download packets of source code on Coders Packet
Comments