subject

Import turtle as turtle import math

#
class GraphXY:
def __init__(self, xlist = None, ylist = None):
self.__x = []
self.__y = []
for i in xlist:
self.__x. append(i)
for i in ylist:
self.__y. append(i)
self.__n = len(self.__x)
self.__s = None
self.__t = None

def printpoints(self):
self.__s = turtle. Screen()
self.__t = turtle. Turtle()
self.__t. forward(200)
self.__t. backward(400)
self.__t. home()
self.__t. left(90)
self.__t. forward(200)
self.__t. backward(400)
self.__t. right(90)
self.__t. home()
self.__t. penup()
for i in range(self.__n):
self.__t. goto(self.__x [i], self.__y[i])
self.__t. pendown()
self.__t. write('x')
self.__t. penup()

def finddistances(self):
# write your code to find distances between all city pairs

return d # this function returns 2D matrix

def makeroads(self, d, m):
# write your code to draw lines between points using turtle

return # this function returns nothing
#
#
# following 2 functions are not part of the class
def mindistance(d):
# write your code here to find minimum distances

return m # this function returns 1D list of minimum distances

def showdistance(d):
# write your code to print distances as a table

return # this function returns nothing
#
#
# Tester code starts here
# x-points of cities
xpoints = [-150, -100, -50, 0, 50, 100, 150]

# y-points of cities
ypoints = [150, -150, 0, 100, 50, 100, -50]

# making a graph object from x-points and y-points
g = GraphXY(xpoints, ypoints)

# print the cities on the graph
g. printpoints()

# finding the distance between each city: this will return 2D Matrix like 7x7
d = g. finddistances()

# printing the table of distances between cities
showdistance(d)

# finding the minimum distance between cities (excluding c0 to c0 etc.)
m = mindistance(d)
print("minimum distances are: ", m)

# Draw the lines connecting cities using minimum distances between them
# this function takes 2 inputs. (1) all distances matrix, and (2) minimum distance list
g. makeroads(d, m)

turtle. done()

I want to connect the nearest dots to each other as shown in the picture


Import turtle as turtle

import math
##################################################
class Grap

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 20:00
What is the term for water wave that is created by an underwater earthquake
Answers: 1
question
Computers and Technology, 23.06.2019 17:00
The more powerful, 60 volt cables and the main power shut-off on an hev are both colored orange.
Answers: 1
question
Computers and Technology, 24.06.2019 17:00
Carlos, an algebra teacher, is creating a series of powerpoint presentations to use during class lectures. after writing, formatting, and stylizing the first presentation, he would like to begin writing the next presentation. he plans to insert all-new content, but he wants to have the same formatting and style as in the first one. what would be the most efficient way for carlos to begin creating the new presentation? going under the file tab and opening the first presentation, deleting all content from each page, and adding new content going under the file tab and clicking on new in the left pane, then choosing new from existing going under the design tab and clicking on themes, then selecting the theme that was used for the first template going under the design tab and opening the template that was created for the first presentation
Answers: 2
question
Computers and Technology, 24.06.2019 22:30
To include a watermark or page border on a word document, you will first need to navigate to the tab. file home insert design
Answers: 1
You know the right answer?
Import turtle as turtle import math

#
class GraphXY:
def __init__(self, xli...
Questions
question
Mathematics, 18.04.2020 03:55
Questions on the website: 13722366