Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
Tags
- Import
- execCommand
- db
- ajax
- Porject
- await
- slow and steady
- addEventListener
- js
- 참고블로그
- promise
- 비동기
- json
- Project
- JS #프로젝트
- database
- mysql
- webpack
- prj
- 게임
- callback
- https://youtube.com/playlist?list=PLuHgQVnccGMA5836CvWfieEQy0T0ov6Jh&si=FTaYv8m21EhO-A2K
- object
- setTimeout()
- 혼프
- sql
- eport
- async
- https://m.blog.naver.com/tt2t2am1118/221010125300
- 동기
Archives
- Today
- Total
C-log
Welcome to Python : 내장 함수 본문
728x90
- 클래스 : https://hi-code.tistory.com/123
- 모듈 : https://hi-code.tistory.com/124
- 패키지 : https://hi-code.tistory.com/125
- 예외 처리 : https://hi-code.tistory.com/126
- 내장 함수 : https://hi-code.tistory.com/127
- 표준 라이브러리 : https://hi-code.tistory.com/128
- 외부 라이브러리 :https://hi-code.tistory.com/129
Title | Code | Console |
abs |
# 절댓값을 리턴 a = abs(3)
print(a)
a = abs(-3)
print(a)
abs(-1.2)
print(a)
|
3 3 3 |
all |
a = all([1, 2, 3]) # 1,2,3이 True print(a)
a = all([1, 2, 3, 0]) # 1,2,3이 True 지만 0으로 False
print(a)
a = all([]) # 빈값은 False
print(a)
|
True False True |
any |
a = any([1, 2, 3, 0]) # 1,2,3이 True print(a)
a = any([0, ""]) # 0과 ""는 False
print(a)
a = any([]) # 빈값은 False
print(a)
|
True False False |
chr |
# 숫자 값을 입력받아 그 코드에 해당하는 문자를 리턴 a = chr(97)
print(a)
|
a |
dir |
# 객체가 지닌 변수나 함수를 보여주는 함수 print(dir([1, 2, 3]))
print(dir({'1', 'a'}))
|
['__add__', '__class__', '__class_getitem__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__'... |
divmod |
# a,b의 인자를 나눈 몫과 나머지를 튜플로 리턴 print(divmod(7, 3))
|
(2, 1) |
enumerate |
# 데이터를 입력받아 인텍스 값을 포함하는 열겨형 객체 for i, name in enumerate(['body', 'foo', 'bar']):
print(i, name)
|
0 body 1 foo 2 bar |
eval |
#문자열로 구선된 표현식을 입력으로 받아 해당 문자열 실행 print(eval('1 + 2'))
print(eval('divmod(4,3)'))
|
3 (1, 1) |
filter |
#filter를 사용하지 않은 코드 def positive(l):
result = [] #양수만 걸러 내서 저장할 변수
for i in l:
if i > 0:
result.append(i) #리스트에 i 추가
return result
print(positive([1, -3, 2, 0, -5, 6]))
|
[1, 2, 6] |
def positive(x): return x > 0
print(list(filter(positive, [1, -3, 2, 0, -5, 6])))
|
[1, 2, 6] | |
hex |
a = hex(234) # 16진수로 변환 print(a)
|
0xea |
id |
a = 3 print(id(3))
print(id(a))
b = a
print(id(b))
|
2186759766320 2186759766320 2186759766320 |
input |
a = input("Enter : ") b = input()
|
Enter : 123 123 |
int |
a = int('3') print(a)
|
3 |
isinstance |
class Person: pass
a = Person()
print(isinstance(a, Person))
|
True |
len |
a = len("python") print(a)
a = len([1, 2, 3])
print(a)
a = len((1, 'a'))
print(a)
|
6 3 2 |
list |
a = list('python') print(a)
|
['p', 'y', 't', 'h', 'o', 'n'] |
map |
#for문 def two_times(numberList):
result = []
for number in numberList:
result.append(number * 2)
return result
result = two_times([1, 2, 3, 4])
print(result)
|
[2, 4, 6, 8] |
# map def two_times(x):
return x*2
result = list(map(two_times, [1, 2, 3, 4]))
print(result)
|
[2, 4, 6, 8] | |
max |
a = max([1, 2, 3]) print(a)
a = max("python")
print(a)
|
3 y |
min |
a = min([1, 2, 3]) print(a)
a = min("python")
print(a)
|
1 h |
oct |
a = oct(34) #8진수 문자열로 변경 print(a)
|
0o42 |
open |
f = open("binary_file", "rb") |
|
ord |
a = ord('a') # 유니코드 숫자 값 리턴 print(a)
|
97 |
pow |
a = pow(2, 5) #2^5 print(a)
|
32 |
range |
a = list(range(5)) print(a)
|
[0, 1, 2, 3, 4] |
a = list(range(5, 10)) print(a)
|
[5, 6, 7, 8, 9] | |
a = list(range(1, 10, 2)) #숫자 사이의 거리는 2 print(a)
a = list(range(0, -10, -1)) #숫자 사이의 거리는 -1
print(a)
|
[1, 3, 5, 7, 9] [0, -1, -2, -3, -4, -5, -6, -7, -8, -9] |
|
round |
#2번째 반올림 print(a)
|
5.68 |
sorted |
a = sorted([3, 1, 2]) print(a)
|
[1, 2, 3] |
str |
a = str(3) print(a)
print(type(a))
|
3 <class 'str'> |
sum |
a = sum([1, 2, 3]) print(a)
|
6 |
tuple |
print(tuple("abc")) print(tuple([1, 2, 3]))
print(tuple((1, 2, 3)))
|
('a', 'b', 'c') (1, 2, 3) (1, 2, 3) |
type |
print(type("abc")) print(type([]))
print(type(open("test", 'w')))
|
<class 'str'> <class 'list'> <class '_io.TextIOWrapper'> |
zip |
zIp = list(zip([1, 2, 3], [4, 5, 6])) print(zIp)
|
[(1, 4), (2, 5), (3, 6)] |
728x90
'📘Python' 카테고리의 다른 글
Welcome to Python : 표준 라이브러리 (0) | 2023.07.27 |
---|---|
Welcome to Python : 예외처리 (0) | 2023.07.25 |
Welcome to Python : 패키지 (0) | 2023.07.24 |
Welcome to Python : 모듈 (0) | 2023.07.24 |
Welcome to Python : 클래스 (0) | 2023.07.21 |
Comments