2108 통계학 / 정렬 / 딕셔너리
Dictionarykey- value 로 이루어진 순서가 없는 자료형선언 : f = {} #최빈값을 저장할 딕셔너리삽입 : f[n] = 1print(student.items()) # 출력: dict_items([('name', 'John'), ('age', 21), ('year', 3)])print(student.keys()) # 출력: dict_keys(['name', 'age', 'year'])print(student.values()) # 출력: dict_values(['John', 21, 3]) 정답최빈값을 구하기 위해서 딕셔너리를 선언하여 입력around(값) -> 소수점 0번째 자리까지 반올림해서 출력 : 1.6. -> 2around(값, 1) -> 소수점 1번째 자리까지 반올림해서 출력..
11651 좌표 정렬하기 2 / 정렬 / 자바 Arrays.sort()
n = int(input())arrays = []for _ in range(n): x, y = map(int, input().split()) arrays.append((x, y))arrays.sort(key=lambda p: (p[1], p[0]))for x, y in arrays: print(x, y) Sortsort의 기본 -> 오름차순 정렬key는 정렬 기준을 반환하는 함수lambda : 인수1, 인수2, ...: 반환값key : [(3, 1), (2, 2), (1, 2), (2, 3), (1, 3)] -> 각각 생성된 key값에 의해서 오름차순으로 정렬되는 것 자바e1[0] = 1, e2[0] = 2일 때:e1[0] - e2[0]은 1 - 2 = -1-1은 음수이므로, e1이 e2..