from collections import namedtuple
# Define the NamedTuple for a 2D point with color data
Point = namedtuple('Point', ['x', 'y', 'r', 'g', 'b'])
# Create the first point
print("Enter the data for the first point:")
x1 = int(input("Enter x coordinate (short): "))
y1 = int(input("Enter y coordinate (short): "))
r1 = int(input("Enter red color value (byte): "))
g1 = int(input("Enter green color value (byte): "))
b1 = int(input("Enter blue color value (byte): "))
point1 = Point(x1, y1, r1, g1, b1)
# Create the second point
print("\nEnter the data for the second point:")
x2 = int(input("Enter x coordinate (short): "))
y2 = int(input("Enter y coordinate (short): "))
r2 = int(input("Enter red color value (byte): "))
g2 = int(input("Enter green color value (byte): "))
b2 = int(input("Enter blue color value (byte): "))
point2 = Point(x2, y2, r2, g2, b2)
# Display the points data
print("\nThe data for the first point is:")
print(f"x: {point1.x}, y: {point1.y}, r: {point1.r}, g: {point1.g}, b: {point1.b}")
print("\nThe data for the second point is:")
print(f"x: {point2.x}, y: {point2.y}, r: {point2.r}, g: {point2.g}, b: {point2.b}")
Output
Enter the data for the first point:
Enter x coordinate (short): 5
Enter y coordinate (short): 10
Enter red color value (byte): 255
Enter green color value (byte): 100
Enter blue color value (byte): 50
Enter the data for the second point:
Enter x coordinate (short): 20
Enter y coordinate (short): 25
Enter red color value (byte): 0
Enter green color value (byte): 255
Enter blue color value (byte): 200
The data for the first point is:
x: 5, y: 10, r: 255, g: 100, b: 50
The data for the second point is:
x: 20, y: 25, r: 0, g: 255, b: 200