From 724839f190b8ae881bb6b6d7d29954711015e694 Mon Sep 17 00:00:00 2001 From: shariik Date: Mon, 15 Dec 2025 13:32:14 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=2017=20?= =?UTF-8?q?=D0=BF=D0=B0=D1=80=D0=B0=D0=B3=D1=80=D0=B0=D1=84=202.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2.2_lesson.17.20.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/2.2_lesson.17.20.py b/2.2_lesson.17.20.py index e69de29..a368367 100644 --- a/2.2_lesson.17.20.py +++ b/2.2_lesson.17.20.py @@ -0,0 +1,18 @@ +****Задание 17 Параграф 2.2*** +***Знаете ли вы, что Python изначально создавался для решения математических задач? Давайте воспользуемся его возможностями и найдём корни уравнения, используя составные условные операции.*** + + +if name == "main": + a, b, c = float(input()), float(input()), float(input()) + if not a and not b and not c: + print('Infinite solutions') + elif not a and not b and c or b ** 2 < 4 * a * c: + print('No solution') + elif b ** 2 == 4 * a * c: + print(f'{-b / (2 * a):.2f}') + elif not a: + print(f'{-c / b:.2f}') + else: + roots = [(-b - (b ** 2 - 4 * a * c) ** 0.5) / (2 * a), (-b + (b ** 2 - 4 * a * c) ** 0.5) / (2 * a)] + roots.sort() + print(f'{roots[0]:.2f} {roots[1]:.2f}')