Python provides a standard GUI framework Tkinter which is used to develop fast and easy GUI applications. Here we will be developing a simple multiple-choice quiz in python with GUI. We will be creating a multiple choice quiz in Python with Tkinter. First, we will create a library named Quiz in the directory of your preference. Overview Steps Needed 1. We will create data.json for storing the data The data for the quiz is defined in data.json with JSON data which are name/value pairs and contain an array of values. We have defined sample data for the quiz as shown below : { "question": [ "Q1. What Indian city is the capital of two states?", "Q2. Which city is the capital of India?", "Q3. Smallest State of India?", "Q4. Where is Taj Mahal Located?" ], "answer": [ 1, 2, 3, 2 ], "options": [ ["Chandigarh", "Kolkata", "Delhi", "Bangalore" ], ["Jaipur", "Delhi", "Chennai", "Mumbai" ], ["Rajasthan", "Punjab", "Goa", "Bihar" ], ["Lucknow", "Agra", "Bhopal", "Delhi" ] ] } 2. Creating the GUI using Tkinter in quiz.py
Note: Both the data.json and the quiz.py will be created in the same directory that we have defined above. Now that we have created the data.json file for storing the data we are going to create quiz.py file which will contain the program for the quiz. Python3
|