- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Finding Students with Second Lowest Grade – Detailed Version #Python #HackerRank #NestedLists
In this video, we solve the HackerRank problem of finding the student(s) with the second lowest grade in a class using Python. We store student names and grades in a nested list, identify the second lowest grade, and then print the names of all students having that grade in alphabetical order.
Step-by-Step Explanation:
Input Reading:
Read the number of students.
For each student, read the name and grade and store them as a nested list.
#InputHandling #NestedLists
Identify Unique Grades:
Create a sorted list of unique grades to easily determine the second lowest grade.
#Sorting #UniqueValues
Filter Students:
Extract the names of students whose grade matches the second lowest grade.
Sort these names alphabetically.
#Filtering #Sorting
Output:
Print each name on a new line.
#Output #Result
Copy and paste the code below into your Jupyter Notebook to practice the detailed solution!
Code for Detailed Version (Copy-Paste in Jupyter Notebook):
def find_second_lowest_students():
# Read the number of students
n = int(input().strip())
students = []
# Collect student names and grades
for _ in range(n):
name = input().strip()
grade = float(input().strip())
students.append([name, grade])
# Extract a sorted list of unique grades
unique_grades = sorted({grade for name, grade in students})
# The second lowest grade
second_lowest = unique_grades[1]
# Get names of all students with the second lowest grade and sort them alphabetically
second_lowest_students = sorted([name for name, grade in students if grade == second_lowest])
# Print the names of the students
for student in second_lowest_students:
print(student)
if __name__ == '__main__':
find_second_lowest_students()
Видео Finding Students with Second Lowest Grade – Detailed Version #Python #HackerRank #NestedLists канала CodeVisium
Step-by-Step Explanation:
Input Reading:
Read the number of students.
For each student, read the name and grade and store them as a nested list.
#InputHandling #NestedLists
Identify Unique Grades:
Create a sorted list of unique grades to easily determine the second lowest grade.
#Sorting #UniqueValues
Filter Students:
Extract the names of students whose grade matches the second lowest grade.
Sort these names alphabetically.
#Filtering #Sorting
Output:
Print each name on a new line.
#Output #Result
Copy and paste the code below into your Jupyter Notebook to practice the detailed solution!
Code for Detailed Version (Copy-Paste in Jupyter Notebook):
def find_second_lowest_students():
# Read the number of students
n = int(input().strip())
students = []
# Collect student names and grades
for _ in range(n):
name = input().strip()
grade = float(input().strip())
students.append([name, grade])
# Extract a sorted list of unique grades
unique_grades = sorted({grade for name, grade in students})
# The second lowest grade
second_lowest = unique_grades[1]
# Get names of all students with the second lowest grade and sort them alphabetically
second_lowest_students = sorted([name for name, grade in students if grade == second_lowest])
# Print the names of the students
for student in second_lowest_students:
print(student)
if __name__ == '__main__':
find_second_lowest_students()
Видео Finding Students with Second Lowest Grade – Detailed Version #Python #HackerRank #NestedLists канала CodeVisium
Комментарии отсутствуют
Информация о видео
24 марта 2025 г. 13:24:12
00:00:10
Другие видео канала





















