修改

跳轉到: 導覽搜尋

计算机(儿童)-2015年春-朱房村-第六次活动-课程提纲

已增加14,431位元組2015年7月9日 (四) 10:52
以“<span style="color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"></span>by&nbsp;[http://www.ygclub....”为内容创建页面
<span style="color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"></span>by&nbsp;[http://www.ygclub.org/bbs/space-uid-12814.html tracybryantliao] <span style="color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">part one: 第一节课</span><br/><span style="color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">1- 复习函数的使用</span><br/> <div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">将多条的命令组合包含在一起,并且用一个简单的名字来表示。</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">相当于增加了一条新的命令,如果指示机器人执行这条新命令,机器人将会执行这条新命令中所包含的多条命令。</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">def命令的形式:</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="word-wrap: break-word; font-weight: 700;">def&nbsp;''新命令的名称&nbsp;''():</span></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><span style="word-wrap: break-word; font-weight: 700;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;''包含的命令''</span></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><font color="#ff0000" style="word-wrap: break-word;">1)def和新命令名称之间用空格隔开</font>;</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><font color="#ff0000" style="word-wrap: break-word;">2)新命令名称后紧跟着一对括号的一个冒号</font>;</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><font color="#ff0000" style="word-wrap: break-word;">3)新命令所包含的命令从第2行开始写,并且每行的开头与第1 行的开头有一定的缩进距离,一般是4个空格;</font></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><font color="#ff0000" style="word-wrap: break-word;">4)新命令在使用前要先定义。</font></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><br/></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">''#先定义''</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><span style="word-wrap: break-word; font-weight: 700;">def turn_right():</span></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">turn_left()</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">turn_left()</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">turn_left()</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">''#后使用''</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><span style="word-wrap: break-word; font-weight: 700;">turn_right()</span></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">turn_off()</div> <br/><br/><span style="color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">2- 学习新命令</span><br/> <div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">指示机器人根据不同条件,执行不同的命令。</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">判断命令的3种形式:</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">1) 形式1:</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="word-wrap: break-word; font-weight: 700;">if&nbsp;''条件''&nbsp;():</span></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><span style="word-wrap: break-word; font-weight: 700;">''&nbsp; &nbsp;&nbsp; &nbsp;命令''</span></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">2) 形式2:</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="word-wrap: break-word; font-weight: 700;">if&nbsp;''条件1''&nbsp;():</span></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><span style="word-wrap: break-word; font-weight: 700;">''&nbsp; &nbsp;&nbsp;&nbsp;命令1''</span></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><span style="word-wrap: break-word; font-weight: 700;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:</span></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><span style="word-wrap: break-word; font-weight: 700;">''&nbsp; &nbsp; 命令2&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;''</span></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><br/></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">3) 形式3:</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="word-wrap: break-word; font-weight: 700;">if&nbsp;''条件1''&nbsp;():</span></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><span style="word-wrap: break-word; font-weight: 700;">''&nbsp; &nbsp;&nbsp;&nbsp;命令1''</span></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><span style="word-wrap: break-word; font-weight: 700;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif&nbsp;''条件2''&nbsp;():</span></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><span style="word-wrap: break-word; font-weight: 700;">''&nbsp; &nbsp;&nbsp;&nbsp;命令2''</span></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><span style="word-wrap: break-word; font-weight: 700;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:</span></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><span style="word-wrap: break-word; font-weight: 700;">''&nbsp; &nbsp;&nbsp;&nbsp;命令3''</span></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><br/></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">判断命令的使用规范:</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">1)&nbsp;<font color="#ff0000" style="word-wrap: break-word;">if和elif 后面加条件(是或不是),最后以冒号结束;</font></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">2)<font color="#ff0000" style="word-wrap: break-word;">&nbsp;else后面接冒号结束;</font></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">3)<font color="#ff0000" style="word-wrap: break-word;">&nbsp;和定义命令一样,每个条件所属的命令前必须有相同的缩进</font>。</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">可以有多种的判断条件,我们会使用到的条件包括:</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">1) front_is_clear 前面为空</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">2) right_is_clear 右边为空</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">3) left_is_clear 左边为空</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><br/></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><span style="word-wrap: break-word; font-weight: 700;">if right_is_clear():</span></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">&nbsp; &nbsp;&nbsp;&nbsp;turn_right()</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">&nbsp; &nbsp;&nbsp;&nbsp;move()</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><span style="word-wrap: break-word; font-weight: 700;">elif front_is_clear():</span></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">&nbsp; &nbsp;&nbsp; &nbsp;move()</div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;"><span style="word-wrap: break-word; font-weight: 700;">else:</span></div><div align="left" style="word-wrap: break-word; color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">&nbsp; &nbsp;&nbsp; &nbsp;turn_left()</div> <br/><br/><span style="color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">part two: 第二节课</span><br/><span style="color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">练习挑战赛</span><br/><span style="color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">先上台阶,再下台阶(台阶4层)</span><br/><span style="color: rgb(0, 0, 0); font-family: Tahoma, 'Microsoft Yahei', SimSun, sans-serif; font-size: 14px; line-height: 21px;">前三名中代码行数最少的人获胜</span>