Changes between Version 36 and Version 37 of ControlSystems/SoftwareTeam/IntroToPython
- Timestamp:
- Sep 4, 2017, 6:48:07 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ControlSystems/SoftwareTeam/IntroToPython
v36 v37 151 151 Oh no, I'm tired, so I'm not going to tell you the answer for this one. You should be seeing a pattern by now. You tell me---What should it print? Count starts out at 0, and as long as count is less than 9 it will run the code in the block, then it will print "Good bye!". What else does it print out? 152 152 153 == Compound control statements==154 Lastly, you can combine all three of these in any sort combination, and nest them. This is how you do real work in a program. For example, try running this one:153 == Bringing it all Together... == 154 Lastly, you can combine all three of these in any sort of combination, and nest them. This is how you do real work in a program. For example, try running this one: 155 155 156 156 {{{ … … 180 180 score! 181 181 }}} 182 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:182 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: 183 183 184 1. You can tell a print to not end with a new line by adding an end="" to the print statement, like `print("Im a teapot!",end="")`''.''185 1. An empty print statement `print("")`just prints a new line.186 1. ''If you want to loop over a set of numbers, use `range()`.''` For example for i in range(1,10) will make i go from 1 to 10 incrementing 1 each time.`184 1. You can tell a print to not end with a new line by adding an end="" to the print statement, like `print("Im a teapot!",end="")`''. '' 185 1. An empty print statement `print("")` just prints a new line. 186 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 you start, and the second number is where you want to stop __minus 1__. Don't ask why. Its really nerdy. Not buying it? Fine. [https://softwareengineering.stackexchange.com/questions/110804/why-are-zero-based-arrays-the-norm Don't say I didn't warn you.] 187 187 188 Answer is [wiki:ProgrammingAnswerPotatoExercise here] . 188 189 189 190 Answer is [wiki:ProgrammingAnswerPotatoExercise here].191 192 ----193 190 [[[wiki:ProgrammingReserve Programming]Archive | Programming Archive]]