Q. 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 90thpercentile 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()
VI. Display the value at the index obtained in Step 3.
The corresponding value in the list is the xth percentile.
Answer :-
def Portal ( lst ):
for i in range ( len( lst ) ):
for j in range ( len( lst) - 1 ):
if lst [ j ] > lst [ j + 1 ] :
lst[j] , lst [ j + 1] = lst[j + 1] , lst [j]
x = int(input ("Enter 'xth' percentile :- ") )
index = round( x * len( lst ) / 100 )
print("Index / Marks of Student :- ", lst[ index ])
n = int(input("Enter number of Student :- "))
print()
lst = []
for i in range(n) :
mark = int(input("Enter Mark of Student :- "))
lst += [ mark ]
print()
Portal(lst)
Output :-
Enter Mark of Student :- 95
Enter Mark of Student :- 46
Enter Mark of Student :- 123
Enter Mark of Student :- 159
Enter Mark of Student :- 136
Enter Mark of Student :- 178
Enter Mark of Student :- 56
Enter Mark of Student :- 99
Enter Mark of Student :- 88
Enter Mark of Student :- 146
Enter Mark of Student :- 128
Enter Mark of Student :- 137
Enter Mark of Student :- 111
Enter Mark of Student :- 156
Enter Mark of Student :- 48
Enter 'xth' percentile :- 95
Index / Marks of Student :- 178
>>>
where is answer
ReplyDeleteOk, I have updated it.
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )