Week 3 assignment 1

mail@pastecode.io avatar
unknown
python
10 days ago
351 B
0
Indexable
Never
    for i in range(len(marks)):
        for j in range(len(marks)):
            if marks[i] > marks[j]:
                marks[i], marks[j] = marks[j], marks[i]
    
    median = 0
    if len(marks) % 2 != 0:
      median = marks[len(marks)//2]
    else:
      mid_index = len(marks)//2
      median = (marks[mid_index] + marks[mid_index-1]) / 2
      
Leave a Comment