from collections import namedtuple
# Define the NamedTuple for a 2D point with color data
Point = namedtuple('Point', ['x', 'y', 'r', 'g', 'b'])
# Create an array to store up to 1000 points
points = []
# Prompt user for data for the first point
print("Enter the data for point 1:")
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): "))
# Store the first point in the array
points.append(Point(x1, y1, r1, g1, b1))
# Prompt user for data for the second point
print("Enter the data for point 2:")
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): "))
# Store the second point in the array
points.append(Point(x2, y2, r2, g2, b2))
# Display the data for the first point
print("\nThe data for the first point is:")
print(f"x: {points[0].x}, y: {points[0].y}, r: {points[0].r}, g: {points[0].g}, b: {points[0].b}")
# Display the data for the second point
print("\nThe data for the second point is:")
print(f"x: {points[1].x}, y: {points[1].y}, r: {points[1].r}, g: {points[1].g}, b: {points[1].b}")
Output
Enter the data for point 1:
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 point 2:
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