From 9395004484a2b6d5d47c64705455030e5c6953f1 Mon Sep 17 00:00:00 2001 From: user Date: Tue, 9 Dec 2025 15:11:38 +0500 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=2017?= =?UTF-8?q?=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B8=D0=BB=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(+) create mode 100644 2.2_lesson.17.20.py diff --git a/2.2_lesson.17.20.py b/2.2_lesson.17.20.py new file mode 100644 index 0000000..2e3f124 --- /dev/null +++ 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}') \ No newline at end of file