{"id":9174,"date":"2016-05-05T22:22:47","date_gmt":"2016-05-06T02:22:47","guid":{"rendered":"http:\/\/cscircles.cemc.uwaterloo.ca\/?page_id=9174"},"modified":"2017-06-28T14:31:57","modified_gmt":"2017-06-28T18:31:57","slug":"2-zh","status":"publish","type":"page","link":"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/2-zh\/","title":{"rendered":"2: \u51fd\u6570"},"content":{"rendered":"<!-- Please retain this notice and add more notes if you create a new version.<br \/>\nOriginal lesson author: Graeme Kemkes, gdkemkes@alumni.uwaterloo.ca, http:\/\/cscircles.ca<br \/>\nLicense: http:\/\/creativecommons.org\/licenses\/by-nc-sa\/3.0\/-->\n<p>&nbsp;<\/p>\n<p>\u6211\u4eec\u5df2\u7ecf\u89c1\u8fc7\u4e00\u4e2a\u7528\u4e8e\u8f93\u51fa\u4fe1\u606f\uff0c\u540d\u4e3a<code>print()<\/code>\u7684\u51fd\u6570\u3002\u5f53\u4f60\u8981\u7528\u5230\u4e00\u4e2a\u51fd\u6570\u65f6\uff0c\u4f60\u9700\u8981\u5199\u4e0b\u4ed6\u7684\u540d\u5b57\u5e76\u5728\u540e\u9762\u7684\u62ec\u53f7\u4e2d\u653e\u5165\u4e00\u4e9b<em>\u5b9e\u53c2<\/em>\u3002\u7b80\u5355\u6765\u8bb2\uff0c\u5b9e\u53c2\u8fd9\u4e2a\u8bcd\u7684\u610f\u601d\u5c31\u662f\u4e00\u4e2a\u51fd\u6570\u7684\u8f93\u5165\u3002<\/p>\n<p>\u7136\u540e\uff0c\u8fd9\u4e2a\u51fd\u6570\u5c31\u4f1a\u6839\u636e\u5b83\u7684\u5b9e\u53c2\u6765\u505a\u4e00\u4e9b\u4e8b\u3002\u5f53\u4e00\u4e2a\u51fd\u6570\u6709\u591a\u4e2a\u5b9e\u53c2\u65f6\uff0c\u4f60\u9700\u8981\u7528\u9017\u53f7(<code>,<\/code>)\u5c06\u5b83\u4eec\u5206\u5f00\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u7ed9 <code>print<\/code>\u591a\u4e2a\u5b9e\u53c2\uff1b\u5b83\u4f1a\u6309\u5e8f\u7684\u5c06\u5b83\u4eec\u6253\u5370\u8f93\u51fa\uff0c\u5e76\u7528\u7a7a\u683c\u6765\u5206\u5f00\u4ed6\u4eec\u3002<\/p>\n<p>\u6211\u4eec\u4f1a\u7528\u4e0b\u9762\u8fd9\u4e2a\u4f8b\u5b50\u6765\u8bc1\u660e\u3002<\/p>\n<p><form class=\"pbform\" action=\"#\" id=\"pbform0\" method=\"POST\">\n<div class='pybox modeNeutral  facultative' id='pybox0'>\n<div class=\"heading\"><span class=\"title\">Example<\/span><\/div>\u6253\u5370\u4e09\u4e2a\u6570\u5b57<div class='pyboxTextwrap pyboxCodewrap RO '  style='height: 58px;'><textarea wrap='off' name='usercode0' id='usercode0'  cols=10 rows=2 readonly='readonly'  style = 'height : 58px;'  class='pyboxCode RO'>\nx = 3\nprint(x, x +   x  , x * x)<\/textarea><\/div>\n<div id='pbhistory0' class='flexcontain' style='display:none;'><\/div>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit0' value=' '\/><\/td>\n<\/tr><\/table><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse0\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"0\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"51b3011fc5915e78e76a5018d2450e45\"\/>\n<div id='pbresults0' class='pbresults'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>document.getElementById(\"submit0\").value = \"Run program\";document.getElementById(\"inputInUse0\").value = \"N\";<\/script>\n<table class='pywarn'><tr><td class='pywarnleft'><img src='https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-content\/plugins\/pybox\/files\/warning.png'\/><\/td><td class='pywarnright'><span> \u4e0a\u9762\u793a\u4f8b\u7a0b\u5e8f\u4e2d\u591a\u4f59\u7684\u7a7a\u683c\u5bf9\u8f93\u51fa\u5e76\u6ca1\u6709\u4efb\u4f55\u5f71\u54cd\u3002\u591a\u4f59\u7684\u7a7a\u683c\u5728\u5176\u4ed6\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u4e5f\u90fd\u662f\u65e0\u610f\u4e49\u7684\u3002\u4e0d\u8fc7\uff0c\u8981\u5c0f\u5fc3\u6bcf\u4e00\u884c<em><strong>\u5f00\u59cb\u65f6<\/strong>\u7684\u989d\u5916\u7a7a\u683c<\/em>\uff0c\u4ed6\u4eec\u53eb\u505a<em>\u7f29\u8fdb<\/em>,\u5e76\u4e14\u6709\u4e00\u4e2a\u7279\u6b8a\u7684\u610f\u4e49\u3002\u5f53\u4f60\u4e0d\u6b63\u786e\u7684\u4f7f\u7528\u65f6\uff0c\u7f29\u8fdb\u53ef\u80fd\u4f1a\u9020\u6210<a href=\"http:\/\/cscircles.cemc.uwaterloo.ca\/console\/?consolecode=print%28%22This%20line%20is%20ok%22%29%0A%20print%28%22This%20one%20starts%20with%20a%20space%22%29\" target=\"_blank\">\u9519\u8bef\uff08\u70b9\u51fb\u94fe\u63a5\u6765\u770b\u4e00\u4e2a\u793a\u4f8b\uff09<\/a>\u3002\u4f60\u5c06\u4f1a\u5728\u51e0\u8282\u8bfe\u540e\u5b66\u5230\u600e\u6837\u6b63\u786e\u7684\u4f7f\u7528\u7f29\u8fdb\u3002  <\/span><\/td><\/table><\/p>\n<p>\u4e00\u4e2a\u51fd\u6570\u4e5f\u53ef\u4ee5\u5f52\u8fd8\u4e00\u4e2a\u503c\uff08\u5c31\u50cf\u4e00\u4e2a\u8f93\u51fa\uff09\u3002\u4f8b\u5982\u51fd\u6570 <code>max()<\/code>\u00a0\u4f1a\u5f52\u8fd8\u5b9e\u53c2\u4e2d\u6700\u5927\u7684\u90a3\u4e2a\u6570\uff0c\u8fd9\u610f\u5473\u7740\u8fd9\u4e9b\u5b9e\u53c2\u5fc5\u987b\u90fd\u662f\u6570\u5b57\u3002<br \/>\n<form class=\"pbform\" action=\"#\" id=\"pbform1\" method=\"POST\">\n<div class='pybox modeNeutral  facultative' id='pybox1'>\n<div class=\"heading\"><span class=\"title\">Example<\/span><\/div><em>\u8bd5\u7740\u5728\u8fd0\u884c\u4e4b\u524d\u9884\u6d4b\u4e0b\u9762\u8fd9\u4e2a\u7a0b\u5e8f\u7684\u8f93\u51fa<\/em><div class='pyboxTextwrap pyboxCodewrap RO '  style='height: 58px;'><textarea wrap='off' name='usercode1' id='usercode1'  cols=10 rows=2 readonly='readonly'  style = 'height : 58px;'  class='pyboxCode RO'>\nprint(max(42, 17))\nprint(max(128,281,812))<\/textarea><\/div>\n<div id='pbhistory1' class='flexcontain' style='display:none;'><\/div>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit1' value=' '\/><\/td>\n<\/tr><\/table><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse1\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"1\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"63d7a889992170aa6cb0a32d6c940050\"\/>\n<div id='pbresults1' class='pbresults'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>document.getElementById(\"submit1\").value = \"Run program\";document.getElementById(\"inputInUse1\").value = \"N\";<\/script>\n<em>\u8fd4\u56de\u503c<\/em>\u8fd9\u4e2a\u540d\u8bcd\u6307\u7684\u662f\u4e00\u4e2a\u51fd\u6570\u5f52\u8fd8\u7684\u503c\u3002\u4f8b\u5982<code>max(42, 17)<\/code>\u8fd9\u4e2a\u51fd\u6570\uff0c\u6211\u4eec\u4f1a\u8bf4\u201c\u51fd\u6570<code>max<\/code>\u7684\u8fd4\u56de\u503c\u662f42\u3002\u201d<br \/>\n\u51fd\u6570<code>max<\/code>\u6709\u4e00\u4e2a\u8868\u73b0\u7c7b\u4f3c\u7684\u670b\u53cb\uff1a\u51fd\u6570<code>min<\/code>\uff0c\u5b83\u4f1a\u8fd4\u56de\u5b9e\u53c2\u4e2d<em>\u7684\u6700\u5c0f\u503c<\/em>\u3002<\/p>\n<div class='pybox modeNeutral' id='pybox2'>\n<img title='You have not yet completed this problem.' src='https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-content\/plugins\/pybox\/files\/icon.png' class='pycheck'\/><div class=\"heading\"><span class='type'>Multiple Choice Exercise: <\/span><span class='title'>\u6700\u5c0f\u4e0e\u6700\u5927\uff08\u4e00\uff09<\/span><\/div><div>\u4e0b\u9762\u8fd9\u4e2a\u7a0b\u5e8f\u7684\u8f93\u51fa\u662f\u4ec0\u4e48\uff1f<br \/>\n&lt;pre&gt;x = 13<br \/>\ny = 7<br \/>\na = max(x+y, x*2)<br \/>\nb = min(x, y)<br \/>\nprint(a,b)&lt;\/pre&gt;<br \/>\n<\/div><label>Your choice: <\/label><select id=\"pyselect2\"><option value=\"d\" selected>Select one<\/option><option value=\"r\">26 7<\/option><option value=\"w\">20 13<\/option><option value=\"w\">13 20<\/option><option value=\"w\">7 26<\/option><\/select><div class='pyboxbuttons'><input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" name=\"slug\" value=\"2.intro\"\/><input type='submit' style='margin:5px;' value='Check answer' onClick='pbMultiCheck(2)'\/><\/div><div class=\"pbresults\" id=\"pyMultiResults2\"><\/div><div class=\"epilogue\">Correct!<\/div><\/div>\n<p>\u51fd\u6570\u4eec\u53ef\u4ee5\u7ec4\u5408\u5728\u4e00\u8d77\u7528\u6765\u521b\u9020\u66f4\u590d\u6742\u7684\u8868\u8fbe\u5f0f\u3002<br \/>\n<div class='pybox modeNeutral' id='pybox3'>\n<img title='You have not yet completed this problem.' src='https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-content\/plugins\/pybox\/files\/icon.png' class='pycheck'\/><div class=\"heading\"><span class='type'>Short Answer Exercise: <\/span><span class='title'>\u6700\u5c0f\u4e0e\u6700\u5927\uff08\u4e8c\uff09<\/span><\/div>\u4e0b\u9762\u8fd9\u4e2a\u7a0b\u5e8f\u7684\u8f93\u51fa\u662f\u4ec0\u4e48\uff1f <a class=\"hintlink\"  id=\"hintlink4\">\u63d0\u793a<\/a><br \/>\n&lt;pre&gt;x = min(max(13, 7), 9)<br \/>\nprint(x)&lt;\/pre&gt;<br \/>\n<br><label for=\"pyShortAnswer3\">Your answer (enter a number): <\/label><input type=\"text\" onkeypress=\"{if (event.keyCode==13) pbShortCheck(3)}\" id=\"pyShortAnswer3\"><div class=\"pyboxbuttons\"><input type=\"hidden\" name=\"type\" value=\"number\"\/><input type=\"hidden\" name=\"correct\" value=\"9\"\/><input type=\"hidden\" name=\"slug\" value=\"2.compose\"\/><input type=\"hidden\" name=\"lang\" value=\"\"\/><input type='submit' style='margin:5px;' value='Check answer' onClick = 'pbShortCheck(3)'\/><\/div><div class=\"pbresults\" id=\"pyShortResults3\"><\/div><div class=\"epilogue\">Correct!<\/div><\/div>\n<p>\u5728Python\u4e2d\u4f60\u5e76\u4e0d\u4f1a\u53ea\u7528\u5230\u9884\u5148\u8bbe\u5b9a\u597d\u7684\u51fd\u6570\u3002\u5728\u63a5\u4e0b\u6765\u51e0\u8282\u8bfe\u4e2d\uff0c\u4f60\u4f1a\u5b66\u5230\u600e\u6837\u5b9a\u4e49\u65b0\u51fd\u6570\uff01<\/p>\n<h2>\u5e38\u89c1\u9519\u8bef<\/h2>\n<p>\u5982\u679c\u4f60\u5728\u8c03\u7528\u4e00\u4e2a\u51fd\u6570\u65f6\uff0c\u6ca1\u6709\u8db3\u591f\u7684\u5b9e\u53c2\u6216\u8005\u6709\u592a\u591a\u7684\u5b9e\u53c2\uff0c\u90a3\u4e48\u4f60\u4f1a\u5f97\u5230\u4e00\u4e2a\u9519\u8bef\u4fe1\u606f\u3002\u4f8b\u5982\uff0cmax \u9700\u8981\u81f3\u5c11\u4e00\u4e2a\u8f93\u5165\uff1a<br \/>\n<form class=\"pbform\" action=\"#\" id=\"pbform5\" method=\"POST\">\n<div class='pybox modeNeutral  facultative' id='pybox5'>\n<div class=\"heading\"><span class=\"title\">Example<\/span><\/div>\u8c03\u7528 <code>max<\/code>\u65f6\u6ca1\u6709\u8db3\u591f\u7684\u5b9e\u53c2\u3002<div class='pyboxTextwrap pyboxCodewrap RO '  style='height: 32px;'><textarea wrap='off' name='usercode5' id='usercode5'  cols=10 rows=1 readonly='readonly'  style = 'height : 32px;'  class='pyboxCode RO'>\nmax()<\/textarea><\/div>\n<div id='pbhistory5' class='flexcontain' style='display:none;'><\/div>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit5' value=' '\/><\/td>\n<\/tr><\/table><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse5\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"5\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"533d15721b982f77f37080b7877c5b1d\"\/>\n<div id='pbresults5' class='pbresults'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>document.getElementById(\"submit5\").value = \"Run program\";document.getElementById(\"inputInUse5\").value = \"N\";<\/script>\n<\/p>\n<p>\u5f53\u4f60\u7684\u4ee3\u7801\u6ca1\u6709\u6b63\u5e38\u8fd0\u884c\u65f6\uff0c\u4ed4\u7ec6\u9605\u8bfb\u4f60\u6536\u5230\u7684\u9519\u8bef\u4fe1\u606f\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u5bf9\u4e8e\u9519\u8bef\u7684\u5730\u65b9\uff0cPython \u901a\u5e38\u4f1a\u7ed9\u4f60\u975e\u5e38 \u6709\u7528\u7684\u53cd\u9988\u3002\u3002\u4f46\u6709\u4e00\u4e9b\u60c5\u5f62\u4e0b\uff0c\u4f60\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u601d\u8003\u624d\u80fd\u627e\u51fa\u95ee\u9898 \u2014 \u4e0b\u9762\u662f\u4e00\u4e2a\u4f8b\u5b50\u3002<\/p>\n<p><form class=\"pbform\" action=\"#\" id=\"pbform6\" method=\"POST\">\n<div class='pybox modeNeutral  facultative' id='pybox6'>\n<div class=\"heading\"><span class=\"title\">Example<\/span><\/div>\u6309\u4e0b\u00a0<strong>\u8fd0\u884c\u7a0b\u5e8f<\/strong>; \u5e76\u770b\u4e00\u770b\u4ea7\u751f\u7684\u9519\u8bef\u3002<div class='pyboxTextwrap pyboxCodewrap RO '  style='height: 58px;'><textarea wrap='off' name='usercode6' id='usercode6'  cols=10 rows=2 readonly='readonly'  style = 'height : 58px;'  class='pyboxCode RO'>\nsmaller = min(14, 99\nbigger = max(3, 4)<\/textarea><\/div>\n<div id='pbhistory6' class='flexcontain' style='display:none;'><\/div>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit6' value=' '\/><\/td>\n<\/tr><\/table><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse6\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"6\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"167beb08629b6fed87e7d3a0f4c7393e\"\/>\n<div id='pbresults6' class='pbresults'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>document.getElementById(\"submit6\").value = \"Run program\";document.getElementById(\"inputInUse6\").value = \"N\";<\/script>\n<\/p>\n<p>Python\u8bf4\u8fd9\u91cc\u6709\u4e00\u4e2a\u8bed\u6cd5\u9519\u8bef\uff0c\u4e5f\u5c31\u662f\u8bf4\u5b83\u65e0\u6cd5\u7406\u89e3\u4f60\u60f3\u5e72\u4ec0\u4e48\uff1a<\/p>\n<pre>\u00a0Traceback (most recent call last):\r\n   In line 2 of the code you submitted:\r\n     bigger = max(3, 4)\r\n          ^\r\n \u8bed\u6cd5\u9519\u8bef\uff1a\u65e0\u6548\u7684\u8bed\u6cd5<\/pre>\u4e8b\u5b9e\u4e0a\uff0c<code>bigger = max(3, 4)<\/code>\u8fd9\u884c\u5e76\u6ca1\u6709\u95ee\u9898\u3002\u771f\u6b63\u7684\u9519\u8bef\u5176\u5b9e\u662f\u7531\u524d\u4e00\u884c\u9020\u6210\u7684\uff1a\u6211\u4eec\u5fd8\u8bb0\u5728smaller = min(14, 99 \u540e\u52a0\u4e0a\u4e00\u4e2a\u53f3\u62ec\u53f7<code>)<\/code>\uff0c\u6240\u4ee5Python\u5f00\u59cb\u5728\u4e0b\u4e00\u884c\u5bfb\u627e\u53f3\u62ec\u53f7<code>)<\/code>\u3002\u56e0\u6b64\uff0c\u5f53\u4f60\u5728\u8c03\u8bd5\u7a0b\u5e8f\u5361\u4f4f\u65f6\uff0c\u8bd5\u7740\u68c0\u67e5Python\u63d0\u793a\u7684\u4e4b\u524d\u548c\u4e4b\u540e\u7684\u4ee3\u7801\u884c\u3002<\/p>\n<h2>\u7ec3\u4e60<\/h2>\n<p>\u8fd9\u662f\u4e00\u4e2a\u7528\u5230<code>min<\/code>\u548c<code>max<\/code>\u51fd\u6570\u7684\u4e24\u90e8\u5206\u7ec3\u4e60\u3002Maxime\u548cMiniac \u8fd9\u4e24\u5ea7\u57ce\u5e02\u4e4b\u95f4\u662f\u7528\u4e00\u4e9b\u6865\u6881\u8fde\u63a5\u7740\u7684\u3002\u6bcf\u5ea7\u6865\u6881\u90fd\u6709\u4e00\u4e2a\u4e0d\u540c\u7684\u627f\u91cd\u9650\u5236\u3002<br \/>\n<form class=\"pbform\" action=\"#\" id=\"pbform7\" method=\"POST\">\n<div class='pybox modeNeutral ' id='pybox7'>\n<img title='You have not yet completed this problem.' src='https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-content\/plugins\/pybox\/files\/icon.png' class='pycheck'\/><div class=\"heading\"><span class='type'>Coding Exercise: <\/span><span class='title'>\u4e00\u6761\u8def<\/span><\/div>\u5bf9\u4e8e\u7b2c\u4e00\u90e8\u5206\uff0c\u8fd9\u4e24\u4e2a\u57ce\u5e02\u4e4b\u95f4\u6709\u4e00\u6761\u5355\u884c\u9053\u3002\u8fd9\u6761\u8def\u6709\u4e09\u5ea7\u6865\uff0c\u91cd\u91cf\u9650\u5236\u5206\u522b\u4e3a<code>a<\/code>\u3001<code>b<\/code><code>c<\/code>\uff0c\u5982\u4e0b\u56fe\u6240\u793a:<\/p>\n<div><img loading=\"lazy\" decoding=\"async\" src=\"..\/wp-content\/lesson_files\/img\/2\/one-road-zh.png\" alt=\"\" width=\"802\" height=\"296\" \/><\/div>\n<p>\u8981\u60f3\u5728\u8fd9\u6761\u8def\u7ebf\u4e0a\u884c\u9a76\uff0c\u4f60\u7684\u5361\u8f66\u5fc5\u987b\u5148\u901a\u8fc7\u627f\u91cd\u9650\u5236\u4e3a<code>a<\/code>\u7684\u6865\u6881\uff0c\u63a5\u7740\u901a\u8fc7\u627f\u91cd\u9650\u5236\u4e3a<code>b<\/code>\u7684\u6865\u6881\uff0c\u6700\u540e\u901a\u8fc7\u627f\u91cd\u9650\u5236\u4e3a<code>c<\/code>\u7684\u6865\u6881\u3002\u5982\u679c\u4f60\u7684\u5361\u8f66\u8d85\u8fc7\u8fd9\u4e09\u4e2a\u627f\u91cd\u9650\u5236\u4e2d\u7684\u4efb\u610f\u4e00\u4e2a\u5c31\u4f1a\u53d1\u751f\u4e8b\u6545\u3002<em>\u7f16\u5199\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u4f7f\u5b83\u6253\u5370\u51fa\u5728\u8fd9\u6761\u8def\u4e0a\u8fd0\u8f93\u7684\u6700\u5927\u8f7d\u91cd\u91cf\u3002<\/em> \u4f60\u7684\u4ee3\u7801\u5e94\u8be5\u5047\u8bbe\u53d8\u91cf<code>a<\/code>\u3001<code>b<\/code>\u548c<code>c<\/code>\u5df2\u7ecf\u542b\u6709\u6865\u6881\u7684\u627f\u91cd\u9650\u5236\u3002<div class=\"helpOuter\" style=\"display: none;\"><div class=\"helpInner\"><div style=\"text-align: center\">You need to create an account and log in to ask a question.<\/div><\/div><\/div><div class='pyboxTextwrap pyboxCodewrap RW resizy'  style='height: 526px;'><textarea wrap='off' name='usercode7' id='usercode7'  cols=10 rows=20   class='pyboxCode RW'>\n<\/textarea><\/div>\n<div id='pbhistory7' class='flexcontain' style='display:none;'><\/div>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit7' value=' '\/><\/td>\n<td><input type='button' name='history' value=\"History\" onclick=\"historyClick(7,'2.bridges1')\" ><\/td>\n<td><input type='button' name='help' value=\"Help\" onclick=\"helpClick(7);\" ><\/td>\n<\/tr><\/table><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse7\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"7\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"48ebd83e99a6b443ec85b765d49d8fa7\"\/>\n<div id='pbresults7' class='pbresults'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>document.getElementById(\"submit7\").value = \"Run program\";document.getElementById(\"inputInUse7\").value = \"N\";<\/script>\n<\/p>\n<p><form class=\"pbform\" action=\"#\" id=\"pbform8\" method=\"POST\">\n<div class='pybox modeNeutral ' id='pybox8'>\n<img title='You have not yet completed this problem.' src='https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-content\/plugins\/pybox\/files\/icon.png' class='pycheck'\/><div class=\"heading\"><span class='type'>Coding Exercise: <\/span><span class='title'>\u4e24\u6761\u8def<\/span><\/div>\u7b2c\u4e8c\u90e8\uff1a\u73b0\u5728\u6211\u4eec\u4f1a\u544a\u8bc9\u4f60\u5b8c\u6574\u7684\u6545\u4e8b\u3002\u8fd9\u4e24\u4e2a\u57ce\u5e02\u4e4b\u95f4\u8fd8\u6709\u4e00\u6761\u542b\u6709\u4e24\u5ea7\u6865\u7684<strong>\u7b2c\u4e8c\u6761\u8def\u7ebf<\/strong>\uff0c\u7b2c\u4e00\u6761\u7684\u627f\u91cd\u9650\u5236\u4e3a<code>d<\/code>\uff0c\u7b2c\u4e8c\u6761\u7684\u627f\u91cd\u9650\u5236\u4e3a<code>e<\/code>\uff0c\u5982\u4e0b\u9762\u6240\u793a\u3002<\/p>\n<div style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" src=\"..\/wp-content\/lesson_files\/img\/2\/two-roads-zh.png\" alt=\"\" width=\"737\" height=\"428\" \/><\/div>\n<p>\u4f60\u7684\u5361\u8f66\u53ef\u4ee5\u8d70\u4efb\u610f\u4e00\u6761\u8def\u7ebf\u3002\u7f16\u5199\u4e00\u4e2a\u53ef\u4ee5\u6253\u5370\u51fa\u5728\u4e24\u4e2a\u57ce\u5e02\u4e4b\u95f4\u8fd0\u8f93\u7684\u6700\u5927\u91cd\u91cf\u7684\u7a0b\u5e8f\u3002\u5047\u8bbe\u53d8\u91cf<code>a<\/code>\u3001<code>b<\/code><code>c<\/code><code>d<\/code>\u548c<code>e<\/code>\u542b\u6709\u6865\u6881\u7684\u627f\u91cd\u9650\u5236\u3002 <a class=\"hintlink\"  id=\"hintlink9\">\u63d0\u793a<\/a> <a class=\"hintlink\"  id=\"hintlink10\">\u63d0\u793a2<\/a>\u00a0<div class=\"helpOuter\" style=\"display: none;\"><div class=\"helpInner\"><div style=\"text-align: center\">You need to create an account and log in to ask a question.<\/div><\/div><\/div><div class='pyboxTextwrap pyboxCodewrap RW resizy'  style='height: 526px;'><textarea wrap='off' name='usercode8' id='usercode8'  cols=10 rows=20   class='pyboxCode RW'>\n<\/textarea><\/div>\n<div id='pbhistory8' class='flexcontain' style='display:none;'><\/div>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit8' value=' '\/><\/td>\n<td><input type='button' name='history' value=\"History\" onclick=\"historyClick(8,'2.bridges2')\" ><\/td>\n<td><input type='button' name='help' value=\"Help\" onclick=\"helpClick(8);\" ><\/td>\n<\/tr><\/table><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse8\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"8\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"3ea38c4fa0f9edf01d064b10b1de419d\"\/>\n<div id='pbresults8' class='pbresults'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>document.getElementById(\"submit8\").value = \"Run program\";document.getElementById(\"inputInUse8\").value = \"N\";<\/script>\n<\/p>\n<h2>\u7ec3\u4e60\uff1a\u4ee3\u7801\u6392\u5e8f<\/h2>\n<p>\u4ee3\u7801\u6392\u5e8f\u53c8\u6765\u5566\uff0c\u4f60\u5fc5\u987b\u7528\u62d6\u62c9\u7684\u65b9\u5f0f\u91cd\u65b0\u6392\u5217\u5b83\u4eec\u4f7f\u5b83\u4eec\u53d8\u6210\u4e00\u4e2a\u6b63\u786e\u7684\u7a0b\u5e8f\u3002<\/p>\n<p><form class=\"pbform\" action=\"#\" id=\"pbform11\" method=\"POST\">\n<div class='pybox modeNeutral scramble' id='pybox11'>\n<img title='You have not yet completed this problem.' src='https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-content\/plugins\/pybox\/files\/icon.png' class='pycheck'\/><div class=\"heading\"><span class='type'>Scramble Exercise: <\/span><span class='title'>\u4ee3\u7801\u6392\u5e8f<\/span><\/div>\u91cd\u65b0\u6392\u5217\u8fd9\u4e9b\u4ee3\u7801\uff0c\u4f7f\u4ed6\u80fd\u4ee5<strong>\u5347\u5e8f<\/strong>\u7684\u987a\u5e8f\u6253\u5370\u8f93\u51fa<code>x<\/code>, <code>y<\/code> and <code>z<\/code>\u8fd9\u4e09\u4e2a\u6570\u5b57\uff0c\u4e5f\u5c31\u662f\u8bf4\u5148\u6253\u5370\u6700\u5c0f\u7684\u6570\uff0c\u63a5\u7740\u662f\u4e2d\u95f4\u7684\u6570\uff0c\u6700\u540e\u662f\u6700\u5927\u7684\u6570\u3002<br \/>\n<em>\u7528\u9f20\u6807\u8fdb\u884c\u62d6\u62c9\u6765\u91cd\u884c\u6392\u5217\u6bcf\u4e00\u884c<\/em>\u3002<ul class=\"pyscramble\" name=\"pyscramble\" id=\"pyscramble11\">\n <li class=\"pyscramble\">print(max(x, y, z))<\/li>\n <li class=\"pyscramble\">print(min(x, y, z))<\/li>\n <li class=\"pyscramble\">print(x+y+z-min(x, y, z)-max(x, y, z))<\/li>\n<\/ul>\n<input type='hidden' id='usercode11' name='usercode11'\/>\n<div id='pbhistory11' class='flexcontain' style='display:none;'><\/div>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit11' value=' '\/><\/td>\n<\/tr><\/table><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse11\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"11\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"eb50401ba88f216e5454217630052102\"\/>\n<div id='pbresults11' class='pbresults'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>document.getElementById(\"submit11\").value = \"Run program\";document.getElementById(\"inputInUse11\").value = \"N\";<\/script>\n<\/p>\n<p>\u5f53\u4f60\u5b8c\u6210\u4e0a\u9762\u7684\u7ec3\u4e60\u540e\uff0c\u4f60\u6709\u4e24\u4e2a\u9009\u62e9\uff1a<\/p>\n<ul>\n<li>\u4f60\u53ef\u4ee5\u76f4\u63a5\u8fdb\u5165<a class=\"open-same-window\" href=\"http:\/\/cscircles.cemc.uwaterloo.ca\/3-comments-literals\/\">\u7b2c\u4e09\u8bfe<\/a>\uff0c\u6216\u8005<\/li>\n<li>\u4f60\u53ef\u4ee5\u5728<a class=\"open-same-window\" href=\"http:\/\/cscircles.cemc.uwaterloo.ca\/2x-extra-practice\/\">\u8bfe\u7a0b2X<\/a>\u4e2d\u505a\u4e00\u4e9b\u5173\u4e8e\u51fd\u6570\u7684\u989d\u5916\u7ec3\u4e60\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; \u6211\u4eec\u5df2\u7ecf\u89c1\u8fc7\u4e00\u4e2a\u7528\u4e8e\u8f93\u51fa\u4fe1\u606f\uff0c\u540d\u4e3aprint()\u7684\u51fd\u6570\u3002\u5f53\u4f60\u8981\u7528\u5230\u4e00\u4e2a\u51fd\u6570\u65f6\uff0c\u4f60\u9700\u8981\u5199\u4e0b\u4ed6\u7684\u540d\u5b57\u5e76\u5728\u540e\u9762\u7684\u62ec\u53f7\u4e2d\u653e\u5165\u4e00\u4e9b\u5b9e\u53c2\u3002\u7b80\u5355\u6765\u8bb2\uff0c\u5b9e\u53c2\u8fd9\u4e2a\u8bcd\u7684\u610f\u601d\u5c31\u662f\u4e00\u4e2a\u51fd\u6570\u7684\u8f93\u5165\u3002 \u7136\u540e\uff0c\u8fd9\u4e2a\u51fd\u6570\u5c31\u4f1a\u6839\u636e\u5b83\u7684\u5b9e\u53c2\u6765\u505a\u4e00\u4e9b\u4e8b\u3002\u5f53\u4e00\u4e2a\u51fd\u6570\u6709\u591a\u4e2a\u5b9e\u53c2\u65f6\uff0c\u4f60\u9700\u8981\u7528\u9017\u53f7(,)\u5c06\u5b83\u4eec\u5206\u5f00\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u7ed9 print\u591a\u4e2a\u5b9e\u53c2\uff1b\u5b83\u4f1a\u6309\u5e8f\u7684\u5c06\u5b83\u4eec\u6253\u5370\u8f93\u51fa\uff0c\u5e76\u7528\u7a7a\u683c\u6765\u5206\u5f00\u4ed6\u4eec\u3002 \u6211\u4eec\u4f1a\u7528\u4e0b\u9762\u8fd9\u4e2a\u4f8b\u5b50\u6765\u8bc1\u660e\u3002 Example\u6253\u5370\u4e09\u4e2a\u6570\u5b57 x = 3 print(x, x + x , x * x) \u4e0a\u9762\u793a\u4f8b\u7a0b\u5e8f\u4e2d\u591a\u4f59\u7684\u7a7a\u683c\u5bf9\u8f93\u51fa\u5e76\u6ca1\u6709\u4efb\u4f55\u5f71\u54cd\u3002\u591a\u4f59\u7684\u7a7a\u683c\u5728\u5176\u4ed6\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u4e5f\u90fd\u662f\u65e0\u610f\u4e49\u7684\u3002\u4e0d\u8fc7\uff0c\u8981\u5c0f\u5fc3\u6bcf\u4e00\u884c\u5f00\u59cb\u65f6\u7684\u989d\u5916\u7a7a\u683c\uff0c\u4ed6\u4eec\u53eb\u505a\u7f29\u8fdb,\u5e76\u4e14\u6709\u4e00\u4e2a\u7279\u6b8a\u7684\u610f\u4e49\u3002\u5f53\u4f60\u4e0d\u6b63\u786e\u7684\u4f7f\u7528\u65f6\uff0c\u7f29\u8fdb\u53ef\u80fd\u4f1a\u9020\u6210\u9519\u8bef\uff08\u70b9\u51fb\u94fe\u63a5\u6765\u770b\u4e00\u4e2a\u793a\u4f8b\uff09\u3002\u4f60\u5c06\u4f1a\u5728\u51e0\u8282\u8bfe\u540e\u5b66\u5230\u600e\u6837\u6b63\u786e\u7684\u4f7f\u7528\u7f29\u8fdb\u3002 \u4e00\u4e2a\u51fd\u6570\u4e5f\u53ef\u4ee5\u5f52\u8fd8\u4e00\u4e2a\u503c\uff08\u5c31\u50cf\u4e00\u4e2a\u8f93\u51fa\uff09\u3002\u4f8b\u5982\u51fd\u6570 max()\u00a0\u4f1a\u5f52\u8fd8\u5b9e\u53c2\u4e2d\u6700\u5927\u7684\u90a3\u4e2a\u6570\uff0c\u8fd9\u610f\u5473\u7740\u8fd9\u4e9b\u5b9e\u53c2\u5fc5\u987b\u90fd\u662f\u6570\u5b57\u3002 Example\u8bd5\u7740\u5728\u8fd0\u884c\u4e4b\u524d\u9884\u6d4b\u4e0b\u9762\u8fd9\u4e2a\u7a0b\u5e8f\u7684\u8f93\u51fa print(max(42, 17)) print(max(128,281,812)) \u8fd4\u56de\u503c\u8fd9\u4e2a\u540d\u8bcd\u6307\u7684\u662f\u4e00\u4e2a\u51fd\u6570\u5f52\u8fd8\u7684\u503c\u3002\u4f8b\u5982max(42, 17)\u8fd9\u4e2a\u51fd\u6570\uff0c\u6211\u4eec\u4f1a\u8bf4\u201c\u51fd\u6570max\u7684\u8fd4\u56de\u503c\u662f42\u3002\u201d \u51fd\u6570max\u6709\u4e00\u4e2a\u8868\u73b0\u7c7b\u4f3c\u7684\u670b\u53cb\uff1a\u51fd\u6570min\uff0c\u5b83\u4f1a\u8fd4\u56de\u5b9e\u53c2\u4e2d\u7684\u6700\u5c0f\u503c\u3002 Multiple Choice Exercise: \u6700\u5c0f\u4e0e\u6700\u5927\uff08\u4e00\uff09\u4e0b\u9762\u8fd9\u4e2a\u7a0b\u5e8f\u7684\u8f93\u51fa\u662f\u4ec0\u4e48\uff1f &lt;pre&gt;x = 13 y = 7 a = max(x+y, &hellip; <a href=\"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/2-zh\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-9174","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-json\/wp\/v2\/pages\/9174","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-json\/wp\/v2\/comments?post=9174"}],"version-history":[{"count":12,"href":"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-json\/wp\/v2\/pages\/9174\/revisions"}],"predecessor-version":[{"id":10201,"href":"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-json\/wp\/v2\/pages\/9174\/revisions\/10201"}],"wp:attachment":[{"href":"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-json\/wp\/v2\/media?parent=9174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}