← All Exercises
Python NamedTuple Usage
intermediatepython
Background
NamedTuples provide readable, immutable record types with minimal memory overhead, ideal for data records.
Problem
Create a Point namedtuple with x and y fields, and write a function to compute the distance between two points.
Input
Two Point namedtuples with x and y coordinates.
Output
The Euclidean distance between the two points.
Sample tests
Sample 1
Input: Point(0,0), Point(3,4)
Expected: 5.0
Your solution
Learning objective
Learn namedtuple creation, field access, and practical usage for record data.