75.0k views
5 votes
Python Quiz Application using Lists and Dictionary

Instructions for creating a quiz using List:
Give some name to your quiz application. Example: Python Quiz Application
Enter some description for the application so that user can easily understand about your application
Ask the name from the user that would be displayed as a player name
Your quiz should have three different levels (Easy, Average, and Hard).
Example, the application can have following functions
easyLevel() function
averageLevel() function
hardLevel() function
Out of above given three levels, atleast one should be implemented by using lists and dictionary (any of the three levels, implement one with lists and second with dictionary). For third level, it’s your choice whether you want to do it using Lists or Dictionaries.
Each level should have atleast 10 questions with 4 options same as Assignment-1. Here you will use three lists/dictionaries (one with lists and second with dictionary, third is your choice) instead of simple print() command to optimise your code:
questionList/dictionary : Enter all your questions in question List/dictionary
choiceList/dictionary: Enter the options for all questions
correctAnswerList/dictionary: Enter the correct Answers in the list/dictionary
Using for loop iterate questionList/dictionary and choiceList/dictionary to print the questions and respective choices.
Ask the user to enter the choice. Further, you need to check the entered choices with the correct answers with the correctAnswerList/dictionary . The application should have a calculateResult variable that will be incremented by 1 every time if the user would enter correct answer for the question. However, there is no negative marking for any wrong answered question. Initialise calculateResult = 0
Use decision structures to switch between different levels. Further you need to create functions for every level.
Your application can have even more functions.
Note: User can enter the wrong choice as well, so you have a default case for every user choice that would display "invalid choice" message to user.
Further, you need to set a timer for your quiz and display it on the screen showing the time elapsed using the inbuilt modules either datetime or time

User Gwell
by
8.4k points

1 Answer

4 votes

Final answer:

To build a Python Quiz Application, one must create various difficulty levels, use lists and dictionaries to hold questions, options, and correct answers, and track scores. The implementation includes functions for each level, user input validation, and a quiz timer.

Step-by-step explanation:

To create a Python Quiz Application, start by defining a name and description for the application to help users understand its purpose. The application will feature three levels of difficulty: Easy, Average, and Hard. In one of these levels, use a list and in another a dictionary to manage questions, options, and correct answers. The third level's structure is at your discretion.

Each level should include at least 10 questions, each with 4 answer choices. Use loops to iterate through the questions and options, and prompt the user to select an answer. Compare user responses to the correct answers in your lists or dictionaries, incrementing the calculateResult variable for each correct answer, starting from zero. Utilize conditionals to navigate between the different levels of the quiz.

Implement functions like easyLevel(), averageLevel(), and hardLevel() to organize your application's structure, and handle cases of invalid user inputs. Additionally, incorporate a timer using modules such as datetime or time to track the duration of the quiz.

User Adam Berecz
by
8.3k points