diff --git a/Practica2/task_1_rpo254.py b/Practica2/task_1_rpo254.py new file mode 100644 index 0000000..eec8628 --- /dev/null +++ b/Practica2/task_1_rpo254.py @@ -0,0 +1,37 @@ +# Импортирование библиотек +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) diff --git a/Practica2/task_2_rpo254.py b/Practica2/task_2_rpo254.py new file mode 100644 index 0000000..ab32a75 --- /dev/null +++ b/Practica2/task_2_rpo254.py @@ -0,0 +1,10 @@ +# Ввод 3 чисел +input_one = int(input("Введите 1 число :: ")) +input_two = int(input("Введите 2 число :: ")) +input_three = int(input("Введите 3 число :: ")) + +nums = input_one - input_two - input_three + +print("Остаток суммы зарплаты :: {}".format(nums)) + + diff --git a/Practica2/task_3_rpo254.py b/Practica2/task_3_rpo254.py new file mode 100644 index 0000000..0b6a1f0 --- /dev/null +++ b/Practica2/task_3_rpo254.py @@ -0,0 +1,5 @@ +one_diag = int(input("Введите 1 длину диагонали :: ")) +two_diag = int(input("Введите 2 длину диагонали :: ")) + +romb_s = (one_diag * two_diag) // 2 +print(romb_s) diff --git a/Practica2/task_4_rpo254.py b/Practica2/task_4_rpo254.py new file mode 100644 index 0000000..f6e6825 --- /dev/null +++ b/Practica2/task_4_rpo254.py @@ -0,0 +1,7 @@ +import random + +text = [ "To be", "or not", "to be" ] +random_text_one = random.choice(text) +random_text_two = random.choice(text) +random_text_three = random.choice(text) +print("{}\n" "{}\n" "{}\n".format(random_text_one, random_text_two, random_text_three)) diff --git a/Practica2/task_5_rpo254.py b/Practica2/task_5_rpo254.py new file mode 100644 index 0000000..ac316af --- /dev/null +++ b/Practica2/task_5_rpo254.py @@ -0,0 +1,7 @@ +import random + +text = [ "<>'" ] +random_text_one = random.choice(text) +random_text_two = random.choice(text) +random_text_three = random.choice(text) +print("{}\n" " {}\n" " {}\n".format(random_text_one, random_text_two, random_text_three))