Project: Overview
- Algorithms course
- Intermediate
- Lesson 21/80
- 4 min
Plan a mini app that sorts exam scores and prints stats.
Project: Overview
In this project we build a student-score sorting and statistics application in four steps.
First a function that prepares the score array, then sorting with merge sort, then picking the top N results, and finally printing statistics.
Each lesson will include the previous lesson's solution, so the code accumulates.
Data model
The score array is an integer list such as [85, 92, 78, 90, 88]. Each lesson works on this array.
The accumulating code: init_scores, merge_sort_scores, top_k, print_stats. Each function uses the previous one's result.
This structure mirrors modular code organization in real applications.
Practice Score array
Write init_scores(). Return [85, 92, 78, 90, 88]. Print [85, 92, 78, 90, 88] with print(init_scores()).
Starter code
def init_scores():
# Return score arraySample solution
def init_scores():
# Return score array
return [85, 92, 78, 90, 88]
print(init_scores())Expected output
[85, 92, 78, 90, 88]
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Project: Overview: match the terms
| Term | Meaning |
|---|---|
Step 1 |
Score array |
Step 2 |
Sort |
Step 3 |
Top N |
Step 4 |
Statistics |
2 Which sort does the project use?
- Bubble sort
- Merge sort Correct answer
- Selection sort
- Quick sort
Explanation: Merge sort
3 First step
def ____(...):
def init_scores(...):
Explanation: init_scores is right.