gpt-3.5-turbo-0613· OpenAI WildChat-4.8M (AI2)
напиши калькулятор на python
- User
напиши калькулятор на python
- 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 x / y else: return "На ноль делить нельзя!" print("Выберите операцию:") print("1. Сложение") print("2. Вычитание") print("3. Умножение") print("4. Деление") choice = input("Введите номер операции (1/2/3/4): ") num1 = float(input("Введите первое число: ")) num2 = float(input("Введите второе число: ")) if choice == "1": print(num1, "+", num2, "=", add(num1, num2)) elif choice == "2": print(num1, "-", num2, "=", subtract(num1, num2)) elif choice == "3": print(num1, "*", num2, "=", multiply(num1, num2)) elif choice == "4": print(num1, "/", num2, "=", divide(num1, num2)) else: print("Неверный выбор операции")Этот код позволяет пользователю выбрать операцию (сложение, вычитание, умножение или деление) и ввести два числа. Затем программа выполняет выбранную операцию и выводит результат на экран.
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-2024-08-06Compare side by side →
- gpt-4o-2024-08-06Compare side by side →
- gpt-4o-2024-08-06Compare side by side →
- gpt-4o-2024-08-06Compare side by side →
- grok-3-preview-02-24Compare side by side →
- command-a-03-2025Compare side by side →
- gpt-4o-mini-2024-07-18Compare side by side →
- gpt-4o-2024-08-06Compare side by side →
- gpt-4o-2024-08-06Compare side by side →
- gpt-4o-2024-08-06Compare side by side →