Error
Errors:
It’s the moment you’ve been working towards - the Ultimate Clean Up Challenge! Karel has put together a community litter pick up event for her neighborhood. For the next three weeks, Karel will work with other community members to pick up the litter in the park.
Write a program that has Karel walk around the park and pick up all of the litter. Your program should work regardless of which week it is.
Hint: Use what you’ve learned about if statements and for loops!
Challenge: Can you avoid repeating the same for loops by using a for loop within a for loop? To do this, you may need to use the following hints:
Method A: How can you get Karel to face the same direction at the start of each loop?
Method B: You can use an if/else statement to give Karel options when she asks a question about the world around her: one set of commands for when she answers yes and another set of commands for when she answers no. Check out the DOCS tab to learn how to write an if/else statement in Python. If you go this route, you might need Karel to ask questions about which direction she is facing by using
facing_east()
andfacing_west()
.
Ending World
Karel's Built in Commands
Karel Commands
|
|
|
|
|
UltraKarel
UltraKarel Commands
|
UltraKarel Conditions
|
|
Color
Random
Functions
Writing a Function
Writing a function is like teaching karel a new word.
Naming Functions: You can name your functions whatever you want, but you can't have spaces in the function name.
Remember that commands in functions must be indented one level
Calling a Function
You call a function to tell the computer to actually carry out the new command.
Conditional Statements
Remember that comands in conditional statements must be indented one level.If statements
If/Else statements
Example of if statements
Karel Conditions
Don't forget the()
at the end!
|
|