Files
python_course/00_intro.ipynb
2025-10-20 19:58:45 +00:00

216 lines
5.5 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"cells": [
{
"cell_type": "markdown",
"id": "3b60ae9e-f5a7-48f5-93dc-790467444b39",
"metadata": {},
"source": [
"# Введение."
]
},
{
"cell_type": "markdown",
"id": "ef042162-a459-4fb3-8cd1-a02803f8df90",
"metadata": {},
"source": [
"Программа ниже выведет в поток вывода сообщение в кавычках.\n",
"Попробуй запустить ее нажатием на кнопку в панели сверху."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "4d7a42a6-7b13-434f-87fa-03e5ce876778",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"i like pizza\n"
]
}
],
"source": [
"print(\"i like pizza\")"
]
},
{
"cell_type": "markdown",
"id": "54e3af2b-305d-4abb-b1a3-8e4dc5569373",
"metadata": {},
"source": [
"Мы можем \"распечатать\" еще одно сообщение, при этом оно будет напечатано с новой строки."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "7664f248-3e35-432d-bc10-6dbaaa6b13bb",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"i like pizza\n",
"it's really good\n"
]
}
],
"source": [
"print(\"i like pizza\")\n",
"print(\"it's really good\")"
]
},
{
"cell_type": "markdown",
"id": "2845a424-be55-46c8-9bd8-5f31e66b5229",
"metadata": {},
"source": [
"В `python`, как и в любом другом языке программирования есть возможность комментировать код. Для этого используем символ `#` и все, что будет находится после этого символа в той же строке будет игнорироваться интерпретатором `python`. Например "
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "412deffb-7934-4cd7-ae18-11591243df96",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"i like pizza\n"
]
}
],
"source": [
"print(\"i like pizza\")\n",
"# print(\"it's really good\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "59266fec-0edf-48d2-a0d5-394bdebd956e",
"metadata": {},
"outputs": [],
"source": [
"Если же нам необходимо \"спрятать\" от компилятора какую-то часть кода,\n",
"состоящую из нескольких строк мы можем использовать тройные кавычки."
]
},
{
"cell_type": "markdown",
"id": "80da61b9-60d6-4a79-8183-ba35a6d5ba73",
"metadata": {},
"source": [
"\"\"\"\n",
"print(\"this will not be printed\")\n",
"print(\"so is this\")\n",
"\"\"\"\n",
"print(\"this will be printed\")"
]
},
{
"cell_type": "markdown",
"id": "d604444e-117e-4876-8472-6dd0a4489927",
"metadata": {},
"source": [
"Комментарии обычно используются чтобы оставлять какие-либо пометки в коде для себя или других."
]
},
{
"cell_type": "markdown",
"id": "4adb843f-ccde-49ac-8b58-18ec9b3e3d87",
"metadata": {},
"source": [
"# Задания."
]
},
{
"cell_type": "markdown",
"id": "bdcb005b-e23f-456a-bbe4-1b99238cbf46",
"metadata": {},
"source": [
"1. В поле ниже напиши программу, которая будет распечатывать строку \"my name is Masha\". Проверь себя."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5de8c323-6e13-41f9-aa27-cdae0b490d73",
"metadata": {},
"outputs": [],
"source": [
"# решение задания 1"
]
},
{
"cell_type": "markdown",
"id": "49031654-cd40-4856-8182-5121aac287f5",
"metadata": {},
"source": [
"2. При помощи комментариев опиши то, что делает твоя программа выше."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c5255231-7506-4443-9dd1-251bff667850",
"metadata": {},
"outputs": [],
"source": [
"# решение задания 2"
]
},
{
"cell_type": "markdown",
"id": "e723a4b9-9a71-4a32-bfa8-2b4456c8c4ae",
"metadata": {},
"source": [
"3. А можешь ли ты записать программу эквивалентную\n",
"\n",
"```python\n",
"print(\"i like pizza\")\n",
"print(\"it's really good\")\n",
"```\n",
"\n",
"но используя `print` только один раз?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aa4f0d76-adc0-4299-be92-55689aec8e17",
"metadata": {},
"outputs": [],
"source": [
"# решение задания 3"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.11.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}