Skip to content

Commit 3955446

Browse files
committed
Updated python code
1 parent 35ec0b3 commit 3955446

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

hackerrank/python/basic_data_types/finding_the_percentage.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
scores = list(map(float, line))
77
student_marks[name] = scores
88
query_name = input()
9+
# Get the marks list of the queried student name
910
score_list = student_marks.get(query_name)
11+
#Calculating average
1012
average = sum(score_list)/len(score_list)
1113
print('{:.2f}'.format(average))

hackerrank/python/basic_data_types/list_comprehensions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
y = int(input())
44
z = int(input())
55
n = int(input())
6+
# Using list comprehension to find all permutations of x,y,z values whose sum is not equal to n
67
permutation_list = [[a,b,c] for a in range(x+1) for b in range(y+1) for c in range(z+1) if (a+b+c) != n]
78
print(permutation_list)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
if __name__ == '__main__':
22
n = int(input())
33
arr = map(int, input().split())
4+
# Converting to set datatype to retain only unique values. Then, it's converted to list datatype to access through indices
45
nums = list(set(arr))
56
nums.sort()
7+
# Get second last value of the list (Runner-up score)
68
print(nums[-2])

0 commit comments

Comments
 (0)