Загрузить файлы в «/»
This commit is contained in:
commit
d288c528d3
23
calculator.py
Normal file
23
calculator.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
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()
|
||||||
Loading…
Reference in New Issue
Block a user