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,100 courses taught by industry experts.

Working with OOP in Python turtle graphics

Working with OOP in Python turtle graphics

- [Instructor] We have here a program which uses object oriented Python turtle graphics. First of all, I'm just going to run it and show you what it does. So you can see we get this lovely colorful spiral. Let's look at how this is achieved. So lines one and two are simply about importing the turtle module that we need for anything to do with turtle graphics. And then from line four to line eight, we are creating an instance of a screen object. So this is an example on line five of instantiation. So we're basically calling the constructor for the screen class, and that gives us a screen upon which we can do our various drawing, et cetera, with turtle graphics. And then we can call some methods on that screen that we've created. So for example, we can do screen.setup and that allows us to set the dimensions and we can set the title and the background color as well. And then from line 10 to 13, we also have another example of instantiation. So this is when we create an instance of an…

Contents