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


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

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SoftwareTeam/IntroToPython

    v49 v50  
    11Prerequisites: [wiki:SoftwareOverviewControl Control Systems Overview]
    22
    3 = Lesson 1:  Getting Started =
     3= Lesson 1:  Getting Started =
    44If 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.
    55
     
    4747And, boom, now you're a programmer.  The rest of learning how to code is just more details.  This is the end of Lesson 1.
    4848
    49 = Lesson 2:  Making Decisions =
     49= Lesson 2:  Making Decisions =
    5050In 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".
    5151
     
    186186 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.]
    187187
    188 The solution is [wiki:ProgrammingAnswerPotatoExercise here].   This concludes Lesson 2.
    189 
    190 = Lesson 3:  Functions =
    191 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.
    192 
    193 Functions 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 
    195 The 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.
     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.
    196196
    197197Functions can take variables arguments as input, and may return variables as output.
     
    199199Here's a few handy functions, with some examples:
    200200
    201 ----
     201input(prompt): Prompts the user for input by showing the prompt screen, returning whatever the user entered after they hit <enter>.
     202
    202203[[[wiki:ProgrammingReserve Programming]Archive | Programming Archive]]