Changes between Version 48 and Version 49 of ControlSystems/SoftwareTeam/IntroToPython


Ignore:
Timestamp:
Sep 4, 2017, 7:07:07 PM (8 years ago)
Author:
cdelgigante
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SoftwareTeam/IntroToPython

    v48 v49  
    11Prerequisites: [wiki:SoftwareOverviewControl Control Systems Overview]
    22
    3 ----
    4 = Lesson 1:  Getting Started =
     3= Lesson 1:  Getting Started =
    54If you want to tell a computer to do something, you have to communicate with the computer in a programming ''language''.  When we say language, we mean it.   A language has words and grammar and everything else, just like French.
    65
     
    4847And, boom, now you're a programmer.  The rest of learning how to code is just more details.  This is the end of Lesson 1.
    4948
    50 = Lesson 2: Making Decisions =
     49= Lesson 2:  Making Decisions =
    5150In 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".
    5251
     
    187186 1. If you want to loop over a set of numbers, use a `range()`.  For example, `for x in range(0,5)` will make x go from 0 to 4 incrementing 1 each time it loops.  The first number is where x starts, and the second number is where x will stop __minus 1__.  Don't ask why---its just the way computers and programs work.  Don't believe me?  Fine. [https://softwareengineering.stackexchange.com/questions/110804/why-are-zero-based-arrays-the-norm Don't say I didn't warn you.]
    188187
    189 The solution is [wiki:ProgrammingAnswerPotatoExercise here].
     188The solution is [wiki:ProgrammingAnswerPotatoExercise here].   This concludes Lesson 2.
     189
     190= Lesson 3:  Functions =
     191So 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.
     192
     193Functions do things in your code.  You've already used two:   print (yes that's a function), and range (assuming you did the last exercise of the last less and didn't cheat).
     194
     195The actual code run in these functions can be pretty big.  Imagine if you had to type it out every time you wanted to use it.   That would get old, confusing, and error prone fast.
     196
     197Functions can take variables arguments as input, and may return variables as output.
     198
     199Here's a few handy functions, with some examples:
    190200
    191201----