0% found this document useful (0 votes)
0 views2 pages

Programming Assignment 2 (1)

This programming assignment involves creating a command-line quiz game that presents multiple-choice questions to the player. The game requires defining a data structure for questions, implementing functions to display questions, get player answers, and calculate scores, while ensuring proper input validation. The assignment will be evaluated based on functionality, syntax, and code clarity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views2 pages

Programming Assignment 2 (1)

This programming assignment involves creating a command-line quiz game that presents multiple-choice questions to the player. The game requires defining a data structure for questions, implementing functions to display questions, get player answers, and calculate scores, while ensuring proper input validation. The assignment will be evaluated based on functionality, syntax, and code clarity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Programming Assignment - 2

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.

2.2 Implement Game Functions


You need to come up with the function arguments and return types yourself.

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.

2.3 Make the game loop incorporating previously defined functions


1. Use a loop to iterate over the questions.
2. For each question: display the question, get the player’s answer, check if the answer is
correct, increment the 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.

You might also like