Добавление 2 дз

This commit is contained in:
2025-09-11 18:33:59 +05:00
parent 0ff94792ec
commit 739a99dcf0
5 changed files with 66 additions and 0 deletions

View File

@@ -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)

View File

@@ -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))

View File

@@ -0,0 +1,5 @@
one_diag = int(input("Введите 1 длину диагонали :: "))
two_diag = int(input("Введите 2 длину диагонали :: "))
romb_s = (one_diag * two_diag) // 2
print(romb_s)

View File

@@ -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))

View File

@@ -0,0 +1,7 @@
import random
text = [ "<<Life is what happens", "when", "you're busy making other plans>>'" ]
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))