From the course: Building the Classic Snake Game with Python

Meet turtle graphics

- Instructor] Turtle graphics is a popular educational tool for teaching and learning about programming. And for good reason, it is awesome. In my opinion, it is one of the best tools there is for learning how to program with Python. With it, you can progress from total beginner to mastering important advanced programming concepts. Turtle graphics was created in the 1960s when the logo programming language was extended to control the turtle robot, a simple robot that looked a bit like a turtle and had a pen attached, which would draw on a large piece of paper on the floor. When writing programs with Turtle graphics, you get instant visual feedback from your code, so you can see clearly what is happening and how it works. When you install Python with a standard installation, it comes with an IDE called IDLE, which is like a beginners IDE. And in IDLE, there is a help menu. And if you go to Turtle Demo in the help menu, then you'll see there's some really interesting sample programs for turtle graphics. So you click on Examples. And by the way, if you're on Mac, you would access IDLE by going into a terminal and typing IDLE 3 and then pressing Enter. So there's this selection of example programs. So, for example, there is a planet and moon animation. You can see the code here on the left. This uses object oriented programming. So it's very interesting just in terms of the code to have a look at what's going on. But the actual result is this little animation here. And that's one of them. There's another one, which is Nim, which is the game of Nim, which is a strategy game where you have to remove sticks or coins or whatever you're using. Press space bar to start. Okay, so the computer's played and then I select. It's the black ones, I guess, I'm removing. So I click on there. So that's an implementation of Nim. And again, you can see the code over here on the left. Another example, Two Canvases. This shows you, you can actually have two turtle graphics windows going at once. That's quite useful. And let's just look at one more. So maybe the ground dance. There we go. So this is a really nice animation. With relatively little code. If you look here on the left, we're not using a lot of commands, but we're getting this really quite impressive animation going on. So these are some examples of, what you can do with Turtle graphics.

Contents