Python Turtle

Some 90’s themed Turtle Artwork

Getting Started

We can begin our python app like most other apps, by building a folder to host our files and opening it in our text editor of choice, here I will be using Visual Studio Code. Python files are named with the .py extension, so be sure whatever you name your file, it ends with .py.

importing the Turtle class from the turtle module, and setting a variable equal to the Turtle function

Importing the Screen

By adding an additional import, the Screen, we can persist the canvas even after our turtle has finished drawing. After we import the Screen, we create a local variable screen and set it equal to the function Screen(), just like we did for turtle. Finally, we call a function mainLoop() on screen to persist the canvas.

importing both Turtle and Screen
Making Picasso jealous

Understanding The Screen

It is easier to make your picture how you want it to look if you understand the screen itself. The screen is simply divided into four quadrants along an x and y axis.

Image from the python documentation

Let’s Get Creative

So far all we have done is make a straight line on a white canvas. Not exactly ready for the refrigerator, but there are a plethora of commands we can run to make an image here. Below I have listed just a few commands to get started with to help you create your masterpiece. At the end of the article, I will link the full Python Turtle documentation if you wish to delve deeper into creating Turtle art.

Resources:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aidan McBride

Aidan McBride

I ‘m a Web Developer and a Flatiron coding bootcamp alumni. I currently work in the financial tech industry as a Front End Engineer