Skip to content
DeepForgeby svx
All problems
EasyLinear Algebrala-055

Midpoint of Two Points

Problem

Return the midpoint of points p and q, computed componentwise as (p[i] + q[i]) / 2.

Return the coordinates as floats.

Hint

The midpoint is the average of the two points.

Test cases

case 1
in: [[0,0],[4,6]]
expected: [2,3]
case 2
in: [[1,2],[3,4]]
expected: [2,3]
case 3
in: [[-2,5],[2,-5]]
expected: [0,0]
case 4
in: [[1.5,2.5],[2.5,3.5]]
expected: [2,3]
Starter codePython
def midpoint(p, q):
    # Your code here
    pass

4 test cases · run your code against them in the editor