Week1-2 | 자료형변환.py

Seongeun·2023년 6월 11일

week1

목록 보기
2/9
post-thumbnail

Week1-2. python 자료형변환(type-casting)

  • int( ): integer(정수) type의 자료형으로 변환된다.
 var1 = True  #bool_type
 var1 = int(True)  #int_type #type_casting
 
 num1 = 3.141592   #float_type
 num1 = int(num1)  #int_type 
 
 print(num1)       #출력값_3
  • float( ): real number(실수) type의 자료형으로 변환된다.

  • str( ): string(문자열) type의 자료형으로 변환된다.

 var1 = 3.141592   #float_type
 var1 = str(var1)  #str_type 

0개의 댓글