You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
2.6 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

{
"cells": [
{
"cell_type": "markdown",
"id": "4cd45516",
"metadata": {},
"source": [
"# Корни квадратного уравнения #"
]
},
{
"cell_type": "markdown",
"id": "2aa19998",
"metadata": {},
"source": [
"Python очень активно применяют ученые со всего мира в своих исследованиях. В этом задании мы с вами попробуем с помощью Python найти корни квадратного уравнения.\n",
"\n",
"Напомним, что квадратное уравнение выглядит следующим образом:\n",
"\n",
"$$ ax^2 + bx + c = 0 $$\n",
"\n",
"На вход программе мы подадим коэффициенты $a$, $b$ и $c$ - ваша цель напечатать корни квадратного уравнения (каждый с новой строки).\n",
"\n",
"Помним формулу дискриминанта и корней:\n",
"\n",
"$$ D = b^2 - 4ac $$\n",
"$$ x_{1,2} = \\frac {-b \\pm \\sqrt {b^2 - 4ac} } {2a} $$\n",
"\n",
"Коэффициенты a, b, c вы можете получить следующим образом:\n",
"\n",
"```\n",
"import sys\n",
"\n",
"a = int(sys.argv[1])\n",
"b = int(sys.argv[2])\n",
"c = int(sys.argv[3])\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "af54e415",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4.0\n",
"-1.0\n"
]
}
],
"source": [
"! python equation.py 1 -3 -4"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "dfaa7006",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-0.3333333333333333\n"
]
}
],
"source": [
"! python equation.py 9 6 1"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "93119b50",
"metadata": {},
"outputs": [],
"source": [
"! python equation.py 2 -3 4"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}