Changes between Version 27 and Version 28 of ControlSystems/SoftwareTeam/IntroToPython


Ignore:
Timestamp:
Sep 4, 2017, 5:50:35 PM (8 years ago)
Author:
cdelgigante
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SoftwareTeam/IntroToPython

    v27 v28  
    5252In 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".
    5353
    54 ==IF-THEN-ELSE==
     54== IF-THEN-ELSE ==
    5555If 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.
    5656
     
    111111Here's a couple other control structures that you should know:
    112112
    113 ==FOR Loop==
    114 The FOR loop control structure runs code repeatly repeats over a variable.  Try running this one:
     113== For Loop ==
     114The For loop control structure runs code repeatly repeats over a variable.  Try running this one:
    115115{{{
    116116fruits = ['banana', 'apple', 'mango']
     
    134134FOR 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.
    135135
    136 ==While Loop==
     136== While Loop ==
    137137
    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. 
     138A 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. 
    139139
    140140----