Ana sayfa
/
Teknoloji
/
Use a function to calculate the average marks. Use another function to find the highest mark and the lowest mark Use a function to count how many students scored above average. 3. Output: Print all the marks , the average mark, the highest mark, the lowest mark, and the number of students scoring above average.

Soru

Use a function to calculate the average marks.
Use another function to find the highest mark and the lowest mark
Use a function to count how many students scored above average.
3. Output:
Print all the marks , the average mark, the highest mark, the lowest mark,
and the number of students scoring above average.

Use a function to calculate the average marks. Use another function to find the highest mark and the lowest mark Use a function to count how many students scored above average. 3. Output: Print all the marks , the average mark, the highest mark, the lowest mark, and the number of students scoring above average.

Çözüm

4.4368 Voting
avatar
Esra
Kıdemli · 10 yıl öğretmeni
Uzman doğrulaması

Cevap

To calculate the average marks, you can use the following functionpython<br />def calculate_average_marks(marks):<br /> return functions:<br /><br />```python<br />def find_highest_mark(marks):<br /> return max(marks)<br /><br />def find_lowest_mark(marks):<br /> return min(marks)<br />```<br /><br />To count how many students scored above average, you can use the following function:<br /><br />```python<br />def count_students_above_average(marks, average_marks):<br /> return sum(1 for mark in marks if mark > average_marks)<br />```<br /><br />Finally, to output all the marks, the average mark, the highest mark, the lowest mark, and the number of students scoring above average, you can use the following code:<br /><br />```python<br />marks = [85, 90, 78, 92, 88] # Example marks list<br />average_marks = calculate_average_marks(marks)<br />highest_mark = find_highest_mark(marks)<br />("Marks:", marks)<br />print("Average mark:", average_marks)<br />print("Highest mark:", highest_mark)<br />print("Lowest mark:", lowest_mark)<br />print("Number of students scoring above average:", students_above_average)<br />```<br /><br />This will output:<br /><br />```<br />Marks: [85, 90, 78, 92, 88]<br />Average mark: 86.6<br />Highest mark: 92<br />Lowest mark: 78<br />Number of students scoring above average: 3<br />```
Derecelendirmek için tıklayın: