Python input().split(), list.sort(reverse=True) 공백으로 자르기, 내림차순 정렬
입력 받은 string 을 공백기준으로 자르고 int 형으로 바꾼 후 내림차순하기data = list(map(int, input().split()))data.sort(reverse=True)print(data)32 84 15 93 47[93, 84, 47, 32, 15] map() 의 리턴값의 개수가 정해져 있다면 변수에 바로 넣을 수 있다.a, b, c = map(int, input().split())print(a, b, c)45 13 8745 13 87 입력을 최대한 빠르게 받기data = sys.stdin.readline().rstrip()print(data)abcdefgabcdefg - 입력이 너무 많아서 입력 받는것 만으로도 시간이 오래걸려서 시간초과 판정을 받을 수 있다. - 이진탐색,..
2022. 6. 20.
Python 내장함수 issubclass(), isinstance(), lambda(), filter(), map(), sorted(), zip()
issubclass 함수# Eagle 클래스는 Bird 클래스를 상속받음.class Eagle(Bird): passinsubclass(Eagle, Bird)True== Eagle 은 Bird 이다.== Eagle 클래스는 Bird 클래스를 상속받았다.== Eagle 클래스는 자식클래스이고 Bird 클래스는 부모클래스이다. isinstance 함수a = Eagle()ininstance(a, Eagle)Trueb = 3ininstance(b, Eagle)False lambda 함수함수를 생성할 때 사용하는 예약어로 def와 동일한 역할. 보통 함수를 한 줄로 간결하게 만들고자 할 때 사용.def sum(a, b): return a+bsum = lambda a, b: a+bsum(3, 4)7..
2022. 6. 19.