Creating the Dog Class (Trial)
00:11 This is specific to IDLE, so if you are using a different editor, then just make sure to print it down here in the file before you run it here. I get the chance to play with it a bit, so I can create a dog.
I’ll call the dog
"Philo", and it’s 12 years old. This is what I get returned. I get a
Dog object. Now I should be able to
print(), well, I should assign it to something, right? That’ll make it easier.
So I assigned the
Dog instance to the variable
philo, and then I should be able to
print(philo). So this is going to call
.__str__(), and you see the f-string returned:
Philo, the name of the dog
is 12 years old, so that’s a nice representation.
01:17 And this is what we’re going to start with with the next review exercise, but it’s always a good review exercise also to redo some code that you’ve already built before, because if you start from scratch, there’s always going to be a little bit of thinking involved.
01:31 If you ended up with something that looks like this, then great job. This is the code that I’m going to continue working with in the next exercise as well. Let’s get going and look at the next task.
Become a Member to join the conversation.