You are viewing a single comment's thread. Return to all comments →
Step 1: Read Input Values
student_number, student_subject = map(int, input().split())
Step 2: Read Marks for Each Subject total_sum = [list(map(float, input().split())) for _ in range(student_subject)]
total_sum = [list(map(float, input().split())) for _ in range(student_subject)]
for i in range(student_number): avg = sum(x[i] for x in total_sum) / student_subject print(f'{avg:.1f}')
Seems like cookies are disabled on this browser, please enable them to open this website
Zipped!
You are viewing a single comment's thread. Return to all comments →
Step 1: Read Input Values
student_number, student_subject = map(int, input().split())
Step 2: Read Marks for Each Subject
total_sum = [list(map(float, input().split())) for _ in range(student_subject)]
for i in range(student_number):
avg = sum(x[i] for x in total_sum) / student_subject print(f'{avg:.1f}')
- This is a list comprehension that iterates student_subject times.
- Each line of input is expected to contain space-separated marks of all students for one subject.
- map(float, input().split()) ensures marks are treated as floating-point numbers.
- total_sum now holds a list of lists, where each inner list represents a subject's marks across all students.