Напиши простой код на основе которорго можно будет обучить ученика использовать функции…
- User
Напиши простой код на основе которорго можно будет обучить ученика использовать функции в python, дай мне только код, без комментариев
Assistant
def greet(name): print("Привет, " + name + "!") greet("Анна") greet("Иван") def add(a, b): return a + b result = add(3, 5) print("Результат сложения:", result) def multiply(x, y): return x * y print("Произведение:", multiply(4, 7)) def calculate(operation, a, b): if operation == "add": return add(a, b) elif operation == "multiply": return multiply(a, b) else: return "Неизвестная операция" print("Вычисление:", calculate("add", 10, 20)) print("Вычисление:", calculate("multiply", 10, 20))
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.