Skip to content

Instantly share code, notes, and snippets.

@mahenzon
Created April 1, 2025 07:37
Show Gist options
  • Save mahenzon/488352d6dc4d5f5696cb9bb787570087 to your computer and use it in GitHub Desktop.
Save mahenzon/488352d6dc4d5f5696cb9bb787570087 to your computer and use it in GitHub Desktop.
Python Intro | Lerna × Suren
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "9ef76ce3-d633-4ad0-8f3d-686dac48b376",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello World!\n"
]
}
],
"source": [
"print(\"Hello World!\")"
]
},
{
"cell_type": "markdown",
"id": "940b5bce-5a58-4a43-8442-8dac8facfd76",
"metadata": {},
"source": [
"# Пример №1: Приветствие пользователя\n",
"\n",
"Работа с вводом данных"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "68c36634-beb7-443c-b727-3ab543055f38",
"metadata": {},
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
"Enter your name: Suren\n"
]
}
],
"source": [
"name = input(\"Enter your name: \")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "4fc02065-6f79-4158-9ad8-8945ae28ae2d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Suren\n"
]
}
],
"source": [
"print(name)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "f0a0ac00-35ab-4f4a-9bc9-1bbc10a2b8bf",
"metadata": {},
"outputs": [],
"source": [
"greeting = f\"Hello, {name}! Welcome to Python world!\""
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "523dba9b-e608-4a06-af90-964b547a8bf3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello, Suren! Welcome to Python world!\n"
]
}
],
"source": [
"print(greeting)"
]
},
{
"cell_type": "markdown",
"id": "1b462218-1f5a-4df6-a67d-289cc4ea40a0",
"metadata": {},
"source": [
"# Пример №2: Сложение двух чисел"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "43a8cd7e-87b1-474a-8ebc-f8542b8edc6e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1 + 2"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "1c94e6d8-c501-4700-919b-e29ab8dfd846",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"7"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"3 + 4"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "530f57ab-4aeb-49a7-b782-2b4f6a59cf11",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"9\n"
]
}
],
"source": [
"print(4 + 5)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "1d151062-bee2-4caf-8015-9f1e10e2c165",
"metadata": {},
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
"Enter first number: 7\n",
"Enter second number: 9\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"7 + 9 = 16\n"
]
}
],
"source": [
"input_a = input(\"Enter first number: \")\n",
"input_b = input(\"Enter second number: \")\n",
"\n",
"num_a = int(input_a)\n",
"num_b = int(input_b)\n",
"\n",
"total = num_a + num_b\n",
"print(f\"{num_a} + {num_b} = {total}\")"
]
},
{
"cell_type": "markdown",
"id": "16fdd0b6-1d0c-4247-8b5b-afd727b9d401",
"metadata": {},
"source": [
"# Пример №3: Математические операции"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "2fe70dc4-7fe9-43ab-91d5-f7e8c6e9bf70",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1 + 2"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "69d71973-9e28-4977-a6b1-d0ee4f1d41fc",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"3 - 1"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "a3245c23-1a2f-4622-97c1-d1bb1a037598",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-2"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1 - 3"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "fafb5100-1cf4-4d3f-b098-6eed29a76163",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"15"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"5 * 3"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "5c8151f1-962a-406a-8105-21f127819070",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"15"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"3 * 5"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "5d9cdca2-caff-4b15-9a3c-a6bc88e4ee31",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2.5"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"5 / 2"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "4115f941-d479-46cd-a915-47213685d978",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2.5"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"10 / 4"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "edd582c9-7280-48ad-9e81-169674052bf8",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2.0"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"10 / 5"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "8a1e7524-aabf-45c2-8320-4eb2c83949c0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5.0"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"10 / 2"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "647d6788-dfec-4d12-8282-1dc0c116a598",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"10 // 2"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "ff74d001-e451-4507-9a22-6cf955a6455d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"10 // 4"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "a1746820-ff0c-4492-89f0-91eb687d15a0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1.9"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"19 / 10"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "060c829a-d8c8-4bcd-8f9b-488bd7581732",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"19 // 10"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "10dd4f54-9aa8-404c-8eb4-310250d2b109",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"9"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"19 % 10"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "724ec9b6-6de6-497c-95b6-64c616fbc923",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"10 // 4"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "7cdcf03a-5c44-4c3c-ad3a-85c79884b2d9",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"10 % 4"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "b9cce2d9-10f0-49b6-a4de-8f329aaf114c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3.0"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"12 / 4"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "7bf56283-3f69-4d8f-95d3-f8862b96c3a6",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"12 % 4"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "b1a51e1f-c360-45c9-85f2-a9c3da89303f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"13 % 4"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "0c217fa5-5448-4fa9-a78f-5f82b6fb47fe",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"13 // 4"
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "8e2e00b4-4adc-456b-af8b-8f4b2c11d3e0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"8"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"2**3"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "87d6b622-435b-4fc3-8839-2db983e8d5c9",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1024"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"2**10"
]
},
{
"cell_type": "markdown",
"id": "44e55d01-eda3-479a-a5d2-9be11ad9c0d7",
"metadata": {},
"source": [
"# Пример №4: сложная математика"
]
},
{
"cell_type": "code",
"execution_count": 33,
"id": "3188ea18-ba6d-441d-a359-b7bec8d4e598",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"16.0"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"256**0.5"
]
},
{
"cell_type": "code",
"execution_count": 34,
"id": "be69471b-cc0c-40ba-b7ce-a73890990100",
"metadata": {},
"outputs": [],
"source": [
"import math"
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "c1882e62-9db5-48ef-9525-c0b89973c663",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"16.0"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"math.sqrt(256)"
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "40e490b6-8118-4f37-a5d7-1dbdffc4871b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"inf"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"math.inf"
]
},
{
"cell_type": "code",
"execution_count": 37,
"id": "9a890da2-97cd-4d43-a498-479554df38ad",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"math.inf > 1024**1024"
]
},
{
"cell_type": "markdown",
"id": "28ca3be9-9f56-4ca8-8774-cbd95817b26d",
"metadata": {},
"source": [
"# Пример №5: словарь\n",
"\n",
"Коллекция данных"
]
},
{
"cell_type": "code",
"execution_count": 38,
"id": "1c91ee6c-c338-4716-b4c9-0f0129b2c2db",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'title': 'Python Intro', 'date': '2025-04-01'}\n"
]
}
],
"source": [
"webinar_info = {\n",
" \"title\": \"Python Intro\",\n",
" \"date\": \"2025-04-01\",\n",
"}\n",
"print(webinar_info)"
]
},
{
"cell_type": "code",
"execution_count": 39,
"id": "3981271f-7252-40e9-af0e-a60fc474c937",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Webinar Title: Python Intro\n"
]
}
],
"source": [
"print(\"Webinar Title:\", webinar_info[\"title\"])"
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "040390fb-0e50-4222-8d8e-308e47abd7f2",
"metadata": {},
"outputs": [],
"source": [
"webinar_info[\"description\"] = \"Introduction: IDE, text editor, Jupyter notebook\""
]
},
{
"cell_type": "code",
"execution_count": 43,
"id": "16f171c3-5342-4d0f-b52b-b8bed36dcefe",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'title': 'Python Intro', 'date': '2025-04-01', 'description': 'Introduction: IDE, text editor, Jupyter notebook'}\n"
]
}
],
"source": [
"print(webinar_info)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a1ead365-97c3-47f1-8c23-039a49e3bb7f",
"metadata": {},
"outputs": [],
"source": []
}
],
"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.13.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
anyio==4.9.0
appnope==0.1.4
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
asttokens==3.0.0
async-lru==2.0.5
attrs==25.3.0
babel==2.17.0
beautifulsoup4==4.13.3
bleach==6.2.0
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
comm==0.2.2
debugpy==1.8.13
decorator==5.2.1
defusedxml==0.7.1
executing==2.2.0
fastjsonschema==2.21.1
fqdn==1.5.1
h11==0.14.0
httpcore==1.0.7
httpx==0.28.1
idna==3.10
ipykernel==6.29.5
ipython==9.0.2
ipython_pygments_lexers==1.1.1
isoduration==20.11.0
jedi==0.19.2
Jinja2==3.1.6
json5==0.10.0
jsonpointer==3.0.0
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
jupyter-events==0.12.0
jupyter-lsp==2.2.5
jupyter_client==8.6.3
jupyter_core==5.7.2
jupyter_server==2.15.0
jupyter_server_terminals==0.5.3
jupyterlab==4.3.6
jupyterlab_pygments==0.3.0
jupyterlab_server==2.27.3
MarkupSafe==3.0.2
matplotlib-inline==0.1.7
mistune==3.1.3
nbclient==0.10.2
nbconvert==7.16.6
nbformat==5.10.4
nest-asyncio==1.6.0
notebook==7.3.3
notebook_shim==0.2.4
overrides==7.7.0
packaging==24.2
pandocfilters==1.5.1
parso==0.8.4
pexpect==4.9.0
platformdirs==4.3.7
prometheus_client==0.21.1
prompt_toolkit==3.0.50
psutil==7.0.0
ptyprocess==0.7.0
pure_eval==0.2.3
pycparser==2.22
Pygments==2.19.1
python-dateutil==2.9.0.post0
python-json-logger==3.3.0
PyYAML==6.0.2
pyzmq==26.3.0
referencing==0.36.2
requests==2.32.3
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rpds-py==0.24.0
Send2Trash==1.8.3
setuptools==78.1.0
six==1.17.0
sniffio==1.3.1
soupsieve==2.6
stack-data==0.6.3
terminado==0.18.1
tinycss2==1.4.0
tornado==6.4.2
traitlets==5.14.3
types-python-dateutil==2.9.0.20241206
typing_extensions==4.13.0
uri-template==1.3.0
urllib3==2.3.0
wcwidth==0.2.13
webcolors==24.11.1
webencodings==0.5.1
websocket-client==1.8.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment