4. 값의 형태를 변환하기

    # 실수형에서 문자열로 변환
    >>> a = str(3.14)
    >>> a
    '3.14'
    >>> a +1 # 문자열에 숫자를 더하면 타입 에러가 발생한다
    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    <ipython-input-54-98b939904c8e> in <module>
    ----> 1 a+1
    
    TypeError: can only concatenate str (not "int") to str
    
    # 문자열에서 정수로 변환
    >>> b = int("49")
    >>> b
    49
    >>> b + 11
    60
    
    # 정수형에서 실수형으로 변환
    >>> c = float(23)
    >>> c
    23.0
    >>> c + 0.9
    23.9
    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.