Write a programExercise 1/4Basic10 XP

The midpoint of a segment

Task

Write a function stred(a, b) that gets two points as tuples (x, y) and returns the midpoint of the segment between them - also as a tuple. The midpoint is ((x1 + x2) / 2, (y1 + y2) / 2).

For example stred((0, 0), (4, 6)) returns (2.0, 3.0).

Examples

  • Call

    print(stred((0, 0), (4, 6)))

    Expected output

    (2.0, 3.0)

After you submit, 4 hidden tests will also check your solution: a midpoint between whole numbers, negative coordinates, the same point twice, returns a tuple.

Python starts the first time you run code.

Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.

Input (stdin)

Each line = one call to input().

Output

Hints

Try it yourself first. Each hint reveals a little more - and lowers the reward a little.

Signed out, hints are free - but no XP is awarded either.

Solution

The solution unlocks after the last hint.