Another make task, and this time the inner loop works something out for every row.
A teacher keeps the test scores of three students in three subjects. They are stored in a 2D array where the first item on each row is the student’s name, followed by their three test scores.
results = [["Ali", 45, 60, 55], ["Bea", 70, 80, 75], ["Cam", 30, 40, 35]]
Start your program with the results line exactly as it is above. Then write
code that:
//),Three lines, one per student, in the order they are in the array. NAME is the
student’s name and AVERAGE their average score:
NAME has an average score of AVERAGE
Output:
Ali has an average score of 53
Bea has an average score of 75
Cam has an average score of 35
Ali’s scores add up to 160, and 160 divided by 3 is 53 and a third. Integer
division drops the part after the decimal point, so the average is 53.
The tests also check your code: a program that does not have a for loop
inside a for loop, or that does not use //, does not pass.
Make sure that you check for the following things:
//, not /. With / you get 53.333333333333336 and
75.0.str() before it is joined onto the text with a
+.