Changes between Version 27 and Version 28 of ControlSystems/SoftwareTeam/IntroToPython
- Timestamp:
- Sep 4, 2017, 5:50:35 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ControlSystems/SoftwareTeam/IntroToPython
v27 v28 52 52 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 (show on the screen the value of its argument `a`, where `a` is assigned the value "Hello World". 53 53 54 == IF-THEN-ELSE==54 == IF-THEN-ELSE == 55 55 If you want to do more, we need to introduce control structures. 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. 56 56 … … 111 111 Here's a couple other control structures that you should know: 112 112 113 == FOR Loop==114 The F ORloop control structure runs code repeatly repeats over a variable. Try running this one:113 == For Loop == 114 The For loop control structure runs code repeatly repeats over a variable. Try running this one: 115 115 {{{ 116 116 fruits = ['banana', 'apple', 'mango'] … … 134 134 FOR loops are handy if you want to avoid repeating yourself in code, and do the same thing over and over again. The less code you write, the less chance you can make a mistake. Not to mention its easier to read. 135 135 136 == While Loop==136 == While Loop == 137 137 138 A While loop ,is the more charming cousin of the FOR loop, this one repeats as long as its condition is ''True''. If the condition is false when it gets to the While loop, the While loop wont run at all.138 A While loop is the more charming cousin of the FOR loop, this one repeats as long as its condition is ''True''. If the condition is false when it gets to the While loop, the While loop wont run at all. 139 139 140 140 ----