Here's a Binky while loop example
'go forward so long as way is clear, painting squares blue'
Go here first:
- Loop - big jump up in power
- "Do these lines again and again"
- Many types of loop - today while
Syntax 4 parts: while, test, colon, body lines
'body' code inside the while
While Loop Operation
- How the while loop works
- First check the test at the top, True or False?
- If True, run all the lines of the body in order,
-then loop back to top, check test again, .. repeat
- If False, loop is done, continue running after the body
- Binky has functions we've seen: move(), left(), right, paint('blue')
- Binky also has front_clear()
- Checks if the front of binky is clear to move into
- Returning True or False
- Use as the test of while loop
- Notice the () at the end, as with all function calls
These will be part of hw1 soon. Get run-all All Correct for each (see myprojects at upper-right)