criteria = ["price", "performance", "portability", "battery"]
weights = [5, 4, 3, 3]
names = ["Laptop A", "Laptop B", "Desktop C"]
scores = [[4, 3, 5, 5], [2, 5, 3, 3], [3, 5, 1, 1]]
best_name = ""
best_total = -1
for i in range(len(names)):
total = 0
for j in range(len(criteria)):
total = total + weights[j] * scores[i][j]
print(names[i], total)
if total > best_total:
best_total = total
best_name = names[i]
print("Best match:", best_name)
The decision matrix in Python, using lists and nested loops (lists are taught in the Arrays and Subprograms unit; scores here is a list of lists, one row per computer). Change the weights to model a different user. Output (one line each): Laptop A 62 / Laptop B 48 / Desktop C 41 / Best match: Laptop A