rdy w/ lesson 02

This commit is contained in:
nik
2025-10-25 14:51:12 +00:00
parent 88a2d540bf
commit ab056b90b4

View File

@@ -308,6 +308,109 @@
"source": [
"# Задания"
]
},
{
"cell_type": "markdown",
"id": "5a9be6b1-4f2d-4639-a43b-2a7557cc49d7",
"metadata": {},
"source": [
"1. Создайте переменную `price` со значением `19.99`. Приведи её к типу `int` и выведи новое значение и тип переменной. Подумай, что произойдет с дробной частью."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "55ac1362-c07f-439a-a993-5951798fc943",
"metadata": {},
"outputs": [],
"source": [
"# решение задания №1"
]
},
{
"cell_type": "markdown",
"id": "4802ddb7-0304-41cb-9594-3bce55467127",
"metadata": {},
"source": [
"2. Создай переменную `year` со значением `2025`. Приведи её к типу `str` и попробуй выполнить выражение `year + 5`. Что произойдет и почему?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3a8c7484-17fe-49d9-9fb7-8ac50bd14da4",
"metadata": {},
"outputs": [],
"source": [
"# решение задания №2"
]
},
{
"cell_type": "markdown",
"id": "1c14f451-3249-49bc-af9d-6e35bf14b337",
"metadata": {},
"source": [
"3. Создай переменную `number_str = \"42\"`. Приведи её к типу `int` и прибавь `8`. Выведи результат и новый тип переменной. Попробуй сделать то же самое с `number_str = \"42a\"`. Что произойдет и почему?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "49b76ce4-d59c-4a7a-a0aa-eaf2237b0358",
"metadata": {},
"outputs": [],
"source": [
"# решение задания №3"
]
},
{
"cell_type": "markdown",
"id": "0fe68dc4-a730-4fe5-bab3-93f80bee8ca5",
"metadata": {},
"source": [
"4. Создай переменные `a = 0` и `b = 5`. Приведи их к типу `bool` и выведи результат. Объясни, почему значения различаются."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "83b691ba-dadf-429c-afd6-bc30489100fb",
"metadata": {},
"outputs": [],
"source": [
"# решение задания №4"
]
},
{
"cell_type": "markdown",
"id": "73126e34-7ba2-4714-99fb-b222c496b3dd",
"metadata": {},
"source": [
"5. Пусть есть переменные:\n",
"\n",
"```python\n",
"name = \"Vlad\"\n",
"age = 20\n",
"```\n",
"\n",
"Выведи строку:\n",
"\n",
"```\n",
"My name is Vlad and I am 20 years old.\n",
"```\n",
"\n",
"с помощью конкатенации (`+`) и с помощью f-строки. В первом случае тебе придется привести `age` к типу `str`."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bb71ef7d-8d30-4bab-9f4c-a5fa3445f113",
"metadata": {},
"outputs": [],
"source": [
"# решение задания №5"
]
}
],
"metadata": {