From the course: Getting Started with Python Object Oriented Programming: A Hands-On Approach

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Solution: Working with OOP in Python turtle graphics

Solution: Working with OOP in Python turtle graphics

(upbeat music) - [Instructor] This is what I did for the Turtle Graphics Challenge. It's a turtle race. I'm going to show you in action and then we're going to go back and code it, and I'll show you how the various aspects work. So in idle, if I click on there and hit F5 it will run the file. And you can see we have this race between two turtles, a green turtle, and a red turtle. So let's go ahead and code this turtle race. So this is the chapter three challenge, we don't need that comment anymore. We do need the random module, and let's begin. So screen is equal to an instance of turtle.Screen. Notice the capital letter. And then we can do some various setups. So screen.title and notice this is a method, we can call it Turtle Race and bgcolor. You can have all sorts of different color formats, but also color names are just fine. And we're going to have the dimensions screen.setup 600 by 600. Okay, so we've created an instance of turtle.Screen. Remember the syntax here with…

Contents