Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new_list = [1, 2, 3, 4, 5, 6]
- new_list_1 = [2, 3, 4, 5, 6, 7]
- dist = []
- for index in range(len(new_list)):
- x1 = new_list[index]
- x2 = new_list[index+1]
- y1 = new_list_1[index]
- y2 = new_list_1[index+1]
- distance_1 = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
- dist.append(distance_1)
- index += 1
- print(dist)
- new_list = [1, 2, 3, 4, 5, 6]
- new_list_1 = [2, 3, 4, 5, 6, 7]
- dst = lambda xy1, xy2: ((xy1[0] - xy2[0]) ** 2 +
- (xy1[1] - xy2[1]) ** 2
- )** 0.5
- def pairs(seq1, seq2):
- itr = iter(zip(seq1, seq2))
- prev = next(itr)
- while True:
- cur = next(itr)
- yield (prev, cur)
- prev = cur
- result = [dst(pair[0], pair[1]) for pair in pairs(new_list, new_list_1)]
- print(result)
- xs = 1, 2, 3, 4, 5, 6
- for x1, x2 in zip(xs, xs[1:]):
- print(f"x1={x1}, x2={x2}")
- x1=1, x2=2
- x1=2, x2=3
- x1=3, x2=4
- x1=4, x2=5
- x1=5, x2=6
- xs = [1, 2, 3, 4, 5, 6]
- ys = [2, 3, 4, 5, 6, 7]
- points = list(zip(xs, ys))
- distances = [((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
- for (x1, y1), (x2, y2) in zip(points, points[1:])]
- 1.4142135623730951 1.4142135623730951 1.4142135623730951
- 1.4142135623730951 1.4142135623730951
- a = [1,2,3,4,5,6]
- b = [2,3,4,5,6,7]
- for i in range(0:len(a)//2):
- lets_do_some_math(a[2*i],b[2*i],a[2*i+1],b[2*i+1])
- new_list = [1, 2, 3, 4, 5, 6]
- new_list_1 = [2, 3, 4, 5, 6, 7]
- dist = []
- for index in range(len(new_list)):
- try:
- x1 = new_list[index]
- x2 = new_list[index + 1]
- y1 = new_list_1[index]
- y2 = new_list_1[index + 1]
- distance = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
- dist.append(distance)
- except IndexError:
- pass
- print(dist)
- [1.4142135623730951, 1.4142135623730951, 1.4142135623730951, 1.4142135623730951, 1.4142135623730951]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement