sorted
-
Python Useful FunctionsComputer Science/Basic Programming with Python 2021. 11. 20. 19:00
Python에서 다른 library를 이용하지 않고도 사용할 수 있는 유용한 함수들이 있다. abs는 절대값을 계산해준다. abs(-2.371) 2.371 최소값과 최대값을 반환하는 min, max함수도 있고, min([-1, 1, 2, 3, 4]) -1 max([-1, 1, 2, 3, 4]) 4 정렬 후 결과를 주는 sorted함수도 있다. sorted([4, -1, 5, 0, 3]) [-1, 0, 3, 4, 5] type이 무엇인지 알려주는 type함수도 있고, print(type(1)) print(type(0.23)) print(type('hello')) print(type([1, 2, 3, 4])) print(type((1, 2, 3, 4))) print(type({1, 2, 3, 4})) pri..