{"id":317329,"date":"2021-02-02T09:00:32","date_gmt":"2021-02-02T09:00:32","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=317329"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=317329","title":{"rendered":"25 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u043e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u0438\u043a\u043e\u0432 Python, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u043d\u0430\u0442\u044c"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p><em>\u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u0442 Python \u0432\u0435\u043b\u0438\u043a\u0438\u043c<\/em><\/p>\n<p><a href=\"https:\/\/levelup.gitconnected.com\/25-useful-python-one-liners-that-you-should-ec613df18260\" rel=\"noopener noreferrer nofollow\">\u041e\u0440\u0438\u0433\u0438\u043d\u0430\u043b &#171;25 Useful Python One-Liners That You Should know&#187; \u043e\u0442 Abhay Parashar<\/a><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/088\/fff\/624\/088fff624dd665721e1edc94ad7771c5.png\" width=\"700\" height=\"393\"><figcaption><\/figcaption><\/figure>\n<p><em>\u041f\u0435\u0440\u0435\u0434 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435\u043c: \u0432 \u0440\u0443\u043a\u0430\u0445 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b. \u041e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u0438\u043a\u0438, \u043a\u0430\u043a \u0438 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0430\u0445\u0430\u0440, &#8212; \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u0433\u0440\u0430\u043c\u043e\u0442\u043d\u043e\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u0432\u0430\u0448\u0443 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0432 \u0433\u043b\u0430\u0437\u0430\u0445 \u043a\u043e\u043b\u043b\u0435\u0433, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0441\u0432\u0435\u0440\u0445\u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0443\u0441\u0438\u043b\u0438\u0439. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c.<\/em><\/p>\n<p>\u0412 \u0442\u043e\u0442 \u0434\u0435\u043d\u044c, \u043a\u043e\u0433\u0434\u0430 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u0432\u043e\u044e \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u043a\u043e\u0434\u0430 \u043d\u0430 Python, \u044f \u0431\u044b\u043b \u043e\u0447\u0430\u0440\u043e\u0432\u0430\u043d \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u043e\u0439, \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u043a\u0440\u0443\u0442\u043e\u0441\u0442\u044c\u044e \u0435\u0433\u043e \u043e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u0438\u043a\u043e\u0432. \u0412 \u0441\u0432\u043e\u0435\u043c \u0431\u043b\u043e\u0433\u0435 \u044f \u0445\u043e\u0447\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u043d\u0430 Python.<\/p>\n<h2>1. \u0421\u043c\u0435\u043d\u043a\u0430 \u0434\u0432\u0443\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/h2>\n<pre><code class=\"python\"># a = 4 b = 5 a,b = b,a # print(a,b) &gt;&gt; 5,4<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0447\u0435\u0433\u043e-\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043c\u0435\u043d\u044f\u0435\u043c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0434\u0432\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 &#8212; \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0438\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438.<\/p>\n<h2>2. \u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/h2>\n<pre><code class=\"python\">a,b,c = 4,5.5,'Hello' #print(a,b,c) &gt;&gt; 4,5.5,hello<\/code><\/pre>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u044f\u0442\u044b\u0435 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0437\u0430 \u0440\u0430\u0437. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434, \u0432\u044b \u0434\u0430\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 var \u0437\u0430 \u0440\u0430\u0437. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043b\u044f \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0440\u0430\u0437\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<pre><code class=\"python\">a,b,*c = [1,2,3,4,5] print(a,b,c) &gt; 1 2 [3,4,5]<\/code><\/pre>\n<h2>3. \u0421\u0443\u043c\u043c\u0430 \u0447\u0435\u0442\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0432 \u0441\u043f\u0438\u0441\u043a\u0435<\/h2>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432, \u043d\u043e \u043b\u0443\u0447\u0448\u0438\u0439 \u0438 \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<pre><code class=\"python\">a = [1,2,3,4,5,6] s = sum([num for num in a if num%2 == 0]) print(s) &gt;&gt; 12<\/code><\/pre>\n<h2>4. \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430<\/h2>\n<p><code>del<\/code> &#8212; \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0435 \u0432 Python \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<pre><code class=\"python\">#### \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0432\u0441\u0435 \u0447\u0435\u0442\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 a = [1,2,3,4,5] del a[1::2] print(a) &gt;[1, 3, 5]<\/code><\/pre>\n<h2>5. \u0427\u0442\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432<\/h2>\n<pre><code class=\"python\">lst = [line.strip() for line in open('data.txt')] print(lst)<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u0441\u043f\u0438\u0441\u043e\u043a. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0446\u0438\u043a\u043b\u0430 <code>for<\/code> \u0447\u0438\u0442\u0430\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0437\u0430 \u0441\u0442\u0440\u043e\u043a\u043e\u0439. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>strip<\/code> \u0443\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0435 \u043b\u0438\u0448\u043d\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e. \u041d\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<pre><code class=\"python\">list(open('data.txt')) ##\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 with \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043a\u0440\u043e\u0435\u0442 \u0444\u0430\u0439\u043b \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f with open(\"data.txt\") as f: lst=[line.strip() for line in f] print(lst)<\/code><\/pre>\n<h2>6. \u0417\u0430\u043f\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0444\u0430\u0439\u043b<\/h2>\n<pre><code class=\"python\">with open(\"data.txt\",'a',newline='\\n') as f: f.write(\"Python is awesome\")<\/code><\/pre>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043a\u043e\u0434 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0444\u0430\u0439\u043b data.txt, \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u0435\u0449\u0435 \u043d\u0435\u0442, \u0430 \u0437\u0430\u0442\u0435\u043c \u043d\u0430\u043f\u0438\u0448\u0435\u0442 \u0432 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 <code>Python is awesome<\/code>.<\/p>\n<h2>7. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u043e\u0432<\/h2>\n<pre><code class=\"python\">lst = [i for i in range(0,10)] print(lst) &gt; [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]  \u0438\u043b\u0438  lst = list(range(0,10)) print(lst)<\/code><\/pre>\n<p>\u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0442\u0440\u043e\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u0442 \u0436\u0435 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<pre><code class=\"python\">lst = [(\"Hello \"+i) for i in ['Karl','Abhay','Zen']] print(lst) &gt; ['Hello Karl', 'Hello Abhay', 'Hello Zen']<\/code><\/pre>\n<h2>8. Mapping \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435<\/h2>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435. \u041f\u0435\u0440\u0432\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432\u0430\u043c \u0432 \u0433\u043e\u043b\u043e\u0432\u0443, &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0446\u0438\u043a\u043b, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u043e \u0432\u0441\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0434\u0438\u043d \u0437\u0430 \u0434\u0440\u0443\u0433\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0441\u0442\u0430\u0440\u043e\u0439 \u0448\u043a\u043e\u043b\u044b \u0432 Python. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>map<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u0437\u0430 \u043d\u0430\u0441.<\/p>\n<pre><code class=\"python\">list(map(int,['1','2','3'])) &gt; [1, 2, 3] list(map(float,[1,2,3])) &gt; [1.0, 2.0, 3.0]  # \u0410 \u0432\u043e\u0442 \u043a\u0430\u043a \u0434\u0435\u043b\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u044c\u0448\u0435 [float(i) for i in [1,2,3]] &gt; [1.0, 2.0, 3.0]<\/code><\/pre>\n<h2>9. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u0430\u0431\u043e\u0440\u0430<\/h2>\n<p>\u041c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u0430\u0431\u043e\u0440\u043e\u0432. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u0431\u043e\u0440 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u0440\u0435\u043d\u044c \u0432\u0441\u0435\u0445 \u0447\u0435\u0442\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435.<\/p>\n<pre><code class=\"python\"># \u041a\u0432\u0430\u0434\u0440\u0430\u0442 \u0432\u0441\u0435\u0445 \u0447\u0435\u0442\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 {x**2 for x in range(10) if x%2==0} &gt; {0, 4, 16, 36, 64}<\/code><\/pre>\n<h2>10. Fizz Buzz<\/h2>\n<p>\u042d\u0442\u043e \u0442\u0435\u0441\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u0447\u0442\u043e \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0447\u0438\u0441\u043b\u0430 \u043e\u0442 1 \u0434\u043e 100. \u041d\u043e \u0434\u043b\u044f \u0447\u0438\u0441\u0435\u043b, \u043a\u0440\u0430\u0442\u043d\u044b\u0445 \u0442\u0440\u0435\u043c, \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u00ab<strong>Fizz<\/strong>\u00bb \u0432\u043c\u0435\u0441\u0442\u043e \u0447\u0438\u0441\u043b\u0430, \u0430 \u0434\u043b\u044f \u043a\u0440\u0430\u0442\u043d\u044b\u0445 \u043f\u044f\u0442\u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u00ab<strong>Buzz<\/strong>\u00bb. (\u0435\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043d\u043e \u0438 \u0442\u0440\u0435\u043c, \u0438 \u043f\u044f\u0442\u0438, \u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, <strong>FizzBuzz<\/strong>).<\/p>\n<p>\u041f\u043e\u0445\u043e\u0436\u0435, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0446\u0438\u043a\u043b\u044b \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 if-else. \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u0442\u0435\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0430 \u043b\u044e\u0431\u043e\u043c \u0434\u0440\u0443\u0433\u043e\u043c \u044f\u0437\u044b\u043a\u0435, \u0442\u043e \u0432\u0430\u043c, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u043e 10 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430. \u041d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f python, \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c FizzBuzz \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u043a\u043e\u0434\u0430.<\/p>\n<pre><code class=\"python\">['FizzBuzz' if i%3==0 and i%5==0 else 'Fizz' if i%3==0 else 'Buzz' if i%5==0 else i  for i in range(1,20)]<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043a\u043e\u0434\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0446\u0438\u043a\u043b\u0430 \u043e\u0442 1 \u0434\u043e 20, \u0430 \u0437\u0430\u0442\u0435\u043c \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0446\u0438\u043a\u043b\u0430 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u043d\u0430 3 \u0438\u043b\u0438 5. \u0415\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u043c\u044b \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0447\u0438\u0441\u043b\u043e \u043d\u0430 Fizz \u0438\u043b\u0438 Buzz \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e (\u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043e\u0431\u043e\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0447\u0438\u0441\u043b\u043e \u043d\u0430 FizzBuzz).<\/p>\n<h2>11. \u041f\u0430\u043b\u0438\u043d\u0434\u0440\u043e\u043c<\/h2>\n<p>\u041f\u0430\u043b\u0438\u043d\u0434\u0440\u043e\u043c &#8212; \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u0438\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e.<\/p>\n<pre><code class=\"python\">text = 'level' ispalindrome = text == text[::-1] ispalindrome &gt; True<\/code><\/pre>\n<h2>12. \u0426\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u0435\u043b\u0430\u043c\u0438, \u0432 \u0441\u043f\u0438\u0441\u043a\u0435<\/h2>\n<pre><code class=\"python\">lis = list(map(int, input().split())) print(lis) &gt; 1 2 3 4 5 6 7 8 [1, 2, 3, 4, 5, 6, 7, 8]<\/code><\/pre>\n<h2>13. \u041b\u044f\u043c\u0431\u0434\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/h2>\n<p><strong>\u041b\u044f\u043c\u0431\u0434\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/strong> &#8212; \u044d\u0442\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u0430\u044f <strong>\u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/strong>. <\/p>\n<p><strong>\u041b\u044f\u043c\u0431\u0434\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/strong> \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e <strong>__\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435<\/strong>.<\/p>\n<pre><code class=\"python\">sqr = lambda x: x * x  ##\u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0430\u044f \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u043b\u044e\u0431\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 sqr(10) &gt; 100<\/code><\/pre>\n<h2>14. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435<\/h2>\n<pre><code class=\"python\">num = 5 if num in [1,2,3,4,5]:      print('present') &gt; present<\/code><\/pre>\n<h2>15. \u0412\u044b\u0432\u043e\u0434 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d\u044b &#8212; \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u043c\u0435\u043d\u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u0432\u043b\u0435\u043a\u0430\u043b\u043e. \u0412 python \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u043a\u043e\u0434\u0430.<\/p>\n<pre><code class=\"python\">n = 5 print('\\n'.join('?' * i for i in range(1, n + 1))) &gt; ? ?? ??? ???? ?????<\/code><\/pre>\n<h2>16. \u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b\u0430<\/h2>\n<p>\u0424\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b &#8212; \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0438 \u0432\u0441\u0435\u0445 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043f\u0435\u0440\u0435\u0434 \u043d\u0438\u043c.<\/p>\n<pre><code class=\"python\">import math n = 6 math.factorial(n) &gt; 720<\/code><\/pre>\n<h2>17. \u0420\u044f\u0434 \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438<\/h2>\n<p>\u0420\u044f\u0434 \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 &#8212; \u044d\u0442\u043e \u0441\u0435\u0440\u0438\u044f \u0447\u0438\u0441\u0435\u043b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043a\u0430\u0436\u0434\u043e\u0435 \u0447\u0438\u0441\u043b\u043e (\u0447\u0438\u0441\u043b\u043e \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438) \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0443\u043c\u043c\u043e\u0439 \u0434\u0432\u0443\u0445 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0447\u0438\u0441\u0435\u043b. \u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0440\u044f\u0434 \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438: 1, 1, 2, 3, 5, 8, 13 \u0438 \u0442.\u0434. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u0446\u0438\u043a\u043b for \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0440\u044f\u0434\u0430 \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 \u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u043c \u043d\u0430\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435.<\/p>\n<pre><code class=\"python\">fibo = [0,1] [fibo.append(fibo[-2]+fibo[-1]) for i in range(5)] fibo &gt; [0, 1, 1, 2, 3, 5, 8]<\/code><\/pre>\n<h2>18. \u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u0447\u0438\u0441\u043b\u043e<\/h2>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u0447\u0438\u0441\u043b\u043e &#8212; \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c\u043e \u043d\u0430 \u0441\u0435\u0431\u044f \u0438 1. \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: 2,3,5,7 \u0438 \u0442. \u0414. \u0427\u0442\u043e\u0431\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u043f\u0438\u0441\u043a\u0430 \u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c \u0438 \u043b\u044f\u043c\u0431\u0434\u0430 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0447\u0438\u0441\u0435\u043b.<\/p>\n<pre><code class=\"python\">list(filter(lambda x:all(x % y != 0 for y in range(2, x)), range(2, 13))) &gt; [2, 3, 5, 7, 11]<\/code><\/pre>\n<h2>19. \u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430<\/h2>\n<pre><code class=\"python\">findmax = lambda x,y: x if x &gt; y else y  findmax(5,14) &gt; 14 \u0438\u043b\u0438  max(5,14)<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043a\u043e\u0434\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043b\u044f\u043c\u0431\u0434\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0438 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043d\u0438\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e.<\/p>\n<h2>20. \u041b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0430\u043b\u0433\u0435\u0431\u0440\u0430<\/h2>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0432 2 \u0438\u043b\u0438 5 \u0440\u0430\u0437. \u041a\u043e\u0434 \u043d\u0438\u0436\u0435 \u043f\u043e\u043a\u0430\u0436\u0435\u0442, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<pre><code class=\"python\">def scale(lst, x): return [i*x for i in lst]  scale([2,3,4], 2) ## \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 &gt; [4,6,8]<\/code><\/pre>\n<h2>21. \u0422\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0432 python \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0432\u0441\u0435\u0433\u043e \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u043a\u043e\u0434\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044e zip.<\/p>\n<pre><code class=\"python\">a=[[1,2,3],    [4,5,6],    [7,8,9]]  transpose = [list(i) for i in zip(*a)]  transpose &gt; [[1, 4, 7], [2, 5, 8], [3, 6, 9]]<\/code><\/pre>\n<h2>22. \u041f\u043e\u0434\u0441\u0447\u0435\u0442 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430<\/h2>\n<p>\u042d\u0442\u043e \u0432\u0430\u0436\u043d\u044b\u0439 \u0438 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435. \u0412 python \u0435\u0441\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 re, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u0437\u0430 \u043d\u0430\u0441.<\/p>\n<pre><code class=\"python\">import re; len(re.findall('python','python is a programming language. python is python.')) &gt; 3<\/code><\/pre>\n<h2>23. \u0417\u0430\u043c\u0435\u043d\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \u0434\u0440\u0443\u0433\u0438\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c<\/h2>\n<pre><code class=\"python\">\"python is a programming language. python is python\".replace(\"python\",'Java') &gt; Java is a programming language. Java is Java<\/code><\/pre>\n<h2>24. \u0421\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u044f \u043f\u043e\u0434\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u043d\u0435\u0442\u044b<\/h2>\n<p>\u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u0442\u0430\u043a \u0432\u0430\u0436\u043d\u043e, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440 \u0438\u0437 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432.<\/p>\n<pre><code class=\"python\">import random; random.choice(['Head',\"Tail\"]) &gt; Head<\/code><\/pre>\n<h2>25. \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0433\u0440\u0443\u043f\u043f<\/h2>\n<pre><code class=\"python\">groups = [(a, b) for a in ['a', 'b'] for b in [1, 2, 3]]  groups &gt; [('a', 1), ('a', 2), ('a', 3), ('b', 1), ('b', 2), ('b', 3)]<\/code><\/pre>\n<hr>\n<p>\u042f \u043f\u043e\u0434\u0435\u043b\u0438\u043b\u0441\u044f \u0432\u0441\u0435\u043c\u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c\u0438 \u0438 \u0432\u0430\u0436\u043d\u044b\u043c\u0438 \u043e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u0438\u043a\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0437\u043d\u0430\u044e. \u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0435\u0449\u0451, \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/540486\/\"> https:\/\/habr.com\/ru\/post\/540486\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p><em>\u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u0442 Python \u0432\u0435\u043b\u0438\u043a\u0438\u043c<\/em><\/p>\n<p><a href=\"https:\/\/levelup.gitconnected.com\/25-useful-python-one-liners-that-you-should-ec613df18260\" rel=\"noopener noreferrer nofollow\">\u041e\u0440\u0438\u0433\u0438\u043d\u0430\u043b &#171;25 Useful Python One-Liners That You Should know&#187; \u043e\u0442 Abhay Parashar<\/a><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p><em>\u041f\u0435\u0440\u0435\u0434 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435\u043c: \u0432 \u0440\u0443\u043a\u0430\u0445 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u0435 \u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b. \u041e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u0438\u043a\u0438, \u043a\u0430\u043a \u0438 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0430\u0445\u0430\u0440, &#8212; \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u0433\u0440\u0430\u043c\u043e\u0442\u043d\u043e\u0433\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u0432\u0430\u0448\u0443 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0432 \u0433\u043b\u0430\u0437\u0430\u0445 \u043a\u043e\u043b\u043b\u0435\u0433, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0441\u0432\u0435\u0440\u0445\u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0443\u0441\u0438\u043b\u0438\u0439. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c.<\/em><\/p>\n<p>\u0412 \u0442\u043e\u0442 \u0434\u0435\u043d\u044c, \u043a\u043e\u0433\u0434\u0430 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u0432\u043e\u044e \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u043a\u043e\u0434\u0430 \u043d\u0430 Python, \u044f \u0431\u044b\u043b \u043e\u0447\u0430\u0440\u043e\u0432\u0430\u043d \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u043e\u0439, \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u043a\u0440\u0443\u0442\u043e\u0441\u0442\u044c\u044e \u0435\u0433\u043e \u043e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u0438\u043a\u043e\u0432. \u0412 \u0441\u0432\u043e\u0435\u043c \u0431\u043b\u043e\u0433\u0435 \u044f \u0445\u043e\u0447\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u043d\u0430 Python.<\/p>\n<h2>1. \u0421\u043c\u0435\u043d\u043a\u0430 \u0434\u0432\u0443\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/h2>\n<pre><code class=\"python\"># a = 4 b = 5 a,b = b,a # print(a,b) &gt;&gt; 5,4<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0447\u0435\u0433\u043e-\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043c\u0435\u043d\u044f\u0435\u043c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0434\u0432\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 &#8212; \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0438\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438.<\/p>\n<h2>2. \u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/h2>\n<pre><code class=\"python\">a,b,c = 4,5.5,'Hello' #print(a,b,c) &gt;&gt; 4,5.5,hello<\/code><\/pre>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u044f\u0442\u044b\u0435 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0437\u0430 \u0440\u0430\u0437. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434, \u0432\u044b \u0434\u0430\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 var \u0437\u0430 \u0440\u0430\u0437. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u043b\u044f \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0440\u0430\u0437\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<pre><code class=\"python\">a,b,*c = [1,2,3,4,5] print(a,b,c) &gt; 1 2 [3,4,5]<\/code><\/pre>\n<h2>3. \u0421\u0443\u043c\u043c\u0430 \u0447\u0435\u0442\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0432 \u0441\u043f\u0438\u0441\u043a\u0435<\/h2>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432, \u043d\u043e \u043b\u0443\u0447\u0448\u0438\u0439 \u0438 \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<pre><code class=\"python\">a = [1,2,3,4,5,6] s = sum([num for num in a if num%2 == 0]) print(s) &gt;&gt; 12<\/code><\/pre>\n<h2>4. \u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430<\/h2>\n<p><code>del<\/code> &#8212; \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0435 \u0432 Python \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<pre><code class=\"python\">#### \u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0432\u0441\u0435 \u0447\u0435\u0442\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 a = [1,2,3,4,5] del a[1::2] print(a) &gt;[1, 3, 5]<\/code><\/pre>\n<h2>5. \u0427\u0442\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432<\/h2>\n<pre><code class=\"python\">lst = [line.strip() for line in open('data.txt')] print(lst)<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u0441\u043f\u0438\u0441\u043e\u043a. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0446\u0438\u043a\u043b\u0430 <code>for<\/code> \u0447\u0438\u0442\u0430\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0437\u0430 \u0441\u0442\u0440\u043e\u043a\u043e\u0439. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>strip<\/code> \u0443\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0435 \u043b\u0438\u0448\u043d\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e. \u041d\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<pre><code class=\"python\">list(open('data.txt')) ##\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 with \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043a\u0440\u043e\u0435\u0442 \u0444\u0430\u0439\u043b \u043f\u043e\u0441\u043b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f with open(\"data.txt\") as f: lst=[line.strip() for line in f] print(lst)<\/code><\/pre>\n<h2>6. \u0417\u0430\u043f\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0444\u0430\u0439\u043b<\/h2>\n<pre><code class=\"python\">with open(\"data.txt\",'a',newline='\\n') as f: f.write(\"Python is awesome\")<\/code><\/pre>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043a\u043e\u0434 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0444\u0430\u0439\u043b data.txt, \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u0435\u0449\u0435 \u043d\u0435\u0442, \u0430 \u0437\u0430\u0442\u0435\u043c \u043d\u0430\u043f\u0438\u0448\u0435\u0442 \u0432 \u044d\u0442\u043e\u043c \u0444\u0430\u0439\u043b\u0435 <code>Python is awesome<\/code>.<\/p>\n<h2>7. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u043e\u0432<\/h2>\n<pre><code class=\"python\">lst = [i for i in range(0,10)] print(lst) &gt; [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]  \u0438\u043b\u0438  lst = list(range(0,10)) print(lst)<\/code><\/pre>\n<p>\u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0442\u0440\u043e\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u0442 \u0436\u0435 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<pre><code class=\"python\">lst = [(\"Hello \"+i) for i in ['Karl','Abhay','Zen']] print(lst) &gt; ['Hello Karl', 'Hello Abhay', 'Hello Zen']<\/code><\/pre>\n<h2>8. Mapping \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435<\/h2>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435. \u041f\u0435\u0440\u0432\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432\u0430\u043c \u0432 \u0433\u043e\u043b\u043e\u0432\u0443, &#8212; \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0446\u0438\u043a\u043b, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u043e \u0432\u0441\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0434\u0438\u043d \u0437\u0430 \u0434\u0440\u0443\u0433\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0441\u0442\u0430\u0440\u043e\u0439 \u0448\u043a\u043e\u043b\u044b \u0432 Python. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>map<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u0437\u0430 \u043d\u0430\u0441.<\/p>\n<pre><code class=\"python\">list(map(int,['1','2','3'])) &gt; [1, 2, 3] list(map(float,[1,2,3])) &gt; [1.0, 2.0, 3.0]  # \u0410 \u0432\u043e\u0442 \u043a\u0430\u043a \u0434\u0435\u043b\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u044c\u0448\u0435 [float(i) for i in [1,2,3]] &gt; [1.0, 2.0, 3.0]<\/code><\/pre>\n<h2>9. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u0430\u0431\u043e\u0440\u0430<\/h2>\n<p>\u041c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u0430\u0431\u043e\u0440\u043e\u0432. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u0431\u043e\u0440 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u043e\u0440\u0435\u043d\u044c \u0432\u0441\u0435\u0445 \u0447\u0435\u0442\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435.<\/p>\n<pre><code class=\"python\"># \u041a\u0432\u0430\u0434\u0440\u0430\u0442 \u0432\u0441\u0435\u0445 \u0447\u0435\u0442\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 {x**2 for x in range(10) if x%2==0} &gt; {0, 4, 16, 36, 64}<\/code><\/pre>\n<h2>10. Fizz Buzz<\/h2>\n<p>\u042d\u0442\u043e \u0442\u0435\u0441\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u0447\u0442\u043e \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0447\u0438\u0441\u043b\u0430 \u043e\u0442 1 \u0434\u043e 100. \u041d\u043e \u0434\u043b\u044f \u0447\u0438\u0441\u0435\u043b, \u043a\u0440\u0430\u0442\u043d\u044b\u0445 \u0442\u0440\u0435\u043c, \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u00ab<strong>Fizz<\/strong>\u00bb \u0432\u043c\u0435\u0441\u0442\u043e \u0447\u0438\u0441\u043b\u0430, \u0430 \u0434\u043b\u044f \u043a\u0440\u0430\u0442\u043d\u044b\u0445 \u043f\u044f\u0442\u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u00ab<strong>Buzz<\/strong>\u00bb. (\u0435\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043d\u043e \u0438 \u0442\u0440\u0435\u043c, \u0438 \u043f\u044f\u0442\u0438, \u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, <strong>FizzBuzz<\/strong>).<\/p>\n<p>\u041f\u043e\u0445\u043e\u0436\u0435, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0446\u0438\u043a\u043b\u044b \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 if-else. \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u0442\u0435\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0430 \u043b\u044e\u0431\u043e\u043c \u0434\u0440\u0443\u0433\u043e\u043c \u044f\u0437\u044b\u043a\u0435, \u0442\u043e \u0432\u0430\u043c, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u043e 10 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430. \u041d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f python, \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c FizzBuzz \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u043a\u043e\u0434\u0430.<\/p>\n<pre><code class=\"python\">['FizzBuzz' if i%3==0 and i%5==0 else 'Fizz' if i%3==0 else 'Buzz' if i%5==0 else i  for i in range(1,20)]<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043a\u043e\u0434\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0446\u0438\u043a\u043b\u0430 \u043e\u0442 1 \u0434\u043e 20, \u0430 \u0437\u0430\u0442\u0435\u043c \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0446\u0438\u043a\u043b\u0430 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u043d\u0430 3 \u0438\u043b\u0438 5. \u0415\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u043c\u044b \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0447\u0438\u0441\u043b\u043e \u043d\u0430 Fizz \u0438\u043b\u0438 Buzz \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e (\u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043e\u0431\u043e\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0447\u0438\u0441\u043b\u043e \u043d\u0430 FizzBuzz).<\/p>\n<h2>11. \u041f\u0430\u043b\u0438\u043d\u0434\u0440\u043e\u043c<\/h2>\n<p>\u041f\u0430\u043b\u0438\u043d\u0434\u0440\u043e\u043c &#8212; \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u0438\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e.<\/p>\n<pre><code class=\"python\">text = 'level' ispalindrome = text == text[::-1] ispalindrome &gt; True<\/code><\/pre>\n<h2>12. \u0426\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u0435\u043b\u0430\u043c\u0438, \u0432 \u0441\u043f\u0438\u0441\u043a\u0435<\/h2>\n<pre><code class=\"python\">lis = list(map(int, input().split())) print(lis) &gt; 1 2 3 4 5 6 7 8 [1, 2, 3, 4, 5, 6, 7, 8]<\/code><\/pre>\n<h2>13. \u041b\u044f\u043c\u0431\u0434\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/h2>\n<p><strong>\u041b\u044f\u043c\u0431\u0434\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/strong> &#8212; \u044d\u0442\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u0430\u044f <strong>\u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/strong>. <\/p>\n<p><strong>\u041b\u044f\u043c\u0431\u0434\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/strong> \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e <strong>__\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435<\/strong>.<\/p>\n<pre><code class=\"python\">sqr = lambda x: x * x  ##\u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0430\u044f \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u043b\u044e\u0431\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 sqr(10) &gt; 100<\/code><\/pre>\n<h2>14. \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435<\/h2>\n<pre><code class=\"python\">num = 5 if num in [1,2,3,4,5]:      print('present') &gt; present<\/code><\/pre>\n<h2>15. \u0412\u044b\u0432\u043e\u0434 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432<\/h2>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d\u044b &#8212; \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u043c\u0435\u043d\u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u0432\u043b\u0435\u043a\u0430\u043b\u043e. \u0412 python \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u043a\u043e\u0434\u0430.<\/p>\n<pre><code class=\"python\">n = 5 print('\\n'.join('?' * i for i in range(1, n + 1))) &gt; ? ?? ??? ???? ?????<\/code><\/pre>\n<h2>16. \u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b\u0430<\/h2>\n<p>\u0424\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b &#8212; \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0438 \u0432\u0441\u0435\u0445 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043f\u0435\u0440\u0435\u0434 \u043d\u0438\u043c.<\/p>\n<pre><code class=\"python\">import math n = 6 math.factorial(n) &gt; 720<\/code><\/pre>\n<h2>17. \u0420\u044f\u0434 \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438<\/h2>\n<p>\u0420\u044f\u0434 \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 &#8212; \u044d\u0442\u043e \u0441\u0435\u0440\u0438\u044f \u0447\u0438\u0441\u0435\u043b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043a\u0430\u0436\u0434\u043e\u0435 \u0447\u0438\u0441\u043b\u043e (\u0447\u0438\u0441\u043b\u043e \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438) \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0443\u043c\u043c\u043e\u0439 \u0434\u0432\u0443\u0445 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0447\u0438\u0441\u0435\u043b. \u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0440\u044f\u0434 \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438: 1, 1, 2, 3, 5, 8, 13 \u0438 \u0442.\u0434. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438 \u0446\u0438\u043a\u043b for \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0440\u044f\u0434\u0430 \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 \u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u043c \u043d\u0430\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435.<\/p>\n<pre><code class=\"python\">fibo = [0,1] [fibo.append(fibo[-2]+fibo[-1]) for i in range(5)] fibo &gt; [0, 1, 1, 2, 3, 5, 8]<\/code><\/pre>\n<h2>18. \u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u0447\u0438\u0441\u043b\u043e<\/h2>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u0447\u0438\u0441\u043b\u043e &#8212; \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c\u043e \u043d\u0430 \u0441\u0435\u0431\u044f \u0438 1. \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: 2,3,5,7 \u0438 \u0442. \u0414. \u0427\u0442\u043e\u0431\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u043f\u0438\u0441\u043a\u0430 \u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c \u0438 \u043b\u044f\u043c\u0431\u0434\u0430 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0447\u0438\u0441\u0435\u043b.<\/p>\n<pre><code class=\"python\">list(filter(lambda x:all(x % y != 0 for y in range(2, x)), range(2, 13))) &gt; [2, 3, 5, 7, 11]<\/code><\/pre>\n<h2>19. \u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430<\/h2>\n<pre><code class=\"python\">findmax = lambda x,y: x if x &gt; y else y  findmax(5,14) &gt; 14 \u0438\u043b\u0438  max(5,14)<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043a\u043e\u0434\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043b\u044f\u043c\u0431\u0434\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0438 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043d\u0438\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e.<\/p>\n<h2>20. \u041b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0430\u043b\u0433\u0435\u0431\u0440\u0430<\/h2>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0432 2 \u0438\u043b\u0438 5 \u0440\u0430\u0437. \u041a\u043e\u0434 \u043d\u0438\u0436\u0435 \u043f\u043e\u043a\u0430\u0436\u0435\u0442, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<pre><code class=\"python\">def scale(lst, x): return [i*x for i in lst]  scale([2,3,4], 2) ## \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 &gt; [4,6,8]<\/code><\/pre>\n<h2>21. \u0422\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0432 python \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0432\u0441\u0435\u0433\u043e \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u043a\u043e\u0434\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044e zip.<\/p>\n<pre><code class=\"python\">a=[[1,2,3],    [4,5,6],    [7,8,9]]  transpose = [list(i) for i in zip(*a)]  transpose &gt; [[1, 4, 7], [2, 5, 8], [3, 6, 9]]<\/code><\/pre>\n<h2>22. \u041f\u043e\u0434\u0441\u0447\u0435\u0442 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430<\/h2>\n<p>\u042d\u0442\u043e \u0432\u0430\u0436\u043d\u044b\u0439 \u0438 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435. \u0412 python \u0435\u0441\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 re, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u0437\u0430 \u043d\u0430\u0441.<\/p>\n<pre><code class=\"python\">import re; len(re.findall('python','python is a programming language. python is python.')) &gt; 3<\/code><\/pre>\n<h2>23. \u0417\u0430\u043c\u0435\u043d\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \u0434\u0440\u0443\u0433\u0438\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c<\/h2>\n<pre><code class=\"python\">\"python is a programming language. python is python\".replace(\"python\",'Java') &gt; Java is a programming language. Java is Java<\/code><\/pre>\n<h2>24. \u0421\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u044f \u043f\u043e\u0434\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u043d\u0435\u0442\u044b<\/h2>\n<p>\u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u0442\u0430\u043a \u0432\u0430\u0436\u043d\u043e, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440 \u0438\u0437 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432.<\/p>\n<pre><code class=\"python\">import random; random.choice(['Head',\"Tail\"]) &gt; Head<\/code><\/pre>\n<h2>25. \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0433\u0440\u0443\u043f\u043f<\/h2>\n<pre><code class=\"python\">groups = [(a, b) for a in ['a', 'b'] for b in [1, 2, 3]]  groups &gt; [('a', 1), ('a', 2), ('a', 3), ('b', 1), ('b', 2), ('b', 3)]<\/code><\/pre>\n<hr>\n<p>\u042f \u043f\u043e\u0434\u0435\u043b\u0438\u043b\u0441\u044f \u0432\u0441\u0435\u043c\u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c\u0438 \u0438 \u0432\u0430\u0436\u043d\u044b\u043c\u0438 \u043e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u0438\u043a\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0437\u043d\u0430\u044e. \u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0435\u0449\u0451, \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/540486\/\"> https:\/\/habr.com\/ru\/post\/540486\/<\/a><br \/><\/br><\/br><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-317329","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/317329","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=317329"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/317329\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=317329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=317329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=317329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}