Changes between Version 47 and Version 48 of ControlSystems/SoftwareTeam/IntroToPython
- Timestamp:
- Sep 4, 2017, 7:00:10 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ControlSystems/SoftwareTeam/IntroToPython
v47 v48 152 152 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? 153 153 154 == Compound Control Structures: 154 == Compound Control Structures: Here a Control Structure, There a Control Structure, Everywhere a Control Structure... == 155 155 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: 156 156 … … 166 166 print("score!") 167 167 }}} 168 What does it output? See how the indenting works when nesting? Note that `count+=1` is shorthand for `count=count+1` because not typing those ex cesscharacters __could save your life__.168 What does it output? See how the indenting works when nesting? Note that `count+=1` is shorthand for `count=count+1` because not typing those extra characters __could save your life__. 169 169 170 170 Now, modify the code to make it repeat the word potato each time based on the current value of count, and run it. When you're done, the output should look like: