Changes between Version 96 and Version 97 of ControlSystems/SoftwareTeam/IntroToPython


Ignore:
Timestamp:
Sep 4, 2017, 11:16:21 PM (8 years ago)
Author:
cdelgigante
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SoftwareTeam/IntroToPython

    v96 v97  
    9090if location == 'Poughkeepsie, NY':
    9191}}}
    92 and run it again.   What happens?   It should print "Go away, we're out eating tacos".  Why?  If I was in Poughkeepsie, I'd be out eating tacos too.  Yummmm, tacos.
     92and run it again.   What happens?   It should print "Go away, we're out eating tacos".  Why?  If we were in Poughkeepsie, We'd be out eating tacos too.  Yummmm, tacos.
    9393
    9494If you're writing your own code, you don't want to provide an ''else'', just omit the keyword `else:` and the indented block you want to run with it.  For example:
     
    182182score!
    183183}}}
    184 Yeah, this is a little harder, but I bet you can do it.  Ask a neighbor for help if you need to.  I'll give you three hints:
     184Yeah, this is a little harder, but we bet you can do it.  Ask a neighbor for help if you need to.  I'll give you three hints:
    185185
    186186 1. You can tell a print to not end with a new line by adding an end="" to the print statement like this `print("I'm a teapot!",end="")`''. ''
    187187 1. An empty print statement `print("")` just prints a new line, basically the equivalent of having the program hit <enter>.
    188  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.]
     188 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 we didn't warn you.]
    189189
    190190The solution is [wiki:ProgrammingAnswerPotatoExercise here].   This concludes Lesson 2.