Skip to content

Commit 2c94adf

Browse files
author
hallymer
committed
Python 파이썬 기본 함수_01 파일
내장함수(Built-in Functions) 내장 함수 기본 실습 내장 함수 종류, 중요한 내장 함수, 각 함수 예제 실습, filter, map, enumerate, range, zip에 대해서 배웠다. <중요!> enumerate : 인덱스 + Iterable 객체 생성 filter : 반복가능한 객체 요소를 지정한 함수 조건에 맞는 값 추출 map : 반복가능한 객체 요소를 지정한 함수 실행 후 추출
1 parent cdf605a commit 2c94adf

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

chapter08_01.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,40 @@ def conv_abs(x):
5959

6060
print(list(map(conv_abs,[1,-3,2,0,-5,6])))
6161
print(list(map(lambda x:abs(x),[1,-3,2,0,-5,6])))
62+
63+
# pow : 제곱값 반환
64+
print(pow(2,10))
65+
66+
# range : 반복가능한 객체(Iterable) 반환
67+
print(range(1,10,2))
68+
print(list(range(1,10,2)))
69+
print(list(range(0,-15,-1)))
70+
71+
# round : 반올림
72+
73+
print(round(6.5781, 2))
74+
print(round(5.6))
75+
76+
# sorted : 반복가능한 객체(Iterable) 정렬 후 반환
77+
78+
print(sorted([6,7,4,3,1,2]))
79+
a = sorted([6,7,4,3,1,2])
80+
print(a)
81+
print(sorted(['p','y','t','h','o','n']))
82+
83+
# sum : 반복가능한 객체(Iterable) 합 반환
84+
print(sum([6,7,8,9,10]))
85+
print(sum(range(1,101)))
86+
87+
# type : 자료형 확인
88+
89+
print(type(3)) # --> int
90+
print(type({})) # --> dictionary(key와 value로 구성)/ set(key와 value가 없다)
91+
print(type(())) # --> tuple
92+
print(type([])) # --> list
93+
94+
# zip : 반복가능한 객체(Iterable)의 요소를 묶어서 반환
95+
# zip함수는 tuple로 짝을 만들어서 반환한다
96+
97+
print(list(zip([10,20,30],[40,50,777])))
98+
print(type(list(zip([10,20,30],[40,50,777]))[0]))

0 commit comments

Comments
 (0)