()
| 54 | |
| 55 | # Generates question for the user |
| 56 | def 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 |
| 79 | def generate_answer(num): |
no test coverage detected