Hacker Rank Python Log

2/19/2022 9:33 PM In this post I will keep my progress on the python section of Hacker Rank updated. So far everything is pretty easy, but I am only a few programming challenges in. I think that I might go for the certification.

2/19/2022 10:38 PM Overall I think that that went very well. I began learning about something new towards the end, sets. I didn’t understand them very much at all for a bit, but I think I’ve got the basics down. I’m going to take a break for tonight and work on something else.

2/20/2022 3:34 PM I am going to work on some more Hacker Rank now. I find that my problem often is that I don’t understand the question. Not that I can’t do it.

2/20/2022 3:58 PM I just found a pretty cool way to remove duplicates from a list without using a set.

A = [2,3,4,4,4,5,5,6]
B = []
 for i in A:
        if i not in B:

2/20/2022 4:16 PM This one was actually quite tricky. I thought that my way was really bad, but after looking up how to do it online, in comparison my solution is quite clean. I will note that I was not allowed to use dictionaries to solve this problem. That could have saved some loops.

#Print the name(s) of any student(s) having the second lowest grade in.
#If there are multiple students, order their names alphabetically and print each one on a new line.

if __name__ == '__main__':
    list = []
    for _ in range(int(input())):
        temp = []
        name = input()
        score = float(input())
    scorelist = []
    for i in list:
    newscorelist = []
    for i in scorelist:
        if i not in newscorelist:
    seclow = newscorelist[1]
    seclownames = []
    for i in list:
        if i[1] == seclow:
    for i in seclownames:

2/20/2022 5:00 PM Here’s another one I did! This time it is working with dictionaries. Pretty cool stuff!

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

Sample input:
Krishna 67 68 69
Arjun 70 98 63
Malika 52 56 60
if __name__ == '__main__':
    n = int(input())
    student_marks = {}
    for _ in range(n):
        name, *line = input().split()
        scores = list(map(float, line))
        student_marks[name] = scores
    query_name = input()
    query_scores = student_marks[query_name]
    answer = sum(query_scores) / len(query_scores)
# Output: 56.00