{"id":685,"date":"2021-07-06T11:54:55","date_gmt":"2021-07-06T11:54:55","guid":{"rendered":"https:\/\/www.bearloga.space\/?page_id=685"},"modified":"2021-07-06T11:54:55","modified_gmt":"2021-07-06T11:54:55","slug":"python-urok-9-rabota-s-fajlami","status":"publish","type":"page","link":"https:\/\/www.bearloga.space\/en\/python-urok-9-rabota-s-fajlami\/","title":{"rendered":"Python \u0423\u0440\u043e\u043a 9. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u041d\u0430 \u0443\u0440\u043e\u043a\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0432 \u041f\u0438\u0442\u043e\u043d: \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u0438 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0444\u0430\u0439\u043b \u0438 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u0424\u0430\u0439\u043b\u044b \u0432 Python<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 \u0446\u0435\u043b\u043e\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u044e\u0442 \u0434\u0432\u0430 \u0442\u0438\u043f\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 (\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0438\u043c\u0438):<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u0444\u0430\u0439\u043b\u044b<\/strong>&nbsp;\u0441\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b;<\/li><li><strong>\u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0435 (\u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0435) \u0444\u0430\u0439\u043b\u044b<\/strong>&nbsp;(\u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0435 \u043a\u043e\u0434\u044b \u0442\u0430\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0438\u0441\u0443\u043d\u043a\u0438, \u0437\u0432\u0443\u043a\u0438, \u0432\u0438\u0434\u0435\u043e\u0444\u0438\u043b\u044c\u043c\u044b);<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u042d\u0442\u0430\u043f\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u0430\u0439\u043b\u043e\u043c:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>\u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0444\u0430\u0439\u043b\u0430;<ul><li>\u0440\u0435\u0436\u0438\u043c \u0447\u0442\u0435\u043d\u0438\u044f,<\/li><li>\u0440\u0435\u0436\u0438\u043c \u0437\u0430\u043f\u0438\u0441\u0438,<\/li><li>\u0440\u0435\u0436\u0438\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445.<\/li><\/ul><\/li><li>\u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0444\u0430\u0439\u043b\u043e\u043c;<\/li><li>\u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u0444\u0430\u0439\u043b\u0430.<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 python \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0444\u0430\u0439\u043b \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e&nbsp;<strong>\u0444\u0443\u043d\u043a\u0446\u0438\u0438 open<\/strong>&nbsp;\u0441 \u0434\u0432\u0443\u043c\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 (\u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443);<\/li><li>\u0440\u0435\u0436\u0438\u043c \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0444\u0430\u0439\u043b\u0430:<\/li><li>\u00abr\u00bb \u2013 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435,<\/li><li>\u00abw\u00bb \u2013 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c (\u0435\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f),<\/li><li>\u00aba\u00bb \u2013 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043d\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 \u043a\u043e\u0434\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Fin = open ( &#8220;input.txt&#8221; )<br> Fout = open ( &#8220;output.txt&#8221;, &#8220;w&#8221; ) <em># \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438<\/em> Fout.close() Fin.close()<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u0420\u0410\u0411\u041e\u0422\u0410 \u0421 \u0422\u0415\u041a\u0421\u0422\u041e\u0412\u042b\u041c\u0418 \u0424\u0410\u0419\u041b\u0410\u041c\u0418 \u0412 \u041f\u0418\u0422\u041e\u041d<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>\u0427\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430<\/strong>\u00a0\u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438:<ol><li>\u043f\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430\u00a0<strong>readline<\/strong>:<\/li><\/ol><\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">str1 = Fin.readline() <em># str1 = 1<\/em>\nstr2 = Fin.readline() <em># str2 = 2<\/em><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u043c\u0435\u0442\u043e\u0434\u00a0<strong>read<\/strong>\u00a0\u0447\u0438\u0442\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u0444\u0430\u0439\u043b\u0430:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">str = Fin.read() \n''' \nstr = 1\n2\n3\n'''<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u043e\u0432 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f\u00a0<strong>\u043c\u0435\u0442\u043e\u0434 split<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u043f\u0440\u043e\u0431\u0435\u043b\u0430\u043c \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">str = Fin.readline().split()\n<strong>print<\/strong>(str[0])\n<strong>print<\/strong>(str[1])<\/pre>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\"><strong>\u041f\u0440\u0438\u043c\u0435\u0440:<\/strong><br>\u0412 \u0444\u0430\u0439\u043b\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0434\u0432\u0430 \u0447\u0438\u0441\u043b\u0430. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445.<\/p>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\">\u0444\u0430\u0439\u043b input.txt:<br>12 17<\/p>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\">\u043e\u0442\u0432\u0435\u0442:<br>27<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>1.\u0441\u043f\u043e\u0441\u043e\u0431:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">Fin = open ( \"D:\/input.txt\" ) \nstr = Fin.readline().split()\nx, y = int(str[0]), int(str[1])\n<strong>print<\/strong>(x+y)<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>2.\u0441\u043f\u043e\u0441\u043e\u0431:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">...\nx, y = [int(i) <strong>for<\/strong> i <strong>in<\/strong> s]\n<strong>print<\/strong>(x+y)<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u0412 python\u00a0<strong>\u043c\u0435\u0442\u043e\u0434 write \u0441\u043b\u0443\u0436\u0438\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0444\u0430\u0439\u043b<\/strong>:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">Fout = open ( \"D:\/out.txt\",\"w\" ) \nFout.write (\"hello\")<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u0417\u0430\u043f\u0438\u0441\u044c \u0432 \u0444\u0430\u0439\u043b \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439<strong><br>\u0448\u0430\u0431\u043b\u043e\u043d \u0432\u044b\u0432\u043e\u0434\u0430<\/strong>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">Fout.write ( \"{:d} + {:d} = {:d}<strong>\\n<\/strong>\".format(x, y, x+y) )\n\n\u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432\u00a0<strong>{:d}<\/strong>\u00a0\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430\u00a0<strong>format<\/strong>\u00a0(\u0441\u043d\u0430\u0447\u0430\u043b\u0430 x, \u0437\u0430\u0442\u0435\u043c y, \u0437\u0430\u0442\u0435\u043c x+y).<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u0410\u043d\u0430\u043b\u043e\u0433\u043e\u043c \u00ab\u043f\u0430\u0441\u043a\u0430\u043b\u0435\u0432\u0441\u043a\u043e\u0433\u043e\u00bb eof (\u0435\u0441\u043b\u0438 \u043a\u043e\u043d\u0435\u0446 \u0444\u0430\u0439\u043b\u0430) \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0446\u0438\u043a\u043b\u0430\u00a0<strong>while<\/strong>\u00a0\u0438\u043b\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a \u0432 \u0441\u043f\u0438\u0441\u043e\u043a:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">1. <strong>while<\/strong> True: \n   str = Fin.readline() \n   <strong>if<\/strong> <strong>not<\/strong> str: <strong>break<\/strong>\n2. Fin = open ( \"input.txt\" )  \nlst = Fin.readlines() \n <strong>for<\/strong> str <strong>in<\/strong> lst:    \n  <strong>print<\/strong> ( str, end = \"\" )  Fin.close()<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u043b\u044f Python:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>for<\/strong> str <strong>in<\/strong> open ( \"input.txt\" ): \n   <strong>print<\/strong> ( str, end = \"\" )<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 Python 9_1:<\/strong><br>\u0421\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0437 \u0444\u0430\u0439\u043b\u0430&nbsp;<strong>input.txt<\/strong>&nbsp;10 \u0447\u0438\u0441\u0435\u043b (\u0447\u0438\u0441\u043b\u0430 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0431\u0435\u043b). \u0417\u0430\u0442\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0444\u0430\u0439\u043b&nbsp;<strong>output.txt<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438.<strong>\u041f\u0440\u0438\u043c\u0435\u0440:<\/strong><br>\u0421\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0437 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0447\u0438\u0441\u043b\u0430 \u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0445 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0432 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&#x270d; \u0420\u0435\u0448\u0435\u043d\u0438\u0435:<br>&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 Python \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441\u043f\u0438\u0441\u043e\u043a, \u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e.<\/li><li>\u0421\u0447\u0438\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0447\u0438\u0441\u0435\u043b:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">lst = [] \n<strong>while<\/strong> True:\n   st = Fin.readline() \n   <strong>if<\/strong> <strong>not<\/strong> st: <strong>break<\/strong> \n   lst.append (int(st))<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430.<\/li><li>\u0417\u0430\u043f\u0438\u0441\u044c \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 (\u0441\u043f\u0438\u0441\u043a\u0430) \u0432 \u0444\u0430\u0439\u043b:<\/li><li>\u0418\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0444\u0430\u0439\u043b:<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Fout = open ( &#8220;output.txt&#8221;, &#8220;w&#8221; ) <br>Fout.write (str(lst)) <em># \u0444\u0443\u043d\u043a\u0446\u0438\u044f str \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u0435<\/em> <br>Fout.close()<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u0434\u0440\u0443\u0433\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 ;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>for<\/strong> x <strong>in<\/strong> lst: \n    Fout.write (str(x)+\"<strong>\\n<\/strong>\") <em># \u0437\u0430\u043f\u0438\u0441\u044c \u0441 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430<\/em><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 Python 9_2:<\/strong><br>\u0412 \u0444\u0430\u0439\u043b\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430. \u041d\u0430\u0439\u0442\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0444\u0430\u0439\u043b.<strong>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 Python 9_3:<\/strong><br>\u0412 \u0444\u0430\u0439\u043b\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0441\u0442\u043e\u043b\u0431\u0438\u043a \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430. \u041e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043f\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044e \u0441\u0443\u043c\u043c\u044b \u0446\u0438\u0444\u0440 \u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0444\u0430\u0439\u043b.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<strong>\u041f\u0440\u0438\u043c\u0435\u0440:<\/strong><br>\u0412 \u0444\u0430\u0439\u043b \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430\u0445 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0444\u0438\u0440\u043c\u044b \u0432 \u0432\u0438\u0434\u0435:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u0418\u0432\u0430\u043d\u043e\u0432 45 \u0431\u0443\u0445\u0433\u0430\u043b\u0442\u0435\u0440\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><em>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430\u0445, \u0432\u043e\u0437\u0440\u0430\u0441\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u0435\u043d\u044c\u0448\u0435&nbsp;<strong>40<\/strong>.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&#x270d; \u0420\u0435\u0448\u0435\u043d\u0438\u0435:<br>&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u0442.\u0435. \u0432\u0442\u043e\u0440\u044b\u043c \u043f\u043e \u0441\u0447\u0435\u0442\u0443 \u0441\u043b\u043e\u0432\u043e\u043c \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0440\u0430\u0441\u0442, \u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c<strong>\u00a0\u043c\u0435\u0442\u043e\u0434 split<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442 \u0441\u043b\u043e\u0432\u0430 \u043f\u043e \u043f\u0440\u043e\u0431\u0435\u043b\u0430\u043c. \u041f\u043e\u0434 \u043d\u043e\u043c\u0435\u0440\u043e\u043c 1 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0442\u0438 \u0432\u043e\u0437\u0440\u0430\u0441\u0442:<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>st = Fin.readline() <br>data = st.split() <br>stAge = data[1] <br>intAge = int(stAge)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>\u0411\u043e\u043b\u0435\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">st = Fin.readline() \nintAge = int(st.split()[1])<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>while<\/strong> True: \n  st = Fin.readline() \n  <strong>if<\/strong> <strong>not<\/strong> s: <strong>break<\/strong> \n  intAge = int (st.split()[1])<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u041d\u043e \u043b\u0443\u0447\u0448\u0435 \u0432 \u0441\u0442\u0438\u043b\u0435 Python:<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>for<\/strong> st <strong>in<\/strong> open ( &#8220;input.txt&#8221; ):<br> intAge = int (st.split()[1]) <br><strong>if<\/strong> intAge &lt; 40: <br>Fout.write (st)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 Python 9_4:<\/strong><br>\u0412 \u0444\u0430\u0439\u043b \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e \u0434\u0435\u0442\u044f\u0445 \u0434\u0435\u0442\u0441\u043a\u043e\u0433\u043e \u0441\u0430\u0434\u0430:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u0418\u0432\u0430\u043d\u043e\u0432 \u0438\u0432\u0430\u043d 5 \u043b\u0435\u0442\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><em>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0442\u0430\u0440\u0448\u0435\u0433\u043e \u0438 \u0441\u0430\u043c\u043e\u0433\u043e \u043c\u043b\u0430\u0434\u0448\u0435<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041d\u0430 \u0443\u0440\u043e\u043a\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0432 \u041f\u0438\u0442\u043e\u043d: \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u0438 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0444\u0430\u0439\u043b \u0438 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0424\u0430\u0439\u043b\u044b [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-685","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/pages\/685","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/comments?post=685"}],"version-history":[{"count":0,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/pages\/685\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/media?parent=685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/categories?post=685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bearloga.space\/en\/wp-json\/wp\/v2\/tags?post=685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}