Beispiel #1
0
def generate_round():
    first_number = generate_random_number(10, 15)
    second_number = generate_random_number(10, 10)
    operator = choice(OPERATORS)
    question = '{} {} {}'.format(first_number, operator, second_number)
    correct_answer = calculate(first_number, second_number, operator)
    return {'question': question, 'correct_answer': str(correct_answer)}
Beispiel #2
0
def generate_task():
    first_num = generate_random_number()
    second_num = generate_random_number()
    sign, operation = random.choice(ARITHMETIC_OPERATIONS)
    question = "{} {} {}".format(first_num, sign, second_num)
    correct_answer = str(operation(first_num, second_num))
    return (question, correct_answer)
def generate_round():
    first_number = generate_random_number(0, 12)
    second_number = generate_random_number(0, 15)
    question = '{} {}'.format(first_number, second_number)
    correct_answer = gcd(first_number, second_number)
    return {
        'question': question,
        'correct_answer': str(correct_answer)
    }
Beispiel #4
0
def generate_round():
    progression_step = generate_random_number(0, 20)
    progression_start = generate_random_number(0, 100)
    progression_length = generate_random_number(5, 10)
    numbers = generate_progression(progression_start, progression_step,
                                   progression_length)
    hidden_index = generate_random_number(0, len(numbers) - 1)
    return {
        'question': get_question(numbers, hidden_index),
        'correct_answer': str(numbers[hidden_index])
    }
def generate_round():
    number = generate_random_number(0, 20)
    correct_answer = 'yes' if is_even(number) else 'no'
    return {
        'question': str(number),
        'correct_answer': correct_answer
    }
Beispiel #6
0
def generate_task():
    first_element = generate_random_number()
    common_difference = generate_random_number(MIN_COMMON_DIFFERENCE)
    hidden_element_index = generate_random_number(
        MIN_PROGRESSION_INDEX,
        MAX_PROGRESSION_INDEX
    )

    sequence = []
    sequence_with_hidden_element = []
    for i in range(PROGRESSION_LENGTH):
        element = first_element + common_difference * i
        sequence.append(element)
        if i == hidden_element_index:
            sequence_with_hidden_element.append("..")
        else:
            sequence_with_hidden_element.append(element)

    correct_answer = str(sequence[hidden_element_index])
    question = " ".join(list(map(str, sequence_with_hidden_element)))
    return (question, correct_answer)
def generate_task():
    first_num = generate_random_number()
    second_num = generate_random_number()
    question = "{} {}".format(first_num, second_num)
    correct_answer = str(gcd(first_num, second_num))
    return (question, correct_answer)
Beispiel #8
0
def generate_task():
    question = generate_random_number()
    correct_answer = "yes" if is_prime(question) else "no"
    return (question, correct_answer)