Programming Assignment 2 (1)
Programming Assignment 2 (1)
Dimitri Didmanidze
Due: November 1, 2023
Abstract
In this programming assignment, we will use the concepts of variable declaration, arith-
metic operations, container data types, built in functions, user defined functions and work on
strings.
1 Summary
This assignment consists of 1 programming task. Developing a command-line quiz game. The
player will be presented with a series of multiple-choice questions. After answering all the ques-
tions, the program should display the number of correct answers and the player’s percentage
score.
2 Assignment
2.1 Define Your Data Structure
1. Create a list named questions. This list will store each question as a dictionary.
2. Each dictionary should have three key-value pairs: ”question”: The text of the question,
”options”: A list of answer choices, ”answer”: The correct answer.
1. display_question This function should: Display the question to the user, List out the
multiple-choice options.
2. get_player_answer This function should: Prompt the player to input their answer choice
(using the index number). Check if the input is valid (i.e., is a number and corresponds to
an option). If invalid, prompt the player again until a valid input is received. Return the
player’s answer choice.
3. calculate_score This function should: Calculate the percentage score based on the number
of correct answers. Return the percentage score.
3. After the loop, calculate the player’s percentage score, Display the total number of questions,
how many the player answered correctly, and their percentage score.
1
2.4 General Guidelines
1. Write comments in your code. This will help you understand your own logic and make it
clear for others reading your code.
2. Ensure that the program handles unexpected inputs gracefully. For example, if the player
inputs a letter instead of a number, or a number not corresponding to any option, the
program shouldn’t crash. Instead, it should prompt the player to try again.
3 Evaluation Criteria
The assignment will be graded according to the following criteria:
1. Functionality: Does the program run without errors and produce the expected outputs?
2. Syntax: Proper usage of data structures, variables, IO, conditional statements, loops and
functions.
3. Code Clarity: Following PEP 8 guidelines, using descriptive variable names, and proper
structuring of code.