Changes between Version 142 and Version 143 of ControlSystems/SoftwareTeam/IntroToPython
- Timestamp:
- Sep 5, 2017, 8:01:50 AM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ControlSystems/SoftwareTeam/IntroToPython
v142 v143 52 52 53 53 = Lesson 2: Control Structures = 54 [[Image(https://docs.oracle.com/cd/A58617_01/server.804/a58236/03_strua.gif,20%,right)]] 54 55 In lesson 1, we had you create a program, "Hello World". Now, "Hello World" is not too exciting if you want to program robots, but its an important first step. We showed you how to run a function (or verb) `print`, which does something (shows on the screen the value of its argument `a`, where `a` is assigned the value "Hello World". 55 56 … … 57 58 58 59 == If-Then-Else: Decide, already! == 60 Selective execution of portions of your program is done with ''conditionals''. 59 61 Take the program below, it uses an If-Then-Else control structure to ask the program to make a decision, and run code based on that decision. You'll use these all the time. 60 62 … … 114 116 115 117 == For Loop: Stop Hitting Yourself! == 116 The For loop control structure runs code repeats over a variable. Try running this one: 118 Repeated execution of a portion of your program is done with a type of control structure called an ''iterator''. 119 The For loop control structure runs the same block of code for each item contained in a variable. Try running this one: 117 120 118 121 {{{ … … 193 196 194 197 = Lesson 3: Functions = 198 [[Image(https://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Function_machine2.svg/220px-Function_machine2.svg.png,right,15%,nolink)]] 195 199 So are you tired of just printing stuff yet? In the last lesson, we introduced you to all sort of ways to make decisions and loop over code to make your program easier to read and shorter too. 196 200