-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestion.py
More file actions
25 lines (22 loc) · 871 Bytes
/
question.py
File metadata and controls
25 lines (22 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import random
class Question:
answer_symbols = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p"]
def __init__(self, question_text, category=None, *answers:list, question_img=None):
"""
question_text: a string
answers: a list of strings
question_img: a string
"""
self.question_text = question_text
self.question_img = question_img
random.shuffle(answers)
self.answers = answers
self.category = category
def show_question(self):
"""Call this function to display the question"""
# Show question text
if self.question_img is not None:
pass # Show image
for i, answer in self.answers:
answer_text = "{}. {}".format(Question.answer_symbols[i], answer)
# Show answer text