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.
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%
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Distribution of candies according to ages of students
- Python | Sort list according to other list order
- Replace the odd positioned elements with their cubes and even positioned elements with their squares
- Python - Descending Sort String Numbers
- Python | Check for Descending Sorted List
- Minimum and maximum number of N chocolates after distribution among K students
- Python Program to Sort the list according to the column using lambda
- Python | Get a set of places according to search query using Google Places API
- Python | Sort a List according to the Length of the Elements
- Python | Sort a list according to the second element in sublist
- Python | Reshape a list according to given multi list
- Python | Merge two list of lists according to first element
- Python | Remove Consecutive tuple according to key
- Python | Arrange the files in directories according to extensions
- Python | Replace tuple according to Nth tuple element
- Python | Filter tuples according to list element presence
- Python - Sort list of Single Item dictionaries according to custom ordering
- Encrypt the String according to the given algorithm in Python
- Python - Append according to Kth character
- Python program to Sort Tuples by their Maximum element
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.