Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 6 - Functions - Programming Exercises - Page 211: 6.38

Answer

code

Work Step by Step

# 6.38 (Turtle: draw a line) Write the following function that draws a line from point # (x1, y1) to (x2, y2) with color (default to black) and line size (default to 1). # def drawLine(x1, y1, x2, y2, color = "black", size = 1): import turtle def drawLine(x1, y1, x2, y2, color="black", size=1): turtle.color(color) turtle.pensize(size) turtle.penup() turtle.goto(x1, y1) turtle.pendown() turtle.goto(x2, y2) def main(): drawLine(10, 20, 70, 90, "blue", 5) drawLine(40, 20, -70, 50, "yellow", 8) turtle.done() main()
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.