Python program for arranging the students according to their marks in descending order
Consider a class of 20 students whose names and marks are given to you. The task is to arrange the students according to their marks in decreasing order. Write a python program to perform the task.
Attention reader! All those who say programming isn't for kids, just haven't met the right mentors yet. Join the Demo Class for First Step to Coding Course, specifically designed for students of class 8 to 12.
The students will get to learn more about the world of programming in these free classes which will definitely help them in making a wise career choice in the future.
Input: Arun: 78% Geeta: 86% Shilpi: 65% Output: Geeta: 86% Arun: 78% Shilpi: 65%
Approach: Since problem states that we need to collect student name and their marks first so for this we will take inputs one by one in the list data structure then sort them in reverse order using sorted() built-in function based on the student’s percentage and in the last we will print the value accordingly.
Below is the implementation:
-----Program for printing student name with marks using list----- How many student record you want to store?? 3 Enter the student name and percentage: Arun: 78% Enter the student name and percentage: Geeta: 86% Enter the student name and percentage: Shilpi: 65% Sorted list of students according to their marks in descending order Geeta: 86% Arun: 78% Shilpi: 65%