Загрузить файл в "calculyator"
This commit is contained in:
commit
24ac880e1a
28
calculator.py
Normal file
28
calculator.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
while True:
|
||||||
|
print("Выбери действие:")
|
||||||
|
print("1 - сложение")
|
||||||
|
print("2 - умножение")
|
||||||
|
print("0 - выход")
|
||||||
|
|
||||||
|
choice = input("Ваш выбор: ")
|
||||||
|
|
||||||
|
if choice == "0":
|
||||||
|
print("Выход из программы.")
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
numbers = input("Введите числа через пробел: ").split()
|
||||||
|
numbers = [float(x) for x in numbers]
|
||||||
|
|
||||||
|
if choice == "1":
|
||||||
|
result = sum(numbers)
|
||||||
|
print("Результат сложения:", result)
|
||||||
|
|
||||||
|
elif choice == "2":
|
||||||
|
result = 1
|
||||||
|
for num in numbers:
|
||||||
|
result *= num
|
||||||
|
print("Результат умножения:", result)
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("Неизвестная команда!")
|
||||||
Loading…
Reference in New Issue
Block a user