Предмет: Информатика, автор: daniilvoda5

Створити тренажер виконання дії
додавання з двоцифровими числами.

У вікні випадковим чином з’являється
приклад, відповідь на який необхідно
ввести у текстове поле. Після
натискання кнопки Перевірити з’
являється повідомлення про
правильність виконання прикладу.
Кнопка Наступний приклад виводить
інший приклад. Завдання, що містять
математичні вирази генеруються
випадковим чином.
ДАЮ 100 БАЛОВ

Ответы

Автор ответа: pisarkovoleksij
1

Ответ:

Для створення тренажера додавання з двоцифровими числами можна використовувати наступний код на мові Python з використанням бібліотеки tkinter:

python

import random

import tkinter as tk

# створюємо вікно програми

root = tk.Tk()

root.title("Тренажер додавання")

# створюємо функцію для генерації нового прикладу

def generate_example():

    # генеруємо два випадкових числа від 10 до 99

    num1 = random.randint(10, 99)

    num2 = random.randint(10, 99)

    # записуємо відповідь на приклад

    answer = num1 + num2

    # повертаємо приклад та відповідь у вигляді рядка

    return f"{num1} + {num2} =", answer

# створюємо функцію для перевірки відповіді на приклад

def check_answer():

    # отримуємо введену користувачем відповідь

    user_answer = int(entry.get())

    # перевіряємо, чи співпадає вона з правильною відповіддю

    if user_answer == current_answer:

        result_label.config(text="Правильно!")

    else:

        result_label.config(text="Неправильно!")

# створюємо функцію для відображення нового прикладу

def new_example():

    # генеруємо новий приклад

    example, answer = generate_example()

    # зберігаємо правильну відповідь у змінній

    global current_answer

    current_answer = answer

    # оновлюємо текст на екрані з новим прикладом

    example_label.config(text=example)

    result_label.config(text="")

# створюємо елементи інтерфейсу користувача

example_label = tk.Label(root, text="")

example_label.pack()

entry = tk.Entry(root)

entry.pack()

check_button = tk.Button(root, text="Перевірити", command=check_answer)

check_button.pack()

result_label = tk.Label(root, text="")

result_label.pack()

next_button = tk.Button(root, text="Наступний приклад", command=new_example)

next_button.pack()

# викликаємо функцію для генерації першого прикладу

new_example()

# запускаємо головний цикл програми

root.mainloop()

Цей код створює вікно програми з елементами інтерфейсу користувача: міткою для прикладу, текстовим полем для введення відповіді, кнопкою для перевірки відповіді, міткою для відображення результату перевірки та кнопкою для генерації нового прикладу. При запуску програми генерується перший приклад, а при натисканні на кнопку "Наступний приклад" генерується новий приклад. При натисканні на кнопку "Перевірити" програма перевіряє введену користувачем відповідь і виводить результат перевірки на екран.

Похожие вопросы
Предмет: Английский язык, автор: calpac533
Найдите в тексте предложения в страдательном залоге.

Great Britain


Some English customs and traditions are famous all over the world. Tea and


talking about the weather, for example. England is a land rich with traditions


ranging from wassailing to special holiday events and superstitions.


In Great Britain there is no written constitution, only customs, traditions and


precedents. Traditionally the Queen reigns but does not rule.


English people have traditions not only in political, but in social life. They like to spend their free time in pubs where they can have a glass of beer and talk about different things their friends.


A typical feature of an English house is a fireplace, even when there is central heating in house. Many families have pets — a dog, a


cat or a bird.


Politeness is a characteristic feature of English people. They often say "Thank you", "Sorry", "Beg your pardon".


Australia


Many Australians come together on St Patrick's Day to celebrate Irish culture and remember St Patrick. Some organizations hold St Patrick's Day breakfasts and lunches where lucky draw prizes are given and Irish food and drinks are served. On St Patrick's Day parades people wear traditional Irish costumes or dress in green.


Ireland


Many families prepare their homes for Easter Sunday by doing "spring cleaning" to prepare the house for blessing by the local priest which is a religious ceremony that dates back hundreds of years.


Canada


Canadian culture reflects a heavy influence of British, American and Aboriginal culture and traditions. For example, according to Canadian prairie etiquette, if On St Patrick's Day parades people wear traditional Irish costumes, you must return the plate dirty; washing it will bring bad luck.


New Zealand


Church weddings are the most traditional marriage celebrations in New Zealand.


according to custom, the groom should not see the bride before she joins him at the


front of the church on their wedding day. The Maori wedding ceremony is conducted by a tribal elder and the couple is blessed in the Maori language. Wedding rings made carved bone are also popular amongst those wishing to include the ancient culture in their wedding.
Предмет: Математика, автор: shevchenko200419