MCPcopy Create free account
hub / github.com/ndleah/python-mini-project / generate_question

Function generate_question

GK_Maestro/main.py:56–76  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54
55# Generates question for the user
56def generate_question():
57 # List the question numbers and their difficulty level
58 easy_qlist = [2, 3, 4, 8, 9, 14, 15, 16]
59 hard_qlist = [1, 5, 6, 7, 10, 11, 12, 13]
60
61 # Choose a random value - 1 or 2
62 difficulty = randint(1, 2)
63
64 # Difficulty level: easy
65 if difficulty == 1:
66 # Select a random question from the choices
67 random_choice = choice(easy_qlist)
68 ques = easy_question(random_choice)
69 # Difficulty level: hard
70 elif difficulty == 2:
71 # Select a random question from the choices
72 random_choice = choice(hard_qlist)
73 ques = hard_question(random_choice)
74
75 # Return question number and the question
76 return random_choice, ques
77
78# Generate and match answer of the user
79def generate_answer(num):

Callers 1

mainFunction · 0.85

Calls 2

easy_questionFunction · 0.90
hard_questionFunction · 0.90

Tested by

no test coverage detected