DEV Community

Carlos Gamez
Carlos Gamez

Posted on

Python Quiz Program: Building Blocks of My Portfolio

I wanted to create a simple yet functional program to showcase the foundational skills I have acquired. This program, a quiz generator and taker, exemplifies my grasp of Python basics such as classes, file handling, and user input. The idea behind this project is to have an interactive way to create, save, and take quizzes, providing a practical demonstration of my programming abilities.

Screenshot of quiz creator run

Screenshot of quiz taker run

The program revolves around two main classes: User and Question. The User class stores the user's data, including their username, role (quiz creator or taker), and their quiz performance. The Question class defines each quiz question, supporting both multiple-choice and true/false formats. The program allows users to create and save quizzes, which are stored as JSON files for future use. Quiz takers can then load these questions and interactively answer them, with the program providing immediate feedback and tracking their performance.

Here's a breakdown of the key components:

  • User Class: Initializes user data and tracks quiz performance.
  • Question Class: Handles the creation of questions, including asking and evaluating responses. The multiple-choice options are shown in a random order each time.
  • create_user(): Gathers user information and determines their role.
  • create_questions(): Allows quiz creators to input and save questions.
  • save_questions(): Saves created questions to a JSON file.
  • use_saved_questions(): Loads questions from a JSON file for the quiz taker.
  • main(): Integrates all functions, guiding the user through creating or taking a quiz based on their role.

This quiz program is a small yet significant step in my journey to mastering Python. By developing this project, I have reinforced my understanding of fundamental programming concepts and file handling in Python.

For those interested in exploring the code further or providing feedback, the full code is available on my GitHub repository: GitHub - nice-try. Your suggestions and insights are highly appreciated as I continue to learn and grow as a developer.

Top comments (0)