Import turtle as turtle
import math
#
class GraphXY:
def __init__(self, xli...
Computers and Technology, 06.04.2021 05:20 tlecuyer
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
Answers: 1
Computers and Technology, 23.06.2019 17:00
The camera still is bad even with the new iphone xr and especially in low light it is even worst because you can see the pixels more if its in low light. if all you apple customers want apple to fix this then lets fill there feedback with complaints about the
Answers: 1
Computers and Technology, 24.06.2019 04:30
Fall protection, confined space entry procedures, controlled noise levels, and protection from chemical hazards are some of the things that contribute to a safe and
Answers: 1
Computers and Technology, 24.06.2019 14:00
What are the different components of the cloud architecture?
Answers: 2
Computers and Technology, 24.06.2019 18:20
Acommon algorithm for converting a decimal number to binary is to repeatedly divide the decimal number by 2 and save the remainder. this division is continued until the result is zero. then, each of the remainders that have been saved are used to construct the binary number.write a recursive java method that implements this algorithm.it will accept a value of int and return a string with the appropriate binary character representation of the decimal number.my code: public class lab16{public string converttobinary(int input){int a; if(input > 0){a = input % 2; return (converttobinary(input / 2) + "" +a); } return ""; } }
Answers: 1
History, 30.03.2020 18:54
Mathematics, 30.03.2020 18:54
Chemistry, 30.03.2020 18:54
Biology, 30.03.2020 18:54
Mathematics, 30.03.2020 18:54
Chemistry, 30.03.2020 18:54
Mathematics, 30.03.2020 18:54