calculator2/ffggf.py

29 lines
1.0 KiB
Python

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