Загрузить в "calculyator"
2 работа
This commit is contained in:
parent
8ca6338217
commit
63c6d18165
@ -1,28 +1,14 @@
|
||||
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("Неизвестная команда!")
|
||||
num1 = float(input("введите первое число"))
|
||||
num2 = float(input("введите второе число"))
|
||||
operator = input("введите знак")
|
||||
if operator == "+":
|
||||
result= num1 + num2
|
||||
elif operator == "-":
|
||||
result = num1-num2
|
||||
elif operator == "/":
|
||||
result = num1 / num2
|
||||
elif operator == "*":
|
||||
result = num1 * num2
|
||||
else:
|
||||
print("ошибка ввода")
|
||||
print(result)
|
||||
Loading…
Reference in New Issue
Block a user