From the course: Python for Students

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Drawing a line with Python

Drawing a line with Python - Python Tutorial

From the course: Python for Students

Drawing a line with Python

- [Instructor] Let's work on drawing lines using Turtle, Python's built-in drawing feature. The first thing we need to do in order to use Turtle is import it into our file. We'll do that one line one of our program. The next thing we need to do is create a drawing screen. We can do that using the built-in screen function and save it to a variable called screen. The bgcolor function allows us to set the background color of our screen and the title function allows us to put a title on our screen. Let's save this program and run it and see what happens. As you can see, we have a drawing board with a blue background and a title that says "Drawing Lines Practice". Great. Let's draw our first line. In order to draw a line, let's make our first Turtle. We'll save it in a variable called my_turtle, and we create a turtle by just doing turtle.Turtle. We can then draw a line by doing my_turtle.forward and let's just move it forward by 100 pixels. Save it and run it. Great. We now have a blue…

Contents