Добавление 2 дз
This commit is contained in:
37
Practica2/task_1_rpo254.py
Normal file
37
Practica2/task_1_rpo254.py
Normal 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)
|
||||||
10
Practica2/task_2_rpo254.py
Normal file
10
Practica2/task_2_rpo254.py
Normal 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))
|
||||||
|
|
||||||
|
|
||||||
5
Practica2/task_3_rpo254.py
Normal file
5
Practica2/task_3_rpo254.py
Normal 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)
|
||||||
7
Practica2/task_4_rpo254.py
Normal file
7
Practica2/task_4_rpo254.py
Normal 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))
|
||||||
7
Practica2/task_5_rpo254.py
Normal file
7
Practica2/task_5_rpo254.py
Normal 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))
|
||||||
Reference in New Issue
Block a user