gpt-4o-mini-2024-07-18· OpenAI WildChat-4.8M (AI2)
User: Привет Assistant: Привет! Как я могу помочь тебе сегодня? User: Напиши калькулятор…
- User
User: Привет Assistant: Привет! Как я могу помочь тебе сегодня? User: Напиши калькулятор на python Assistant:
- Assistant
Вот простой калькулятор на Python, который может выполнять основные операции: сложение, вычитание, умножение и деление.
def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): if y == 0: return "Ошибка: деление на ноль!" return x / y def calculator(): print("Выберите операцию:") print("1. Сложение") print("2. Вычитание") print("3. Умножение") print("4. Деление") while True: choice = input("Введите номер операции (1/2/3/4): ") if choice in ['1', '2', '3', '4']: num1 = float(input("Введите первое число: ")) num2 = float(input("Введите второе число: ")) if choice == '1': print(f"{num1} + {num2} = {add(num1, num2)}") elif choice == '2': print(f"{num1} - {num2} = {subtract(num1, num2)}") elif choice == '3': print(f"{num1} * {num2} = {multiply(num1, num2)}") elif choice == '4': print(f"{num1} / {num2} = {divide(num1, num2)}") next_calculation = input("Хотите выполнить еще один расчет? (да/нет): ") if next_calculation.lower() != 'да': break else: print("Неверный ввод. Пожалуйста, выберите операцию от 1 до 4.") if __name__ == "__main__": calculator()Этот код реализует консольный калькулятор. Пользователь выбирает операцию, вводит два числа, и программа выводит результат. Также программа спрашивает, хочет ли пользователь сделать еще один расчет.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- gpt-4o-mini-2024-07-18Compare side by side →
- gpt-4o-mini-2024-07-18Compare side by side →
- gpt-4o-mini-2024-07-18Compare side by side →
- gpt-4o-mini-2024-07-18Compare side by side →
- gpt-4o-mini-2024-07-18Compare side by side →
- gpt-4o-mini-2024-07-18Compare side by side →
- gpt-4o-mini-2024-07-18Compare side by side →
- gpt-4o-mini-2024-07-18Compare side by side →
- gpt-4o-mini-2024-07-18Compare side by side →
- gpt-4o-mini-2024-07-18Compare side by side →
- gpt-4o-mini-2024-07-18Compare side by side →