|
1 | 1 | from random import randint |
2 | 2 |
|
3 | 3 |
|
4 | | -def progress(first, step, empty): # создает арифметическую прогрессию |
5 | | - temp = '' |
| 4 | +# функция создает арифметическую прогрессию |
| 5 | +def generating_a_progression(first: int, step: int, empty: int) -> str: |
| 6 | + question = '' |
6 | 7 | for i in range(1, 11): |
7 | 8 | if i == empty: |
8 | | - temp += '.. ' |
| 9 | + question += '.. ' |
9 | 10 | else: |
10 | | - temp += str(first + step * (i - 1)) + ' ' |
11 | | - temp = temp.strip() |
12 | | - return (temp) |
| 11 | + question += str(first + step * (i - 1)) + ' ' |
| 12 | + question = question.strip() |
| 13 | + return (question) |
13 | 14 |
|
14 | 15 |
|
15 | | -rules = "What number is missing in the progression?" |
16 | | -questions = [] |
17 | | -right_answer = [] |
18 | | -for _ in range(3): |
19 | | - first = randint(2, 50) |
20 | | - step = randint(2, 20) |
21 | | - empty = randint(1, 10) |
22 | | - right_answer.append(str(first + step * (empty - 1))) |
23 | | - questions.append(progress(first, step, empty)) |
| 16 | +def displays_rules_game(): |
| 17 | + print("What number is missing in the progression?") |
| 18 | + |
| 19 | + |
| 20 | +def generating_question_and_answer(): |
| 21 | + LEN_PROGRESSION = 10 |
| 22 | + MIN_GEN_RANGE = 1 |
| 23 | + MAX_GEN_RANGE = 50 |
| 24 | + # |
| 25 | + first_element = randint(MIN_GEN_RANGE, MAX_GEN_RANGE) |
| 26 | + step = randint(MIN_GEN_RANGE, MAX_GEN_RANGE) |
| 27 | + index_of_missing_element = randint(MIN_GEN_RANGE, LEN_PROGRESSION) |
| 28 | + # |
| 29 | + answer = str(first_element + step * (index_of_missing_element - 1)) |
| 30 | + question = '' |
| 31 | + for i in range(LEN_PROGRESSION): |
| 32 | + if i + 1 == index_of_missing_element: |
| 33 | + question += '.. ' |
| 34 | + else: |
| 35 | + question += str(first_element + step * i) + ' ' |
| 36 | + question = question.strip() |
| 37 | + return ((question, answer)) |
0 commit comments