Changes between Version 11 and Version 12 of ControlSystems/SoftwareTeam/IntroToPython


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

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SoftwareTeam/IntroToPython

    v11 v12  
    3636And, boom, now you're a programmer.  The rest is just more details.   This is the end of Lesson 1.
    3737
     38
    3839= Lesson 2:  More Things To Do =
    39 Now "Hello World" is not too exciting if you want to program robots, but its important.   It is a program, albeit a short one.  We showed you how to run a function (or verb) print, which does something with its argument A, where A is assigned the value "Hello World".
     40In 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".
    4041
    4142If you want to do more, we need to introduce control structures.  Take the program below.
    4243
    43 Location = 'HERE'
    44 
    45 IF (location == 'HERE') THEN
    46 
    47 Print "We're here! Come on in'
    48 
    49 ELSE
    50 
    51 Print "Go away, we're out eating tacos"
    52 
    53 ELSEIF
     44{{{
     45#!python
     46location = 'HERE'
     47print("Welcome to our store\n")
     48if location == 'HERE':
     49   print("We're here! Come on in\n")
     50else:
     51   print("Go away, we're out eating tacos\n")
     52print("Hope you had a good time")
     53}}}
    5454
    5555Cut and paste this program here, then run it (Press Execute).   It should print "We're here! Come on in!".   If it doesn't ask for help.   Spacing matters in Python.