Posts

Showing posts with the label Python challenges with solution

Finding the percentage in python - HackerRank solution

Solution for hackerRank problem Finding the percentage in python Problem : The provided code stub will read in a dictionary containing key/value pairs of name:[marks] for a list of students. Print the average of the marks array for the student name provided, showing 2 places after the decimal. Example The  query_name  is 'beta'. beta's average score is  . Input Format The first line contains the integer  , the number of students' records. The next lines contain the names and marks obtained by a student, each value separated by a space. The final line contains  query_name , the name of a student to query. Constraints 2<=n<=10 0<=marks[i]<=100 length of marks arrays = 3 Output Format Print one line: The average of the marks obtained by the particular student correct to 2 decimal places. Sample Input 0 3 Krishna 67 68 69 Arjun 70 98 63 Malika 52 56 60 Malika Sample Output 0 56.00 Explanation 0 Explanation 0 Marks for Malika are   whose average is  Sample Input

Athlete sort in python - HackerRank solution

Image
Solution for hackerRank problem Athlete sort in python Problem : You are given a spreadsheet that contains a list of N  athletes and their details (such as age, height, weight, and so on). You are required to sort the data based on Kth the  attribute and print the final resulting table. Follow the example given below for a better understanding. Note that is indexed from 0 to M-1, where M is the number of attributes. Note : If two attributes are the same for different rows, for example, if two athletes are of the same age, print the row that appeared first in the input. Input Format The first line contains N and M separated by a space. The next N lines each contain M elements. The last line contains K  . Constraints 1<=N, M<=1000 0<=K<M Each element <= 1000 Output Format Print the lines of the sorted table. Each line should contain the space separated elements. Check the sample below for clarity. Sample Input 0: 5 3 10 2 5 7 1 0 9 9 9 1 23 12 6 5 9 1 Sample Output 0 7 1 0