24 lines
740 B
Python
24 lines
740 B
Python
def calculator():
|
|
print("Выберите операцию:")
|
|
print("1. Сложение")
|
|
print("2. Умножение")
|
|
|
|
choice = input("Введите номер операции (1/2): ")
|
|
|
|
if choice in ['1', '2']:
|
|
num1 = float(input("Введите первое число: "))
|
|
num2 = float(input("Введите второе число: "))
|
|
|
|
if choice == '1':
|
|
result = num1 + num2
|
|
operation = "Сложение"
|
|
else:
|
|
result = num1 * num2
|
|
operation = "Умножение"
|
|
|
|
print(f"Результат {operation}: {result}")
|
|
else:
|
|
print("Некорректный ввод.")
|
|
|
|
calculator()
|