# 문제 4: 튜플 정렬 (두 번째 값 기준)
# -------------------------------
students = [   ("지훈", 85), ("서연", 90), ("민재", 78)   ]

# TODO: 점수 기준으로 오름차순 정렬해서 출력
#sorted(리스트명 , key =함수명, reverse=True)
# print()
# def 기준(x):   # x=("지훈", 85)
#     return x[1]
# a = sorted(students, key=기준  )
# print(a)

# -------------------------------
# 문제 5: 튜플 정렬 (key 함수 사용)
# -------------------------------
items = [("연필", 10), ("지우개", 3), ("노트", 7)]

# def 기준(x):
#     return x[1]


# a = sorted( items, key=기준    ,reverse=True      )

print(a)
# -------------------------------
# 문제 6: 딕셔너리 → 리스트 → 정렬
# -------------------------------
count = {"사과": 5, "바나나": 2, "포도": 8}

# TODO 1: (이름, 개수) 튜플 리스트 만들기
# items = []

# TODO 2: 개수 기준으로 많은 순서대로 정렬해서 출력
# print()

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: