Zipped in Hacker Rank Solution – Queslers

Problem : Zipped Hacker Rank Solution

This function returns a list of tuples. The i th tuple contains the i th element from each of the argument sequences or iterables.
If the argument sequences are of unequal lengths, then the returned list is truncated to the length of the shortest argument sequence.
Sample Code :

>>> print zip([1,2,3,4,5,6],'Hacker')
[(1, 'H'), (2, 'a'), (3, 'c'), (4, 'k'), (5, 'e'), (6, 'r')]
>>> 
>>> print zip([1,2,3,4,5,6],[0,9,8,7,6,5,4,3,2,1])
[(1, 0), (2, 9), (3, 8), (4, 7), (5, 6), (6, 5)]
>>> 
>>> A = [1,2,3]
>>> B = [6,5,4]
>>> C = [7,8,9]
>>> X = [A] + [B] + [C]
>>> 
>>> print zip(*X)
[(1, 6, 7), (2, 5, 8), (3, 4, 9)]

Task :

The National University conducts an examination of  N students in X subjects.
Your task is to compute the average scores of each student.

fig : Zipped in python – Hacker Rank Solution

The format for the general mark sheet is:

Student ID → ___1_____2_____3_____4_____5__               
Subject 1   |  89    90    78    93    80
Subject 2   |  90    91    85    88    86  
Subject 3   |  91    92    83    89    90.5
            |______________________________
Average        90    91    82    90    85.5 

Input Format :

The first line contains N and X separated by a space.
The next X lines contains the space separated marks obtained by students in a particular subject.

Constraints :

  • 0 < N <= 100
  • 0 < X <= 100

Output Format :

Print the averages of all students on separate lines.
The averages must be correct up to 1 decimal place.


Sample Input :

5 3
89 90 78 93 80
90 91 85 88 86  
91 92 83 89 90.5

Sample Output :

90.0 
91.0 
82.0 
90.0 
85.5  

Explanation :

Marks obtained by student 1: 89 90 91
Average marks of student 1:
270 / 3 = 90.0
Marks obtained by student 2: 90 91 92
Average marks of student 2:
273 / 3 = 91.0
Marks obtained by student 3: 78 85 83
Average marks of student 3:
246 / 3 = 82.0
Marks obtained by student 4: 93 88 89
Average marks of student 4:
270 / 3 = 90.0
Marks obtained by student 5: 80 86 90.5
Average marks of student 5:256.5 / 3 = 85.5

Zipped Hacker Rank Solution in python 2

N,X = map(int,raw_input().split())
marks = []

for i in xrange(X):
    marks.append(map(float,raw_input().split()))
    
for studentScores in zip(*marks):
    print sum(studentScores)/len(studentScores)

Zipped Hacker Rank Solution in python 3

# Enter your code here. Read input from STDIN. Print output to STDOUT
n, x = map(int, input().split()) 

sheet = []
for _ in range(x):
    sheet.append( map(float, input().split()) ) 

for i in zip(*sheet): 
    print( sum(i)/len(i) )

Zipped Hacker Rank Solution in pypy

# Enter your code here. Read input from STDIN. Print output to STDOUT
n, x = map(int, raw_input().split())
all_scores = [map(float, raw_input().split()) for _ in xrange(x)]

for student, score in zip(range(1, n+1), zip(*all_scores)):
    print sum(score)/x

Zipped Hacker Rank Solution in pypy 3

# Enter your code here. Read input from STDIN. Print output to STDOUT
# Enter your code here. Read input from STDIN. Print output to STDOUT
num_of_std,num_of_sbj=map(int,input().split())

all_scores=[]
for _ in range(num_of_sbj):
    all_scores.append(map(float,input().split()))
    
scores_by_std=zip(*all_scores)
avg_scores_by_std=[sum(scores)/num_of_sbj for scores in scores_by_std]
for avg_score in avg_scores_by_std:
    print(avg_score)
Zipped Hacker Rank Solution Review:

In our experience, we suggest you solve this Zipped Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

Zipped is available on Hacker Rank for Free, if you are stuck anywhere between compilation, just visit Queslers to get all Hacker Rank Solution

Zipped Hacker Rank Solution Conclusion:

I hope this Zipped Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Hacker Rank Problem & Solutions >>

Mini-Max Sum Hacker Rank Solution

String Validators Hacker Rank Solution

Text Alignment Hacker Rank solution

String validators Hacker Rank Solution

Staircase Hacker Rank Solution

Leave a Reply

Your email address will not be published. Required fields are marked *