|
| 1 | +You are a teacher and you are correcting papers of your students who wrote an exam you just conducted. You are tasked with the following activities. |
| 2 | + |
| 3 | +## 1. Failed Students |
| 4 | + |
| 5 | +Create the function `count_failed_students()` that takes one parameter: `student_marks`. This function should count the number of students who have failed the subject, returning the count as an integer. We say that a student has failed if their mark is less than or equal to **40**. |
| 6 | + |
| 7 | +Note: `Iterate` through the student marks to find out your answer. |
| 8 | + |
| 9 | +Result should be an `int`. |
| 10 | + |
| 11 | +```python |
| 12 | +>>> count_failed_students(student_marks=[90,40,55,70,30])) |
| 13 | +2 |
| 14 | +``` |
| 15 | + |
| 16 | +## 2. Top Marks |
| 17 | + |
| 18 | +The Headmaster wants to find the group of top students. What qualifies student marks as `top marks` fluctuates, and you will need to find the student marks that are **greater than or equal to** the current threshold. |
| 19 | + |
| 20 | +Create the function `above_threshold()` where `student_marks` and `threshold` are the two required parameters: |
| 21 | + |
| 22 | +1. `student_marks` are a list of marks for each student |
| 23 | +2. `threshold` is the top mark threshold. Marks greater than or equal to this number are considered "top marks" . |
| 24 | + |
| 25 | +This function should return a `list` of all marks that are greater than or equal to a scoring threshold. |
| 26 | + |
| 27 | +**Note:** If you find a mark which is less than the threshold, you should `continue` to evaluating the next mark. |
| 28 | + |
| 29 | +```python |
| 30 | +>>> above_threshold(student_marks=[90,40,55,70,30], 70) |
| 31 | +[90, 70] |
| 32 | +``` |
| 33 | + |
| 34 | +## 3. First K Students. |
| 35 | + |
| 36 | +Create the function `first_k_student_marks()` with parameters `student_marks` and `k` |
| 37 | + |
| 38 | +1. Student marks are a list of marks of each student |
| 39 | +2. k is the number of students. |
| 40 | + |
| 41 | +You need to return the first K number of student Marks. Once you reach K number of students, you should exit out of the loop. |
| 42 | + |
| 43 | +```python |
| 44 | +>>> first_k_student_marks(student_marks=[90,80,100], k=1) |
| 45 | +[90] |
| 46 | +``` |
| 47 | + |
| 48 | +## 4. Full Marks |
| 49 | + |
| 50 | +Create the function `perfect_score()` with parameter `student_info`. |
| 51 | +`student_info` is a dictionary containing the names and marks of the students `{"Charles": 90, "Tony": 80}` |
| 52 | + |
| 53 | +Find if we have any students who scored "full marks"(_100%_)on the exam. If we don't find any "full marks" in `student_info`, we should return "No hundreds" |
| 54 | + |
| 55 | +Return the first student who has scored full marks - 100. |
| 56 | + |
| 57 | +```python |
| 58 | +>>> perfect_score(student_info={"Charles": 90, "Tony": 80, "Alex":100}) |
| 59 | +Alex |
| 60 | +>>> perfect_score(student_info={"Charles": 90, "Tony": 80}) |
| 61 | +No hundreds |
| 62 | +``` |
0 commit comments