Tech Blog of Pinomaker
Published 2022. 4. 20. 17:33
[Python] 기본 함수 정리 Language/Python

1. 01. print()

여러 자료 출력을 하는 함수이다.

<python />
print("Hello " + "world") //Hello world print("Hello ", "world") //Hello world

 

2. 02. eval()

실행 가능한 연산식 문자열을 실행한 결과를 반환

<python />
eval("3+12") //15 eval("3/2") //1.5

 

3. 03. type()

매개 변수로 넣은 값의 자료형을 알 수 있다.

<python />
type(3) //<class 'int'> type(3.14) //<class 'float'> type("Hello") //<class "str">

 

4. 04. divmod()

divmod(a,b)는 몫 연산과 나머지 연산을 함께 수행한다.

<python />
28 // , 28 % 3 // 9, 1 divmod(28, 3) // 9, 1 num1, num2 = divmod(28/3) print(num1, num2) //9, 1

 

5. 05. input()

입력 값을 문자열로 받는 함수이다.

 

<python />
abc = input() >>> 김인후 print(abc) // 김인후 def = input("Enter ur name") >>> Enter ur name 김인후 print(def) //김인후

 

6. 06. 자료 변환 함수 str(), int(), float()

str()은 문자열로, int()는 정수로, float()는 실수로 자료형을 변환한다.

<python />
str(235) // "235" int("235") //235 float(123) //123.0

 

7. 07. 10진수 변환 함수 bin(), oct(), hex()

16진수로 변환은 bin(), 8진수로 변환은 oct(), 2진수는 hex()

 

 

 

profile

Tech Blog of Pinomaker

@pinomaker

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!