This repository has been archived on 2025-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
Files
python_it_top/Practica1/task_1_rpo254.py

38 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Импортирование библиотек
import sys
import math
# Информирование об названии программы
print(":: Суммирование или произведение числа ::\n")
# Ввод 3 чисел
input_three = input("Введите 3 числа :: ")
# Валидация ввода 3 чисел
if len(input_three) != 3:
print("Ошибка: введите именно 3 числа!")
sys.exit(0)
# Выбор действия
print("")
print("Выберите действие\n"
"Сумма(1) или произведение(2)\n"
":: ", end='')
action = input()
# Условие
if action == "1":
# Суммирование
action_plus = [ int(nums_plus) for nums_plus in input_three ]
result_plus = sum(action_plus)
print("Вывод суммы ::", result_plus)
elif action == "2":
# Произведение
action_multip = [ int(nums_multip) for nums_multip in input_three ]
result_multip = math.prod(action_multip)
print("Вывод произведения ::", result_multip)
else:
# Если введено числе не подходящим 1-3
print("\n""Такого действия не существует")
sys.exit(0)