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 17:30
Under which key category do the page up and page down keys fall? page up and page down keys fall under the keys category.
Answers: 1
question
Computers and Technology, 23.06.2019 09:00
The first screen you see when you open word2016 what is called?
Answers: 1
question
Computers and Technology, 24.06.2019 10:20
Write a program that keeps asking the user for new values to be added to a list until the user enters 'exit' ('exit' should not be added to the list). these values entered by the user are added to a list we call 'initial_list'. then write a function that takes this initial_list as input and returns another list with 3 copies of every value in the initial_list. finally, inside print out all of the values in the new list. for example: input: enter value to be added to list: a enter value to be added to list: b enter value to be added to list: c enter value to be added to list: exit output: a b c a b c a b c note how 'exit' is not added to the list. also, your program needs to be able to handle any variation of 'exit' such as 'exit', 'exit' etc. and treat them all as 'exit'.
Answers: 2
question
Computers and Technology, 24.06.2019 11:00
Which of the statements below describe the guidelines for the use of text in presentation programs? a. do not use numbered lists. b. fonts should be appropriate for your audience. c. limit the number of fonts you use to three or four. d. only use bulleted lists for sales promotions. e. select font sizes that are appropriate for your delivery method. f. use font colors that work well with your background. select all that apply
Answers: 1
You know the right answer?
Import turtle as turtle import math

#
class GraphXY:
def __init__(self, xli...
Questions
question
Mathematics, 06.05.2020 08:33
question
Health, 06.05.2020 08:33
question
Mathematics, 06.05.2020 08:33
question
Mathematics, 06.05.2020 08:33
question
World Languages, 06.05.2020 08:33
Questions on the website: 13722367