Created
June 27, 2024 19:37
-
-
Save mindlace/2a9c32b60fede1b7a2113060f1db78f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# write a method that defines a decision tree for walking in the desert and seeing a turtle baking in the sun | |
def decide_action(see_turtle): | |
""" | |
This method defines a decision tree for walking in the desert and seeing a turtle baking in the sun. | |
Parameters: | |
- see_turtle (bool): Whether or not the person sees a turtle baking in the sun. | |
Returns: | |
- str: The action to take. | |
""" | |
if see_turtle: | |
# Check if you have water | |
if have_water(): | |
# Check if the turtle is alive | |
if check_turtle_alive(): | |
# Help the turtle | |
return "Move the turtle to shade and give it water." | |
else: | |
return "The turtle is not alive. No action needed." | |
else: | |
return "You don't have water to help the turtle." | |
else: | |
return "Keep walking. There's no turtle in sight." | |
def have_water(): | |
# Placeholder for checking if the person has water | |
# This should be replaced with actual logic | |
return True | |
def check_turtle_alive(): | |
# Placeholder for checking if the turtle is alive | |
# This should be replaced with actual logic | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment