working on lesson 02

This commit is contained in:
nik
2025-10-25 14:30:08 +00:00
parent 2748971604
commit 88a2d540bf

View File

@@ -271,17 +271,42 @@
"id": "943d648a-4ebb-48a2-a194-43cf6dc7b320",
"metadata": {},
"source": [
"Мы получили `True`. На самом деле здесь все не так сложно. Просто любое ненулевое значение приводится к `True`, а нулевое к `False`. Для строки нулевое значение - пустая строка `\"\"`. Посмотрим на примерах."
"Мы получили `True`. На самом деле здесь все не так сложно. Просто любое ненулевое значение приводится к `True`, а нулевое к `False`. Для строки нулевое значение - пустая строка `''`. Посмотрим на примерах."
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"id": "7c4e5ebd-aece-4d81-bfc1-21a1c6559b55",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"null value for str: False\n",
"null value for int: False\n",
"null value for float: False\n"
]
}
],
"source": [
"print(f\"\") # \n"
"# нулевое значение для str\n",
"print(f\"null value for str: {bool('')}\")\n",
"\n",
"# нулевое значение для int\n",
"print(f\"null value for int: {bool(0)}\")\n",
"\n",
"# нулевое значение для float\n",
"print(f\"null value for float: {bool(0.0)}\")"
]
},
{
"cell_type": "markdown",
"id": "a1dd057d-8447-45e0-a31f-2195506e420d",
"metadata": {},
"source": [
"# Задания"
]
}
],