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 06:30
This technology is used to produce high-quality documents that look good on the computer screen and in print. wiki presentation paint desktop publishing
Answers: 3
question
Computers and Technology, 23.06.2019 20:30
If an appliance consumes 500 w of power and is left on for 5 hours, how much energy is used over this time period? a. 2.5 kwh b. 25 kwh c. 250 kwh d. 2500 kwh
Answers: 1
question
Computers and Technology, 24.06.2019 02:00
Which steps will open the system so that you can enter a question and do a search for
Answers: 1
question
Computers and Technology, 24.06.2019 05:30
Hey i really need some solving this problem: 1. encrypt this binary string into cipher text: 110000. include in your answer the formula the decoder would use to decrypt your cipher text in the format (coded answer) x n mod (m) = y & 2. decrypt this cipher text into a binary string: 106 you.
Answers: 2
You know the right answer?
Import turtle as turtle import math

#
class GraphXY:
def __init__(self, xli...
Questions
question
Mathematics, 16.12.2021 21:40
question
Mathematics, 16.12.2021 21:40
question
Mathematics, 16.12.2021 21:40
question
Mathematics, 16.12.2021 21:40
question
Mathematics, 16.12.2021 21:40
Questions on the website: 13722362