#set()함수 또는 중괄호로 중복 제거 가능
data = set([1,1,2,3,4,4,5])
print(data)
data = {1,1,2,3,4,4,5}
print(data)
#{1, 2, 3, 4, 5}
score = 85
if score >= 70:
print('성적이 우수합니다')
a = [1,2,3,4,5,5,5]
remove_set = {3,5}
result = [i for i in a if i not in remove_set]
print(result)
scores = [90, 75, 77, 65, 97]
cheating_list = {2, 4}
for i in range(5):
if i+1 in cheating_list:
continue
if scores[i] >= 80:
print(i+1, "번 학생은 합격")
#1 번 학생은 합격
#5 번 학생은 합격
def add(a,b):
return a+b
print(add(3,7))
print((lambda a, b: a+b)(3,7))
#입력을 받을 수 있음.
list(map(int, input().split()))
import sys
sys.stdin.readline().rstrip()
answer = 7
print(f"정답은 {answer} 입니다.")
from itertools import permutations
data = ['A', 'B', 'C']
result = list(permutations(data,2))
print(result)
#[('A', 'B'), ('A', 'C'), ('B', 'A'), ('B', 'C'), ('C', 'A'), ('C', 'B')]
from itertools import combinations
data = ['A', 'B', 'C']
result = list(combinations(data,2))
print(result)
#[('A', 'B'), ('A', 'C'), ('B', 'C')]
from itertools import combinations_with_replacement
data = ['A', 'B', 'C']
result = list(combinations_with_replacement(data,2))
print(result)
#[('A', 'A'), ('A', 'B'), ('A', 'C'), ('B', 'B'), ('B', 'C'), ('C', 'C')]
#Max heap 구하는 방법
import heapq
list = [2,6,9,4,7,1]
heap = []
result = []
for item in list:
heapq.heappush(heap, -item)
while heap:
result.append(-heapq.heappop(heap))
print(result) #[9, 7, 6, 4, 2, 1]
#값이 특정 범위에 속하는 원소의 개수 구하기
from bisect import bisect_left, bisect_right
def count_by_range(a, left_value, right_value):
left_index = bisect_left(a, left_value)
right_index = bisect_right(a, right_value)
return right_index - left_index
a = [1,2,3,3,3,3,4,4,8,9]
# 값이 4인 데이터 개수 출력
print(count_by_range(a,4,4))
# 값이 [-1, 3] 범위에 있는 데이터 개수 출력
print(count_by_range(a,-1,3))
#2
#6