Introduction to Programming using Python 1st Edition

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

Chapter 3 - Mathematical Functions, Strings, and Objects - Programming Exercises - Page 89: 3.19

Answer

import turtle x1, y1, x2, y2 = eval(input("Enter two points: ")) turtle.penup() turtle.goto(x1, y1) turtle.pendown() s = "(" + str(x1) + "," + str(y1) + ")" turtle.write(s) turtle.goto(x2, y2) s = "(" + str(x2) + "," + str(y2) + ")" turtle.write(s) turtle.done()

Work Step by Step

# (Turtle: draw a line) Write a program that prompts the user to enter two points # and draw a line to connect the points and displays the coordinates of the points, # as shown in Figure 3.7c. import turtle x1, y1, x2, y2 = eval(input("Enter two points: ")) turtle.penup() turtle.goto(x1, y1) turtle.pendown() s = "(" + str(x1) + "," + str(y1) + ")" turtle.write(s) turtle.goto(x2, y2) s = "(" + str(x2) + "," + str(y2) + ")" turtle.write(s) turtle.done()
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.