{"id":670,"date":"2021-07-06T09:38:13","date_gmt":"2021-07-06T09:38:13","guid":{"rendered":"https:\/\/www.bearloga.space\/?page_id=670"},"modified":"2021-07-06T09:38:14","modified_gmt":"2021-07-06T09:38:14","slug":"python-urok-2-rabota-s-cziklami","status":"publish","type":"page","link":"https:\/\/www.bearloga.space\/uk\/python-urok-2-rabota-s-cziklami\/","title":{"rendered":"Python \u0423\u0440\u043e\u043a 2. \u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0446\u0438\u043a\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 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0432\u0438\u0434\u0430\u043c\u0438 \u0446\u0438\u043a\u043b\u043e\u0432 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u041f\u0438\u0442\u043e\u043d (Python): \u0446\u0438\u043a\u043b \u0441 \u043f\u0440\u0435\u0434\u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c\u00a0<strong>While<\/strong>\u00a0\u0438 \u0446\u0438\u043a\u043b \u0441\u043e \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u043e\u043c\u00a0<strong>For<\/strong>. \u041e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0432 Python \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u0426\u0438\u043a\u043b WHILE<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u0426\u0438\u043a\u043b while \u2014 \u0446\u0438\u043a\u043b \u0441 \u043f\u0440\u0435\u0434\u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c. \u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>i = 5<br> <strong>while<\/strong> i &lt; 15:<br> <strong>print<\/strong>(i)<br> i = i + 2 <em># \u0432\u044b\u0432\u043e\u0434 5 7 9 11 13<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0415\u0449\u0435 \u043f\u0440\u0438\u043c\u0435\u0440:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>i = 0 <br><strong>while<\/strong> i &lt; 100: <br>i += 1 \u00a0<br> <strong>print<\/strong>(i) <em># 100<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u041a\u041e\u041c\u041c\u0415\u041d\u0422\u0410\u0420\u0418\u0418 \u0412 PYTHON<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u041e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u044b\u0439 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441&nbsp;<code>#<\/code>.<br>\u0411\u043b\u043e\u0447\u043d\u044b\u0439 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a (\u0441\u0442\u0440\u043e\u0433\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0431\u043b\u043e\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f \u043d\u0435\u0442 \u0432 \u041f\u0438\u0442\u043e\u043d\u0435):<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><em>#\u041e\u0434\u043d\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u044b\u0435 \u041f\u0438\u0442\u043e\u043d \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438<\/em> &nbsp; <em># \u042d\u0442\u043e<\/em> <em># \u0431\u043b\u043e\u0447\u043d\u044b\u0439 \u0438\u043b\u0438 \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u044b\u0439<\/em> <em># \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>&#8221;&#8217; \u0442\u043e\u0436\u0435 \u0431\u043b\u043e\u0447\u043d\u044b\u0439 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 &#8221;&#8217;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u041e\u041f\u0415\u0420\u0410\u0422\u041e\u0420\u042b BREAK \u0418 CONTINUE<\/h3>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/labs-org.ru\/wp-content\/uploads\/2016\/05\/1-6.png\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"https:\/\/labs-org.ru\/wp-content\/uploads\/2016\/05\/1-6.png\" alt=\"\u0446\u0438\u043a\u043b while \u043d\u0430 \u043f\u0438\u0442\u043e\u043d\u0435\" class=\"wp-image-348\"\/><\/a><\/figure><\/div>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440&nbsp;<strong>break<\/strong>&nbsp;\u2014 \u0432\u044b\u0445\u043e\u0434 \u0438\u0437 \u0446\u0438\u043a\u043b\u0430<br>\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440&nbsp;<strong>continue<\/strong>&nbsp;\u2014 \u0432\u044b\u0445\u043e\u0434 \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0446\u0438\u043a\u043b\u0430<\/p><\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0417\u0430\u0434\u0430\u043d\u0438\u0435:<\/strong>&nbsp;\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>a=0<br> <strong>while<\/strong> a!=10:<br>       a=a+1 <br><strong>if<\/strong> a==5: <br>      <strong>continue<\/strong><br> <strong>print<\/strong> (a) <br><strong>if<\/strong> a==7: <br>      <strong>break<\/strong><br> <strong>print<\/strong> (&#8220;\u0432\u0441\u0451!&#8221;)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u041f\u0440\u0438\u043c\u0435\u0440:<\/strong>&nbsp;\u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0434\u043b\u044f \u0438\u0433\u0440\u044b: \u0417\u0430\u0433\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e&nbsp;<code>random<\/code>). \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0443\u0433\u0430\u0434\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e. \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u0443\u0433\u0430\u0434\u044b\u0432\u0430\u0435\u0442, \u0442\u043e \u0435\u043c\u0443 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0443\u0433\u0430\u0434\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0441\u043d\u043e\u0432\u0430 \u0438 \u0432\u044b\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430, \u0447\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043b\u0438 \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0433\u043e. \u0422\u0430\u043a \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u043e\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u0432\u0432\u0435\u0434\u0435\u0442 \u0441\u043b\u043e\u0432\u043e&nbsp;<em>exit<\/em>. \u0411\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437&nbsp;<code>while True:<\/code>&nbsp;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&#x270d; \u0420\u0435\u0448\u0435\u043d\u0438\u0435:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>import<\/strong> random\n&nbsp;\nnumber = random.randint(0, 100)\n&nbsp;\n<strong>while<\/strong> True:\n    answer = input('\u0423\u0433\u0430\u0434\u0430\u0439 \u0447\u0438\u0441\u043b\u043e: ')\n    <strong>if<\/strong> answer == \"\" <strong>or<\/strong> answer == \"exit\":\n        <strong>print<\/strong>(\"\u0412\u044b\u0445\u043e\u0434 \u0438\u0437 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b\")\n        <strong>break<\/strong>\n&nbsp;\n    <strong>if<\/strong> <strong>not<\/strong> answer.isdigit():\n        <strong>print<\/strong>(\"\u0412\u0432\u0435\u0434\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e\")\n        <strong>continue<\/strong>\n&nbsp;\n    answer = int(answer)\n&nbsp;\n    <strong>if<\/strong> answer == number:\n        <strong>print<\/strong>('\u0412\u0435\u0440\u043d\u043e!')\n        <strong>break<\/strong>\n&nbsp;\n    <strong>elif<\/strong> answer &gt; number:\n        <strong>print<\/strong>('\u0417\u0430\u0433\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435')\n    <strong>else<\/strong>:\n        <strong>print<\/strong>('\u0417\u0430\u0433\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043c\u0435\u043d\u044c\u0448\u0435')<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 Python 2_1:<\/strong>&nbsp;\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u043d\u0435\u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u0447\u0438\u0441\u043b\u0430. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0443\u043c\u043c\u0443 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438 \u0441\u0443\u043c\u043c\u0443 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b. \u0417\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c \u0432\u0432\u043e\u0434 \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u0438 \u0432\u0432\u043e\u0434\u0435 0. \u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e<a href=\"https:\/\/labs-org.ru\/metus-pellentesque-quisque-faucibus\/\" target=\"_blank\" rel=\"noopener\">&nbsp;int()<\/a>.<br><br><strong>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0447\u0438\u0441\u043b\u0430:\n-5  7  8  -2  0\n\u0441\u0443\u043c\u043c\u0430 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445: 15, \u0441\u0443\u043c\u043c\u0430 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445: -7\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 Python 2_2:<\/strong>&nbsp;\u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0446\u0438\u043a\u043b\u0430 \u0440\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0440\u044f\u0434 \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438:&nbsp;<em>1 1 2 3 5 8 13 21<\/em>.<strong>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 Python 2_3:<\/strong>&nbsp;\u0417\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044e\u0442\u0441\u044f&nbsp;<em>10<\/em>&nbsp;\u0447\u0438\u0441\u0435\u043b (\u0446\u0435\u043b\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0442 0 \u0434\u043e 1000). \u041e\u043f\u0438\u0448\u0438\u0442\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043d\u0430\u0439\u0442\u0438 \u0438 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0440\u0435\u0434\u0438 \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u0447\u0451\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u043d\u0435 \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430 \u0442\u0440\u0438.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;<br><strong>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0447\u0438\u0441\u043b\u0430:\n5  7  8  22  9  12  15  0   2   3\n\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:  2\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u0426\u0438\u043a\u043b FOR<\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/labs-org.ru\/wp-content\/uploads\/2016\/05\/1-7.png\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"https:\/\/labs-org.ru\/wp-content\/uploads\/2016\/05\/1-7.png\" alt=\"\u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0446\u0438\u043a\u043b\u0430 For \u043d\u0430 \u041f\u0438\u0442\u043e\u043d\u0435\" class=\"wp-image-349\"\/><\/a><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 Python \u0446\u0438\u043a\u043b for \u0438\u043c\u0435\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441:<br><br>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>for<\/strong> i <strong>in<\/strong> range(3):<br> <strong>print<\/strong>(i) <em># 0<\/em> <em># 1<\/em> <em># 2<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u041f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0434\u0432\u0443\u043c\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>for<\/strong> i <strong>in<\/strong> range(5, 8):<br> <strong>print<\/strong>(i) <em># 5<\/em> <em># 6<\/em> <em># 7<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u041f\u0440\u0438\u043c\u0435\u0440:<\/strong><br>\u0412\u044b\u0432\u0435\u0441\u0442\u0438 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0434\u0432\u043e\u0439\u043a\u0438 \u0441 1-\u0439 \u043f\u043e 10-\u044e.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&#x270d; \u0420\u0435\u0448\u0435\u043d\u0438\u0435:<br><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>for<\/strong> x <strong>in<\/strong> range(1,11): <br><strong>print<\/strong> ( 2**x ) \u00a0 <em># 2 4 8 16 &#8230; 1024<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u0428\u0430\u0433 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 \u0446\u0438\u043a\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>for<\/strong> x <strong>in<\/strong> range(1,11,2): <br><strong>print<\/strong> ( 2**x )<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u041e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0430\u0433:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>for<\/strong> i <strong>in<\/strong> range(10, 7, -1): <br><strong>print<\/strong>(i) <em># 10<\/em> <em># 9<\/em> <em># 8<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u0415\u0449\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>for<\/strong> i <strong>in<\/strong> &#8216;hello world&#8217;:<br> <strong>if<\/strong> i == &#8216;o&#8217;:<br>      <strong>continue<\/strong><br> <strong>print<\/strong>(i, end=&#8221;) \u00a0 <em># hell wrld<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f&nbsp;<strong>break<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>for<\/strong> i <strong>in<\/strong> &#8216;hello world&#8217;:<br> <strong>if<\/strong> i == &#8216;l&#8217;:<br>      <strong>break<\/strong><br> <strong>print<\/strong>(i, end=&#8221;) \u00a0 <em># he<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0417\u0430\u0434\u0430\u043d\u0438\u0435:<\/strong>&nbsp;\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>a=0 <br>n=10<br> <strong>for<\/strong> i <strong>in<\/strong> range(1,n+1,2): <br>a=a+1 <br><strong>if<\/strong> a==5:<br>       <strong>continue<\/strong> <br><strong>print<\/strong> (a)<br> <strong>if<\/strong> a==7: <br>         <strong>break<\/strong><br> <strong>print<\/strong> (&#8220;\u0432\u0441\u0451!&#8221;)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 Python 2_4:<\/strong>&nbsp;\u0421\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e&nbsp;<code>N<\/code>&nbsp;\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u0432\u0432\u043e\u0434\u0438\u043c\u044b\u0445 \u0447\u0438\u0441\u0435\u043b.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0447\u0438\u0441\u0435\u043b:\n6 \n\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0447\u0438\u0441\u043b\u0430:\n-5  4  12  9  7  2\n\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:  4,83\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u0421\u041b\u0423\u0427\u0410\u0419\u041d\u041e\u0415 \u0427\u0418\u0421\u041b\u041e<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u0412 Python \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0432\u0443\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>random()<\/strong>&nbsp;\u2013 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0438\u0437 \u043f\u043e\u043b\u0443\u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430 [0,1) ;<\/li><li><strong>randint(a,b)<\/strong>&nbsp;\u2013 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0438\u0437 \u043e\u0442\u0440\u0435\u0437\u043a\u0430 [a,b].<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u041d\u043e \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><em># \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/em> <strong>from<\/strong> random <strong>import<\/strong> randint <em># \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0446\u0435\u043b\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043e\u0442 1 \u0434\u043e 10<\/em> x = randint(1,11) &nbsp; <em># \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0432 \u043f\u043e\u043b\u0443\u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0435 \u043e\u0442 5 \u0434\u043e 11<\/em> <strong>from<\/strong> random <strong>import<\/strong> random x = 6*random() + 5<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 Python 2_5:<\/strong>&nbsp;\u0418\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 (2_4) \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438.<strong>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 Python 2_6:<\/strong><br>\u041d\u0430\u0439\u0434\u0438\u0442\u0435 \u0432\u0441\u0435 \u0442\u0440\u0451\u0445\u0437\u043d\u0430\u0447\u043d\u044b\u0435 \u0438 \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u0437\u043d\u0430\u0447\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0410\u0440\u043c\u0441\u0442\u0440\u043e\u043d\u0433\u0430.\u0427\u0438\u0441\u043b\u043e \u0410\u0440\u043c\u0441\u0442\u0440\u043e\u043d\u0433\u0430. \u0427\u0438\u0441\u043b\u043e\u043c \u0410\u0440\u043c\u0441\u0442\u0440\u043e\u043d\u0433\u0430 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0441\u0443\u043c\u043c\u0430 \u0446\u0438\u0444\u0440 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e, \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0445 \u0432 N-\u043d\u0443\u044e \u0441\u0442\u0435\u043f\u0435\u043d\u044c (N \u2013 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0446\u0438\u0444\u0440 \u0432 \u0447\u0438\u0441\u043b\u0435) \u0440\u0430\u0432\u043d\u0430 \u0441\u0430\u043c\u043e\u043c\u0443 \u0447\u0438\u0441\u043b\u0443.<br><em>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 153 = 1<sup>3<\/sup>&nbsp;+ 5<sup>3<\/sup>&nbsp;+ 3<sup>3<\/sup>.<\/em><strong>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 Python 2_7:<\/strong><br>\u041d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e N \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0432\u0441\u0435 \u0430\u0432\u0442\u043e\u043c\u043e\u0440\u0444\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u043d\u0435 \u043f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435 N.\u0410\u0432\u0442\u043e\u043c\u043e\u0440\u0444\u043d\u044b\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u0440\u0430\u0432\u043d\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0446\u0438\u0444\u0440\u0430\u043c \u0441\u0432\u043e\u0435\u0433\u043e \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0430.&nbsp;<em>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 25<sup>2<\/sup>&nbsp;= 625.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u0426\u0438\u043a\u043b for in \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u043e\u0440\u0442\u0435\u0436\u0430\u043c\u0438 (\u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u041f\u0440\u0438\u043c\u0435\u0440:<\/strong>&nbsp;\u0412\u044b\u0432\u0435\u0441\u0442\u0438 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0446\u0432\u0435\u0442\u0430 \u0440\u0430\u0434\u0443\u0433\u0438 \u0441 \u0438\u0445 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432\u044b\u043c\u0438 \u043d\u043e\u043c\u0435\u0440\u0430\u043c\u0438:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1-\u0439 \u0446\u0432\u0435\u0442 \u0440\u0430\u0434\u0443\u0433\u0438 - \u044d\u0442\u043e \u043a\u0440\u0430\u0441\u043d\u044b\u0439\n...\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">&#x270d; \u0420\u0435\u0448\u0435\u043d\u0438\u0435:<br>&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>i = 1<br> <strong>for<\/strong> color <strong>in<\/strong> &#8216;\u043a\u0440\u0430\u0441\u043d\u044b\u0439&#8217;, &#8216;\u043e\u0440\u0430\u043d\u0436\u0435\u0432\u044b\u0439&#8217;, &#8216;\u0436\u0435\u043b\u0442\u044b\u0439&#8217;, &#8216;\u0437\u0435\u043b\u0435\u043d\u044b\u0439&#8217;, &#8216;\u0433\u043e\u043b\u0443\u0431\u043e\u0439&#8217;, &#8216;\u0441\u0438\u043d\u0438\u0439&#8217;, &#8216;\u0444\u0438\u043e\u043b\u0435\u0442\u043e\u0432\u044b\u0439&#8217;: <br>      <strong>print<\/strong>(i,&#8217;-\u0439 \u0446\u0432\u0435\u0442 \u0440\u0430\u0434\u0443\u0433\u0438 &#8211; \u044d\u0442\u043e &#8216;, color) <br> i += 1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;<br>\u0414\u0440\u0443\u0433\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u043e\u043c \u0446\u0438\u043a\u043b\u0430:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>for<\/strong> i <strong>in<\/strong> 1,2,3,&#8217;one&#8217;,&#8217;two&#8217;,&#8217;three&#8217;: <br>  <strong>print<\/strong>(i)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u041f\u0440\u0438 \u043f\u0435\u0440\u0432\u044b\u0445 \u0442\u0440\u0435\u0445 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f\u0445 \u0446\u0438\u043a\u043b\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f&nbsp;<code>i<\/code>&nbsp;\u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430&nbsp;<strong>int<\/strong>, \u043f\u0440\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0442\u0440\u0435\u0445&nbsp;\u2014 \u0442\u0438\u043f\u0430&nbsp;<strong>str<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0415\u0449\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>name = &#8220;Ivan&#8221; <br>\u00a0 <strong>for<\/strong> letter <strong>in<\/strong> name: <br><strong>print<\/strong>(letter) <br><em># I<\/em> <br><em># v<\/em><br> <em># a<\/em><br> <em># n<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 Python 2_8:<\/strong>&nbsp;\u0420\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u043d\u0438 \u043d\u0435\u0434\u0435\u043b\u0438 \u0441 \u0438\u0445 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432\u044b\u043c\u0438 \u043d\u043e\u043c\u0435\u0440\u0430\u043c\u0438. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0440\u044f\u0434\u043e\u043c \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u043b\u0438 \u044d\u0442\u043e \u0434\u0435\u043d\u044c \u0438\u043b\u0438 \u0440\u0430\u0431\u043e\u0447\u0438\u0439. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0440\u0442\u0435\u0436.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1-\u0439 \u0434\u0435\u043d\u044c \u043d\u0435\u0434\u0435\u043b\u0438 - \u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a, \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0434\u0435\u043d\u044c\n...<\/pre>\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 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0432\u0438\u0434\u0430\u043c\u0438 \u0446\u0438\u043a\u043b\u043e\u0432 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u041f\u0438\u0442\u043e\u043d (Python): \u0446\u0438\u043a\u043b \u0441 \u043f\u0440\u0435\u0434\u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c\u00a0While\u00a0\u0438 \u0446\u0438\u043a\u043b \u0441\u043e \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u043e\u043c\u00a0For. \u041e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f [&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":[66,69],"tags":[],"class_list":["post-670","page","type-page","status-publish","hentry","category-python","category-obuchenie"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/pages\/670","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/comments?post=670"}],"version-history":[{"count":0,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/pages\/670\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/media?parent=670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/categories?post=670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bearloga.space\/uk\/wp-json\/wp\/v2\/tags?post=670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}