Sort by

recency

|

4608 Discussions

|

  • + 0 comments
    stu_list = []
    n= int(input())
    
    # Collecting student names and scores
    for i in range(n):
        name = input()
        score = float(input())
        stu_list.append([name, score])
    
    # Extracting only the scores
    new_list = [x[1] for x in stu_list]
    
    # Finding the second lowest score
    m = sorted(set(new_list))  # Sorting unique scores
    
    # Sorting names alphabetically
    names = sorted([i[0] for i in stu_list if i[1] == m[1]])
    
    # Printing names
    for name in names:
        print(name)
    
    # Printing names
    for name in names:
        print(name)
    
  • + 0 comments

    n = int(input("Enter number of Students: ")) stu_list = []

    # Collecting student names and scores for i in range(n): name = input("Student name: ") score = float(input("Score: ")) stu_list.append([name, score])

    # Extracting only the scores marks_list =[x[1] for x in stu_list]

    # Finding the second lowest score m = sorted(set(marks_list)) # Sorting unique scores

    
    
    
    

    Printing names

    for name in names: print(name)

    Printing names

    for name in names: print(name)

  • + 0 comments

    Read the number of students

    n = int(input())

    Initialize lists to store student names and grades

    students = [] grades = []

    Read each student's name and grade

    for _ in range(n): name = input() grade = float(input()) students.append((name, grade)) grades.append(grade)

    Find the second lowest grade

    sorted_grades = sorted(set(grades)) # Get unique grades and sort them second_lowest_grade = sorted_grades[1] # The second lowest grade is at index 1

    Find students with the second lowest grade

    second_lowest_students = [name for name, grade in students if grade == second_lowest_grade]

    Sort the names alphabetically

    second_lowest_students.sort()

    Print each name on a new line

    for student in second_lowest_students: print(student)

  • + 0 comments

    if name == 'main': def second_last(l): sl = max(l) for i in l: if i > min(l): if i < sl: sl = i return sl

    L = []
    S = []
    N = int(input())
    
    if 2 <= N <= 5:
      for _ in range(N):
          name = input()
          score = float(input())
          S.append(score)
          L.append([name,score])
    
      S = list(set(S))
      second_marks_in_class = second_last(S)
      second_scorers_in_class = []
    
      for i in L:
        if i[1] == second_marks_in_class:
          second_scorers_in_class.append(i[0])
    
      second_scorers_in_class.sort()
    
      for i in second_scorers_in_class:
        print(i)
    

    `

  • + 0 comments

    if name == 'main':

    #build the nested list
    students = []
    for _ in range(int(input())):
        name = input()
        score = float(input())                
        students.append([score, name])
    #print("students ",students)
    
    #sort sutdents list ascending
    ordered = sorted(students, key=lambda item: (item[0], item[1]))
    #print("ordered ",ordered)
    
    #get the lowest score of ordered student list
    min_score = min(ordered[0] for ordered in ordered)
    #print("first min ",min_score)
    
    #remove the lowest score from the ordered list
    without_min_score = [ordered for ordered in ordered if ordered[0] > min_score ]
    #print("without min ",without_min_score)
    
    #get the second lowest score by getting the min of without_min_score list
    second_min_score = min(without_min_score[0] for without_min_score in without_min_score)
    #print("second min ", second_min_score)
    
    #remove the score above the second lowesrt score
    with_sec_min_score = [without_min_score for without_min_score in without_min_score if without_min_score[0] <= second_min_score ]
    #print("with secon min ",with_sec_min_score)
    
    #map to extract the values
    final2 = list(map(lambda item: item[1] ,with_sec_min_score))
    for i in range(len(final2)):
        print(final2[i])