diff --git a/homework_01/homework_01.ipynb b/homework_01/homework_01.ipynb index 48efeea..a17ed5c 100644 --- a/homework_01/homework_01.ipynb +++ b/homework_01/homework_01.ipynb @@ -27,12 +27,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "5a4d665d", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('1', '4', '3', '2', '5')\n" + ] + } + ], "source": [ - "# ВАШ КОД ЗДЕСЬ" + "num = input(\"Введите пятизначное число: \")\n", + "mirored = num[0],num[3],num[2],num[1],num[4]\n", + "print(mirored)" ] }, { @@ -54,12 +64,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "07154103", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Количество выходных до отпуска: 1\n" + ] + } + ], "source": [ - "# ВАШ КОД ЗДЕСЬ" + "days = int(input(\"Введите количество дней до отпуска: \"))\n", + "\n", + "full_weeks = days // 7\n", + "remaining_days = days % 7\n", + "weekends = full_weeks * 2\n", + "\n", + "if remaining_days >= 6:\n", + " weekends += 1 \n", + "if remaining_days >= 7:\n", + " weekends += 1 \n", + "\n", + "print(f\"Количество выходных до отпуска: {weekends}\")" ] }, { @@ -81,12 +110,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "70f3324c", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "true\n" + ] + } + ], "source": [ - "# ВАШ КОД ЗДЕСЬ" + "length = int(input(\"Введите длину: \"))\n", + "width = int(input(\"Введите ширину: \"))\n", + "size = int(input(\"Введите размер куска: \"))\n", + "\n", + "if size % length == 0 or size % width == 0:\n", + " print(\"true\")\n", + "else:\n", + " print(\"false\")" ] }, { @@ -108,12 +152,37 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "id": "8686127c", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Римская запись: LIV\n" + ] + } + ], "source": [ - "# ВАШ КОД ЗДЕСЬ" + "def int_to_roman(num):\n", + " val = [\n", + " (1000, 'M'), (900, 'CM'), (500, 'D'), (400, 'CD'),\n", + " (100, 'C'), (90, 'XC'), (50, 'L'), (40, 'XL'),\n", + " (10, 'X'), (9, 'IX'), (5, 'V'), (4, 'IV'), (1, 'I')\n", + " ]\n", + " roman_num = []\n", + " for n, r in val:\n", + " while num >= n:\n", + " roman_num.append(r)\n", + " num -= n\n", + " return ''.join(roman_num)\n", + "\n", + "number = int(input(\"Введите целое положительное число: \"))\n", + "if number < 1:\n", + " print(\"Число должно быть положительным!\")\n", + "else:\n", + " print(f\"Римская запись: {int_to_roman(number)}\")" ] }, { @@ -136,24 +205,74 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "id": "74e39179", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Да, это вещественное число\n" + ] + } + ], "source": [ - "# ВАШ КОД ЗДЕСЬ" + "s = input(\"Введите число: \")\n", + "\n", + "is_valid = True\n", + "dot_count = 0\n", + "sign_count = 0\n", + "\n", + "if not s: \n", + " is_valid = False\n", + "else:\n", + " for i, char in enumerate(s):\n", + " if char == '.':\n", + " dot_count += 1\n", + " if dot_count > 1:\n", + " is_valid = False\n", + " break\n", + " elif char in '+-':\n", + " sign_count += 1\n", + " if i != 0 or sign_count > 1: \n", + " is_valid = False\n", + " break\n", + " elif not char.isdigit():\n", + " is_valid = False\n", + " break\n", + "\n", + " if is_valid:\n", + " if dot_count == 1 and len(s) == 1: \n", + " is_valid = False\n", + " elif sign_count == 1 and len(s) == 1: \n", + " is_valid = False\n", + " elif s[0] in '+-.' and len(s) == 2 and not s[1].isdigit(): \n", + " is_valid = False\n", + " elif s[-1] == '.' and len(s) > 1 and not s[-2].isdigit(): \n", + " is_valid = False\n", + "\n", + "print(\"Да, это вещественное число\" if is_valid else \"Нет, это не вещественное число\")" ] } ], "metadata": { "kernelspec": { - "display_name": ".venv (3.11.12)", + "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", - "version": "3.11.12" + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.0" } }, "nbformat": 4,