Changes between Version 96 and Version 97 of ControlSystems/SoftwareTeam/IntroToPython
- Timestamp:
- Sep 4, 2017, 11:16:21 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ControlSystems/SoftwareTeam/IntroToPython
v96 v97 90 90 if location == 'Poughkeepsie, NY': 91 91 }}} 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.92 and 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. 93 93 94 94 If 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: … … 182 182 score! 183 183 }}} 184 Yeah, this is a little harder, but Ibet you can do it. Ask a neighbor for help if you need to. I'll give you three hints:184 Yeah, 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: 185 185 186 186 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="")`''. '' 187 187 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 Ididn'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.] 189 189 190 190 The solution is [wiki:ProgrammingAnswerPotatoExercise here]. This concludes Lesson 2.