namedtuple
Completed
Create Point = namedtuple("Point", "x y"). Read n points and print the one closest to the origin (first one on ties) and the average x and y with 2 decimals.
Input
Line 1: n. Then n lines x y.
Output
Two lines.
Example
Input
3 3 4 -1 1 5 0
Output
Point(x=-1, y=1) 2.33 1.67
Editor
Python
Hints
Named fields read better than p[0] and p[1].
Solution explanation
A namedtuple is a lightweight immutable record with a readable repr.
Show solution
from collections import namedtuple
Point = namedtuple("Point", "x y")
points = [Point(*map(int, input().split())) for _ in range(int(input()))]
print(min(points, key=lambda p: p.x ** 2 + p.y ** 2))
print(f"{sum(p.x for p in points) / len(points):.2f} {sum(p.y for p in points) / len(points):.2f}")