Changes between Version 145 and Version 146 of ControlSystems/SoftwareTeam/IntroToPython


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

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SoftwareTeam/IntroToPython

    v145 v146  
    2020 * ''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 variables as boxes you can store things in; you give each box a name like "student" for the box you'll store student names in or "isaMentor" for the box you'll store whether someone is a mentor (true/false) or "age" where you might store their age in  years.
    2121 * ''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.  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.
     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 inputs (''arguments''), do something, and can output (''return'') nouns as well.  They are like a black box with an input into which you can drop something and an output.  In `redCar = paintCarRed(blueCar)`, `paintCarRed` is a function that takes cars as inputs, paints them red, and outputs the altered car.  Note that you can drop the contents of a variable (box) into a function and place the result into another box.  Functions are verbs, they do things, and they take inputs and return outputs.  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.
    2323 * ''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