Загрузить в "calculyator"
2 работа
This commit is contained in:
parent
8ca6338217
commit
63c6d18165
@ -1,28 +1,14 @@
|
|||||||
while True:
|
num1 = float(input("введите первое число"))
|
||||||
print("Выбери действие:")
|
num2 = float(input("введите второе число"))
|
||||||
print("1 - сложение")
|
operator = input("введите знак")
|
||||||
print("2 - умножение")
|
if operator == "+":
|
||||||
print("0 - выход")
|
result= num1 + num2
|
||||||
|
elif operator == "-":
|
||||||
choice = input("Ваш выбор: ")
|
result = num1-num2
|
||||||
|
elif operator == "/":
|
||||||
if choice == "0":
|
result = num1 / num2
|
||||||
print("Выход из программы.")
|
elif operator == "*":
|
||||||
break
|
result = num1 * num2
|
||||||
|
else:
|
||||||
|
print("ошибка ввода")
|
||||||
numbers = input("Введите числа через пробел: ").split()
|
print(result)
|
||||||
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