Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
111 views
in Computer by (51.9k points)
closed by

All the branches of XYZ school conducted an aptitude test for all the students in the age group 14 - 16. There were a total of n students. The marks of n students are stored in a list. Write a program using a user defined function that accepts a list of marks as an argument and calculates the ‘xth’ percentile (where x is any number between 0 and 100).You are required to perform the following steps to be able to calculate the ‘xth’ percentile.

Note: Percentile is a measure of relative performance i.e. It is calculated based on a candidate’s performance with respect to others. For example: If a candidate's score is in the 90th percentile, that means she/he scored better than 90% of people who took the test.

Steps to calculate the xth percentile:

I. Order all the values in the data set from smallest to largest using Selection Sort. In general any of the sorting methods can be used.

II. Calculate index by multiplying x percent by the total number of values, n.
For example: to find 90th percentile for 120 students: 0.90*120 = 108

III. Ensure that the index is a whole number by using math.round()

IV. Display the value at the index obtained in Step 3.

The corresponding value in the list is the xth percentile.

1 Answer

+1 vote
by (49.5k points)
selected by
 
Best answer
def bubblesort(numlist):
    length = len(numlist)
    for i in range( length - 1):
        for j in range(0, n-1-i):
            if numlist[j] > numlist[j+1]:
               numlist[j], numlist[j+1]  = numlist[j+1], numlist[j]


numbers = eval(input("Enter list of marks using bracket : "))

bubblesort(numbers)

x = int(input("For xth percentile, Enter x : "))

size = len(numbers)

index = int(round((size * x ) / 100, 0))

print(str(x) + "th percentile is : ")

print(numbers[index])

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...