Join us and get access to thousands of tutorials and a community of expert Pythonistas.
This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.
Throw the Dog a Ball
00:00 Let’s go and send Puppy off to fetch something. I’m going to save and run this code. Invalid syntax. Perhaps you forgot a comma? Let me see where that happened.
00:12
Yes. I clearly forgot to close the parentheses on my calls to print() here. All right, got those fixed. Save and run again. Here we are. And then I will have the dog Puppy go and fetch something, so dog.fetch() and I can pass it a thing, so it’ll go fetch a "stick".
00:35
You see that the code waits for half a second, Puppy dashes after the stick, and he waits for half a second and then returns stick to you.
00:43
And as an output I get the string 'stick' in this case. Imagine this would be an object, and you would then continue doing something with it.
00:52 Maybe the dog goes and fetches it, but buries it under the ground. I don’t know. I can now
01:00
throw balls with the dog, and it’s going to run off, get the ball, and return it to me. Great. This is a little idea of how you could continue to work on this Farm model and do lots of other things, but there’s other ideas that you could implement.
01:18 Let’s chat about a couple of possible ideas in the next lesson.
Become a Member to join the conversation.