Home>
I would like to prepare a list of 3 randomly generated hub stations and 25 randomly generated stations, and then generate a list excluding the stations included in a certain radius circle of 3 hub stations. Is calculated only for the last element.
I know that I'm a beginner and stumbling in a rudimentary place, but I'd appreciate it if someone could tell me.
Thank you.
def remove_station (station_list, hub_list, R_big):
X, Y = hub_list [0], hub_list [1]
x, y = station_list [0], station_list [1]
hub_size = len (hub_list [0])
station_size = len (station_list [0])
for i in range (hub_size):
for j in range (station_size):
Dx = X [i]x [j]
Dy = Y [i]y [j]
b = math.sqrt (Dx * Dx + Dy * Dy)
m = []
n = []
if bR_big>= 0: # If the distance between the station and the base station is more than R_big, it will be adopted as a station
m.append (x [j])
n.append (y [j])
else:
pass
return [m, n]

Answer # 1

Answer # 2
Impressions I saw briefly.
I don't think it will work because there is no if statement in the for statement.
Related articles
 python  please tell me the solution of gunicorn: command not found when deploying heroku (crying)
 getoldtweetserror solution for python
 python  i am in trouble because the cause of attributeerror is unknown
 python  i am in trouble because the cause of invalid syntax is unknown
 python  please let me know because there is something i don't understand
 python  about the solution when "list the strings separated by commas, but do not use the commas contained in the characte
 [python] i'm having a problem because i don't know how to efficiently output the line numbers of duplicate lines in a data frame
 python  please tell me the solution of yolov3 error [filenotfounderror: [errno 2] no such file or directory:'traintxt']
 python calculated with the obtained result
 python: pygameerror solution
Related questions
 python 3x  i can't convert the date ("2018/12/31") string in series to datetime with python
 python  something went wrong in the jupiter lab
 python  if unknown data is applied to the statistical model (generalized linear model) and the predicted value is output, it wi
 python 3x  i want to calculate spearson's rank correlation coefficient and pvalue for a twovariable data set obtained from ex
 python 3x  error in sample program of anaphora analysis of natural language processing using spacy and neuralcoref
 import  i'm having trouble reading a folder with a specific name in jupyter notebook
 error when deleting words not specified in list when using strip in python
 python 3x  i want to make a graph plot
 python 3x  i cannot understand the error message displayed by the jupyter notebook in the process of face recognition using dee
 error when deleting a word (conjunction) using replace and strip in python and storing sentences individually in a list
Hello.
The list m, n has been initialized after exiting the double loop, so only the last entry can enter m, n.
It is before the double loop that m and n are initialized.
Need to determine if the distance between a station and all hub stations is more than R_big
Because there is a double loop, the list of normal stations is outside and the list of hub stations is inside.
If you use random data without knowing whether the program is written correctly,
It becomes difficult to verify the program.
I corrected it based on that point. Please see below.
The coordinates of the hub station are as follows.
(25,25)
(75,25)
(75,75)
The coordinates of a normal station are as follows.
(25,20)
(75,30)
(75,60)
(25,75)
(25,60)
The radius R_big is 25.
As you can see by writing a picture, the two stations (25,75) and (25,60) are far from any hub station.
The execution result is as follows.
I'm glad if you can use it as a reference.