{"cells":[{"cell_type":"markdown","metadata":{"id":"yc2eQWIbMD23"},"source":["# **Лекція 01**\n","\n","\n","\n","\n","\n","\n"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":10,"status":"ok","timestamp":1676282791821,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"},"user_tz":-120},"id":"cPtWxxak-ZCs","outputId":"2eb2a602-c251-49b6-8c46-37da98ec369e"},"outputs":[{"output_type":"stream","name":"stdout","text":["Python 3.8.10\n"]}],"source":["! python --version"]},{"cell_type":"markdown","metadata":{"id":"JkIEaB2uuuZG"},"source":["Булеві значення"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"yDfXnHuau8l2","executionInfo":{"status":"ok","timestamp":1676282813018,"user_tz":-120,"elapsed":279,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"f079582d-630c-47fb-8b12-ba37015a1cad","colab":{"base_uri":"https://localhost:8080/"}},"outputs":[{"output_type":"stream","name":"stdout","text":["False\n","True\n","False\n","False\n","False\n","False\n","True\n"]}],"source":["print (bool(None))\n","print (bool(1))\n","print (bool(''))\n","print (bool([]))\n","print (bool(()))\n","print (bool({}))\n","print (bool('new proj'))"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":263,"status":"ok","timestamp":1676282808642,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"},"user_tz":-120},"id":"cOMQYAZW0e76","outputId":"a425ea42-b27e-4519-c132-2f6ed960fe02"},"outputs":[{"output_type":"stream","name":"stdout","text":["False\n"]}],"source":["a=5; b=-1\n","print (bool (1<=a<10 and 1<=b<20))\n"]},{"cell_type":"markdown","metadata":{"id":"QwEuYGNi1pWj"},"source":["Перетворення типів"]},{"cell_type":"code","execution_count":1,"metadata":{"id":"ftiMV5WA1AgM","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1707717709492,"user_tz":-120,"elapsed":8,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"26324cde-e664-4479-fc70-511092479efb"},"outputs":[{"output_type":"stream","name":"stdout","text":["int(3.58)= 3\n","int(14)= 14.0\n","5/2+3= 6.5\n","int('20',8)= 16\n","c= (7.5+3j)\n","дійсна частина 7.5\n","уявна частина 3.0\n","сполученне число (7.5-3j)\n"]}],"source":["#конвертуємо float в int\n","print('int(3.58)=', int(3.58))\n","#конвертуємо int в float\n","print('int(14)=', float(14))\n","#якщо у виразі є ціле і дійсне число, то результат буде дійсним\n","print('5/2+3=', 5/2+4)\n","#можно використовувати різні системи числення перетворення з 8 у 10\n","print(\"int('20',8)=\", int('20',8))\n","#операції з комплесними числами\n","c=7.5+3j\n","print('c=',c)\n","print('дійсна частина',c.real)\n","print('уявна частина',c.imag)\n","print('сполученне число',c.conjugate())"]},{"cell_type":"markdown","metadata":{"id":"l8ZLVJ2Y5lOs"},"source":["Рядки"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"R62bkxxg5oLg","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1676282826657,"user_tz":-120,"elapsed":279,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"f4a7a012-48ce-4518-ae59-3b3157f2c5e6"},"outputs":[{"output_type":"stream","name":"stdout","text":["Парочка — Семен та Одарочка.\n"," Чого Івась не навчиться, того й Іван не знатиме.\n"," За дурною головою і ногам нема покою.\n"]}],"source":["a='Парочка — Семен та Одарочка.\\n'\n","b='''Чого Івась не навчиться, того й Іван не знатиме.\\n'''\n","c=\"За дурною головою і ногам нема покою.\"\n","print(a,b,c)"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"1spmMG7S_GLq","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1676282832429,"user_tz":-120,"elapsed":465,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"300e52c4-43aa-4041-9a5a-0cc95bb4304e"},"outputs":[{"output_type":"stream","name":"stdout","text":["29\n","Парочка — Семен та Одарочка.\n","Парочка — Семен та Одарочка.\n","Парочка — Семен та Одарочка.\n","\n","П\n","а\n","р\n","о\n","ч\n","к\n","а\n"," \n","—\n"," \n","С\n","е\n","м\n","е\n","н\n"," \n","т\n","а\n"," \n","О\n","д\n","а\n","р\n","о\n","ч\n","к\n","а\n",".\n","\n","\n"]}],"source":["#a='Парочка — Семен та Одарочка.\\n'\n","print(len(a))\n","#рядки можно множити на число\n","print(a*3)\n","#з рядками можно робити як з последовностями\n","for ch in a:\n"," print(ch)"]},{"cell_type":"markdown","metadata":{"id":"AnD23sSn93gq"},"source":["В Python існують типи що можна змінювати і не можна.\n","До незмінних (immutable) типів відносяться: цілі числа (int), числа з плаваючою точкою (float), комплексні числа (complex), логічні (bool), кортежі (tuple), рядки (str) і незмінні множини (frozen set) .\n","До змінних (mutable) типів відносяться: списки (list), множини (set), словники (dict)."]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":281,"status":"ok","timestamp":1676282841024,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"},"user_tz":-120},"id":"PgoW3UU269Jq","outputId":"aa28e759-bd87-451a-d95b-b13e65c17caf"},"outputs":[{"output_type":"stream","name":"stdout","text":["[1, 2]\n"]},{"output_type":"execute_result","data":{"text/plain":["[1, 5]"]},"metadata":{},"execution_count":8}],"source":["a = [1, 2]\n","print(a)\n","\n","a[1]=5\n","a"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":538,"status":"ok","timestamp":1676207064693,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"},"user_tz":-120},"id":"-STWlpt9DYv0","outputId":"f92cb9d4-54d3-4c24-bbf2-7d7f7f1e9f42"},"outputs":[{"output_type":"stream","name":"stdout","text":["{'a': 1, 'b': 2, 'c': 3} [1, 2, 3, 4] (1, 2, 3, 4) {1, 2, 3, 4} {4, 5, 6, 7}\n"]},{"output_type":"execute_result","data":{"text/plain":["[1, 2, 3, 4, 1]"]},"metadata":{},"execution_count":10}],"source":["e_list=[1,2,3,4]#Список\n","e_touple=(1,2,3,4)#Незмiнний список - кортеж\n","e_dict={'a':1,'b':2,'c':3}#словник\n","e_set1,e_set2={1,2,3,4}, {4,5,6,7}#Множина\n","print(e_dict,e_list,e_touple, e_set1,e_set2)\n","\n","e_list.append(1)\n","e_list\n"]},{"cell_type":"markdown","metadata":{"id":"b4lDO89EL9L-"},"source":["Введення / виведення даних"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"p_QLL4IZL7e1","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1676207195299,"user_tz":-120,"elapsed":303,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"b5681986-5241-4ab7-94e4-9e667e42a3e1"},"outputs":[{"output_type":"stream","name":"stdout","text":["Hello 55 21.0765\n","21.0765\n","7\n","8\n","12 12.333333333333334 1\n"]}],"source":["i, j, k = \"Hello\", 55, 21.0765\n","print(i, j, k)\n","print(k)\n","print(3+4)\n","print(2 ** 3)\n","print(37 // 3,' ', 37/3,' ', 37%3)"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":6124,"status":"ok","timestamp":1676207222709,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"},"user_tz":-120},"id":"xPl-pkezMLB3","outputId":"d2f7592e-5500-4cd8-c145-602cb75b82e2"},"outputs":[{"output_type":"stream","name":"stdout","text":["Доброго дня.Як вас звати?\n","qwerty\n","Доброго дня, qwerty!\n"]}],"source":["print('Доброго дня.Як вас звати?')\n","name = input()\n","print('Доброго дня, ' + name + '!')"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":7425,"status":"ok","timestamp":1676207300690,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"},"user_tz":-120},"id":"-Bg3AucUNIQE","outputId":"1f85940b-f4ff-4aa0-e2d6-b3fa64d2fe1b"},"outputs":[{"output_type":"stream","name":"stdout","text":["4\n","35\n","435\n","9\n"]}],"source":["a = input()\n","b = input()\n","s = a + b\n","print(s)\n","print(2+7)"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":6171,"status":"ok","timestamp":1676207320028,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"},"user_tz":-120},"id":"x8xFOTsdcr5c","outputId":"c487b3e0-e373-4f86-a1a1-6ec73de68a25"},"outputs":[{"output_type":"stream","name":"stdout","text":["2\n","15\n","17\n"]}],"source":["a = int(input())\n","b = int(input())\n","s = a + b\n","print(s)"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"ETjPzJqwc9_x","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1676207345486,"user_tz":-120,"elapsed":7615,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"311ce431-ce8b-4339-da07-a78225c03ecd"},"outputs":[{"name":"stdout","output_type":"stream","text":["1 2 3 \n"]},{"output_type":"execute_result","data":{"text/plain":["['1', '2', '3']"]},"metadata":{},"execution_count":18}],"source":["s = input() # s == '1 2 3'\n","a = s.split() # a == ['1', '2', '3']\n","a"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"q4WJfLIfSIjL","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1676207425184,"user_tz":-120,"elapsed":343,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"0f014640-7b2b-4c89-96bb-044d722a4689"},"outputs":[{"output_type":"stream","name":"stdout","text":["['яблуко', 'груша', 'слива']\n"]}],"source":["#Проаналізувати код та його дію:\n","import pickle # роботи з модулем\n","\n","name = 'shoplist.data' # назва файлу\n","list = ['яблуко', 'груша', 'слива'] # список покупок\n","data = open(name,'wb') # відкрити файл для запису\n","pickle.dump(list,data) # записати об’єкт у файл\n","data.close() # закрити (звільнити) файл\n","\n","del list # звільнити пам'ять\n","\n","data = open(name, 'rb') # відкрити файл для читання\n","list = pickle.load(data) # завантажити об’єкт з файлу\n","print(list) # вивести об’єкт\n","data.close() # закрити (звільнити) файл"]},{"cell_type":"markdown","metadata":{"id":"crCdAoGgOFUt"},"source":["Умовний оператор"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":426,"status":"ok","timestamp":1676207431321,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"},"user_tz":-120},"id":"WV2T2B5JTdFe","outputId":"3e3aeb85-f08f-4494-a0bd-9c620357ff80"},"outputs":[{"output_type":"stream","name":"stdout","text":["xy')\n"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"yXxen50yOMMN","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1676207450342,"user_tz":-120,"elapsed":307,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"5e075a4b-af85-4702-deed-c31c03d95043"},"outputs":[{"output_type":"stream","name":"stdout","text":["x=y\n"]}],"source":["x, y = 8, 8\n","if (xy):\n"," print('x>y')\n","else:\n"," print('x=y')"]},{"cell_type":"markdown","metadata":{"id":"dEmgw2zYbWJg"},"source":["Вкладені (Каскадні) умовні інструкції\n","Приклад програми, що визначає чверть координатної площини, можна переписати використовуючи \"каскадну\" послідовність операцією if ... elif ... else:"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"-38f0Qadblvc","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1676207474816,"user_tz":-120,"elapsed":6166,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"33077265-0db7-4478-e21e-ca80fa1cecd0"},"outputs":[{"output_type":"stream","name":"stdout","text":["4\n","3\n","перша чверть\n"]}],"source":["x = int(input())\n","y = int(input())\n","if x > 0 and y > 0:\n"," print(\"перша чверть\")\n","elif x > 0 and y < 0:\n"," print(\"четверта чверть\")\n","elif y > 0:\n"," print(\"друга чверть\")\n","else:\n"," print(\"треття чверть\")"]},{"cell_type":"markdown","metadata":{"id":"5mJy6Ngt7hzC"},"source":["Оператор вибору"]},{"cell_type":"code","execution_count":2,"metadata":{"id":"xORAANyLan2v","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1707717812864,"user_tz":-120,"elapsed":280,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"19d2b4e9-88f9-4f50-8755-50928b080744"},"outputs":[{"output_type":"stream","name":"stdout","text":["Saturday\n","Invalid day\n","Sunday\n"]}],"source":["def get_week_day(argument):\n"," switcher ={\n"," 0: \"Sunday\",\n"," 1: \"Monday\",\n"," 2: \"Tuesday\",\n"," 3: \"Wednesday\",\n"," 4: \"Thursday\",\n"," 5: \"Friday\",\n"," 6: \"Saturday\"\n"," }\n"," return switcher.get(argument, \"Invalid day\")\n","\n","print (get_week_day(6))\n","print (get_week_day(8))\n","print (get_week_day(0))"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"hPKRkS6v6ni1","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1676207515247,"user_tz":-120,"elapsed":321,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"d4c6d1fb-03ce-4290-fe30-0c5954d43d68"},"outputs":[{"output_type":"execute_result","data":{"text/plain":["1"]},"metadata":{},"execution_count":25}],"source":["def f(x):\n"," return {\n"," 'a': 1,\n"," 'b': 2,\n"," 'c': 7,\n"," }[x]\n","f('a')"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":7962,"status":"ok","timestamp":1676208644406,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"},"user_tz":-120},"id":"GzRKlW9uySbq","outputId":"dc11576c-85cb-4069-c412-0224f169ec65"},"outputs":[{"output_type":"stream","name":"stdout","text":["3\n","Choices:\n"," 1 - Square\n"," 2 - Cube\n"," 3 - Square Root\n","Please enter your choice:\n","\n","1\n","9.0\n"]}],"source":["import math\n","\n","#print (\"Please enter an integer:\\n\")\n","x = int(input())\n","print(\"Choices:\\n 1 - Square\\n 2 - Cube\\n 3 - Square Root\")\n","print (\"Please enter your choice:\\n\")\n","choice = int(input())\n","def switch_func(value, i):\n"," return {\n"," 1: lambda val: math.pow(val, 2),\n"," 2: lambda val: math.pow(val, 3),\n"," 3: lambda val: math.sqrt(val),\n"," }.get(value)(i)\n","print(switch_func(choice, x))"]},{"cell_type":"markdown","metadata":{"id":"rd5MDAWPdYAi"},"source":["Цикл while"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"X0v2C6OpgTku","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1676208653945,"user_tz":-120,"elapsed":610,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"c9a6f2a2-4a8d-4e65-ed38-489694b50476"},"outputs":[{"output_type":"stream","name":"stdout","text":["1\n","2\n","3\n","4\n","5\n"]}],"source":["i= 1\n","while i < 6:\n"," print(i)\n"," i += 1"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"pgv0xHLld-pv","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1676208665280,"user_tz":-120,"elapsed":6,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"5f94cbc1-e2c8-4054-a69b-fc314bb630d0"},"outputs":[{"output_type":"stream","name":"stdout","text":["1\n","2\n"]}],"source":["i = 1\n","while i < 6:\n","\n"," if i == 3:\n"," break\n"," print(i)\n"," i += 1"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"EsUoXC6TeMqQ","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1676208687983,"user_tz":-120,"elapsed":365,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"99f86955-f944-432a-b928-aa4e0be53562"},"outputs":[{"output_type":"stream","name":"stdout","text":["1\n","2\n","4\n","5\n","6\n"]}],"source":["i = 0\n","while i < 6:\n"," i += 1\n"," if i == 3:\n"," continue\n"," print(i)"]},{"cell_type":"markdown","metadata":{"id":"5Q97bAQketI5"},"source":["Цикл for"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"AdIfwL3qet84","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1676208712438,"user_tz":-120,"elapsed":314,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"725ddf9b-d026-40f2-9646-659403339b2f"},"outputs":[{"output_type":"stream","name":"stdout","text":["apple\n","banana\n","cherry\n"]}],"source":["fruits = [\"apple\", \"banana\", \"cherry\"]\n","for x in fruits:\n"," print(x)"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"THoYuPgZe6NF","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1676208738233,"user_tz":-120,"elapsed":290,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"f6b64430-2770-4056-af0b-c043a325e6e7"},"outputs":[{"output_type":"stream","name":"stdout","text":["b\n","a\n","n\n","a\n"]}],"source":["for x in \"banana\":\n"," print(x)"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"OnLpC0K6e_ZA","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1676208745407,"user_tz":-120,"elapsed":330,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"bcffb841-50ab-42c7-a2a3-489b61c8bdb7"},"outputs":[{"output_type":"stream","name":"stdout","text":["0\n","1\n","2\n","3\n","4\n","5\n","6\n"]}],"source":["for x in range(7):\n"," print(x)"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"DuRSx5JNh63R","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1676208798690,"user_tz":-120,"elapsed":722,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"bb2b3851-710c-40a1-cdce-c35c50b39f5d"},"outputs":[{"output_type":"stream","name":"stdout","text":["10\n"]}],"source":["s=0\n","for x in range(1,5):\n"," s+=x\n","print(s)"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"eR8uqQnoksnL","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1676208820985,"user_tz":-120,"elapsed":309,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"48f76c3e-e948-48e3-ffaf-237c440e99d8"},"outputs":[{"output_type":"stream","name":"stdout","text":["red apple\n","red banana\n","red cherry\n","big apple\n","big banana\n","big cherry\n","tasty apple\n","tasty banana\n","tasty cherry\n"]}],"source":["a = [\"red\", \"big\", \"tasty\"]\n","b = [\"apple\", \"banana\", \"cherry\"]\n","\n","for x in a:\n"," for y in b:\n"," print(x, y)"]},{"cell_type":"markdown","metadata":{"id":"tG4BG5zykHMp"},"source":["Функції Python"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"elapsed":8,"status":"ok","timestamp":1676208829879,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"},"user_tz":-120},"id":"hWSZP8EZmWRh","outputId":"fab5be08-5b77-4fc3-e6de-e67cc8e5040a"},"outputs":[{"output_type":"stream","name":"stdout","text":["Hello from a function\n"]}],"source":["def my_function():\n"," print(\"Hello from a function\")\n","\n","my_function()"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"WfaoWmN3nXfU"},"outputs":[],"source":["def countFood():\n"," a = int(input())\n"," b = int(input())\n"," print(\"Всего\", a+b, \"шт.\")\n","print(\"Скільки було бананів і ананасів для мавпенятка?\")\n","countFood()\n","print(\"Скільки було жучків і чепвячків для їжачка?\")\n","countFood()\n","print(\"Скільки було риб і моллюсків для видр?\")\n","countFood()"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"HARISQ0Uo5fW"},"outputs":[],"source":["def countFood():\n"," a = int(input())\n"," b = int(input())\n"," return a+b\n","print(\"Скільки було бананів і ананасів для мавпенятка?\")\n","print(\"Всего\", countFood(), \"шт.\")\n","print(\"Скільки було жучків і чепвячків для їжачка?\")\n","x=countFood()\n","print(\"Всего\", x, \"шт.\")\n","print(\"Скільки було риб і моллюсків для видр?\")\n","print(\"Всего\", countFood(), \"шт.\")\n"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"Lxq7U5o2U196","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1676209169031,"user_tz":-120,"elapsed":325,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"91e2f201-7ae7-448d-ba60-20411e31578e"},"outputs":[{"output_type":"stream","name":"stdout","text":["x is greater than or equal to y\n"]}],"source":["def main():\n","\tx,y = 12,8\n","\tst = \"x is less than y\" if (x < y) else \"x is greater than or equal to y\"\n","\tprint(st)\n","\n","if __name__ == \"__main__\":\n","\tmain()\n"]},{"cell_type":"code","execution_count":null,"metadata":{"id":"e9FS_1lNtTyZ","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1676209271082,"user_tz":-120,"elapsed":635,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}},"outputId":"40db6c4b-bc68-4da6-fd59-c0d9e3ba4ef2"},"outputs":[{"output_type":"stream","name":"stdout","text":["Орест Ганна\n"]}],"source":["def my_function(fname, lname):\n"," print(fname + \" \" + lname)\n","\n","my_function(\"Орест\", \"Ганна\")"]},{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"ikTxz45RcUyU","outputId":"568bd7d3-e76c-4da7-d267-499e052db2e7","executionInfo":{"status":"ok","timestamp":1676209514751,"user_tz":-120,"elapsed":309,"user":{"displayName":"Galina Marchuk","userId":"08159968800729403674"}}},"outputs":[{"output_type":"stream","name":"stdout","text":["0\n","1\n","2\n"]}],"source":["import numpy as np\n","import pandas as pd\n","\n","for i in range(3):\n"," if i<1:\n"," print(i)\n"," else:\n"," print(i)\n"," #break\n"]}],"metadata":{"colab":{"provenance":[],"authorship_tag":"ABX9TyOF9tfy73DPBHECGfOjnbEC"},"kernelspec":{"display_name":"Python 3","name":"python3"}},"nbformat":4,"nbformat_minor":0}