Use overlapping for statements and conditional statements to obtain the mean (Python)

Asked 6 days ago, Updated 6 days ago, 1 views

I don't know how to solve it.


2022-09-20 16:02

1 Answers

Here's a simple doctor's code.

int student[number of students][number of subjects] = {...}, {...}, {...}, {...};   
int sum = 0; 
char studentName[5]  = { 'A', 'B', 'C', 'D', 'E' };                              

for(i: repeat as many students) {                                    
    for(j: repeat as many subjects) {                                    
        sum += student[i][j];                                     
        if (if you added the last subject of the student)                                    
            print(studentName[i] + "Average of students: " + sum / Number of subjects + '\n')";
    sum = 0;                             

Please refer to the pseudo code above and fill it out according to Python grammar.

Note that if the average value output format is a mistake, you can convert the format accordingly and output it.

The student's name is alphabetic uppercase, but unlike the pseudo code above, it is not assigned to the array.

You can simply print it out by referring to the ASCII code table.

2022-09-20 16:02

If you have any answers or tips

© 2022 pinfo. All rights reserved.