Changes between Version 141 and Version 142 of ControlSystems/SoftwareTeam/IntroToPython


Ignore:
Timestamp:
Sep 5, 2017, 7:50:14 AM (8 years ago)
Author:
David Albert
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SoftwareTeam/IntroToPython

    v141 v142  
    1818Python, like every programming language, has a structure.  Here are the big parts:
    1919
    20  * ''Variables'':  Things you assign to and read from.  Like in Algebra. `a="Dump Truck"` sets the variable `a` to the string "Dump Truck".   You can set them to strings/text, numbers or fancy things like lists.  They're basically the nouns.
    21  * ''Control Structures'':  These are core programming language instructions like IF this is true THEN do that….  These are a lot like grammar rules, like: use active voice, or use punctuation.  They're how you get stuff done.
    22  * ''Functions'': These do things. They take nouns as arguments, do something, and can return nouns. In `redCar = paintCarRed(blueCar)`, `paintCarRed` is a function. They're the verbs, they do things, and they take variables and return variables.  Many functions are built in to Python, but you can (and should) create your own.
    23  * ''Packages'':  A lot of other people have written functions to do things.  A lot of things.  When these things are bundled together they're called ''packages'' which you can download and use.  You can tell your program to use a package and save your self a lot of typing, and do things that would require 2 or 3 college degrees without all that study.
     20 * ''Variables'': [[Image(https://mdn.mozillademos.org/files/13506/boxes.png,10%,right,nolink)]] Things you assign to and read from.  Like in Algebra. `a="Dump Truck"` sets the variable `a` to the string "Dump Truck" (a string is just a sequence of letters and numbers strung together...hence the name).   You can set them to strings/text, numbers or fancy things like lists.  They're basically the nouns.  You can think of a variable as a box you can store something in.
     21 * ''Control Structures'':  [[Image(https://docs.oracle.com/cd/A58617_01/server.804/a58236/03_strua.gif,15%,right)]] These are core programming language instructions like IF this is true THEN do that….  These are a lot like grammar rules, like: use active voice, or use punctuation.  They're how you get stuff done.  Control structures can let you do things selectively (conditionally), iteratively (repeatedly), and sequentially. 
     22 * ''Functions'': [[Image(https://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Function_machine2.svg/220px-Function_machine2.svg.png,right,8%,nolink)]]These do things. They take nouns as arguments (inputs), do something, and can return (output) nouns. In `redCar = paintCarRed(blueCar)`, `paintCarRed` is a function. They're the verbs, they do things, and they take variables and return variables.  Many functions are built in to Python, but you can (and should) create your own.  The ability to create your own functions (new words!) is a big part of what makes programming languages so powerful.
     23 * ''Packages'':  A lot of other people have written new functions to do things.  A lot of things.  When these things are bundled together they're called ''packages'' or ''libraries'' which you can download and use.  You can tell your program to use a package and save your self a lot of typing, and do things that would require 2 or 3 college degrees without all that study.
    2424
    2525Much like in English, you blend all of these together to create stories, or ''programs''.  So lets write the first program that all programmers start with:  "Hello World"