멀티캠퍼스 1주차- 3

2023. 12. 29. 17:24Data Science/Study 자료

28일 리뷰

  • 클래스, 함수, 문자열 클래스 다양한 메서드
  • 리스트 클래스 다양한 메서드
    • append, extend, insert, remove...

딕셔너리

  • Dictionary : 사전
  • 구성 : key -value, keyword(=key), 결과값(=value)
    • 문자열, 리스트, tuple : 데이터 조회 시
    인덱싱 또는 슬라이싱
    • 딕셔너리에서 값을 조회하는 방법은 key값을 통해서 값을 조회
In [6]:
country_capital ={ '대한민국' : '서울', '일본' : '도쿄', '미국' : '워싱턴', '영국' : '런던' } country_capital
Out[6]:
{'대한민국': '서울', '일본': '도쿄', '미국': '워싱턴', '영국': '런던'}
In [4]:
# 딕셔너리에서 value 값을 조회하는 방법은 key값을 통해 조회 # key값은 중복으로 만들 수 없음 country_capital['대한민국'] #문자열 반환
Out[4]:
str
In [7]:
data = { 1 : '버스', 3 : '비행기' } # 숫자 1은 리스트, 문자열, tuple, 인덱스 번호와는 다른 숫자 # 사전은 _dict 라고 사용하는게 좋아보임 data[1]
Out[7]:
'버스'
In [8]:
data2 = { 'list1' : [1, 2, 3], 'list2' : [4, 5, 6] } data2
Out[8]:
{'list1': [1, 2, 3], 'list2': [4, 5, 6]}
In [9]:
data3 = { 'list1' : [1, 2, 3], 'list2' : [4, 5, 6], 1 : '테스트' } data3
Out[9]:
{'list1': [1, 2, 3], 'list2': [4, 5, 6], 1: '테스트'}

딕셔너리 사용처

  • 데이터 분석 : 엑셀 테이블
    • 1억개, 데이터 가공 (최소 1-2시간 가공 작업)
    • 임시 테이블
  • 인터넷 자료형중 JSON 데이터 포맷
  • JSON 데이터 포맷 ==> 딕셔너리와 동일 +API 데이터 크롤링, 기본 자료형(JSON) ==> 딕셔너리 변환 , 변환 후 데이터 가공

딕셔너리 다루기

In [21]:
country_capital ={ '대한민국' : '서울', '일본' : '도쿄', '미국' : '워싱턴', '영국' : '런던' }
In [22]:
#벨류 바꾸기 country_capital['대한민국'] = '부산' country_capital
Out[22]:
{'대한민국': '부산', '일본': '도쿄', '미국': '워싱턴', '영국': '런던'}
In [23]:
#삭제하는 방법 #del del country_capital['영국'] country_capital
Out[23]:
{'대한민국': '부산', '일본': '도쿄', '미국': '워싱턴'}
In [24]:
type(country_capital)
Out[24]:
dict
In [26]:
# 리스트의 형태로 나오지만 리스트타입이 아님 print(type(country_capital.keys())) country_capital.keys()
<class 'dict_keys'>
Out[26]:
dict_keys(['대한민국', '일본', '미국'])
In [27]:
result = country_capital.keys() result.append('독일')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-27-5b509fdeda12> in <cell line: 2>()
      1 result = country_capital.keys()
----> 2 result.append('독일')

AttributeError: 'dict_keys' object has no attribute 'append'
In [29]:
# 데이터 형변환 (리스트) list(result) result.append('독일')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-29-e0739046f25d> in <cell line: 3>()
      1 # 데이터 형변환 (리스트)
      2 list(result)
----> 3 result.append('독일')

AttributeError: 'dict_keys' object has no attribute 'append'
In [30]:
result = list(country_capital.keys())
In [15]:
country_capital.items()
Out[15]:
dict_items([('대한민국', '부산'), ('일본', '도쿄'), ('미국', '워싱턴')])
In [19]:
new_df ={ '중국' : '베이징', '필리핀' : '마닐라', '호주' : '캔버라' } country_capital.update(new_df) country_capital
Out[19]:
{'대한민국': '부산', '일본': '도쿄', '미국': '워싱턴', '중국': '베이징', '필리핀': '마닐라', '호주': '캔버라'}
In [20]:
country_capital.clear() #빈 사전 생성 country_capital
Out[20]:
{}

if 조건문

  • 만약 A라면 ~일 것이다
  • 프로그래밍에서 조건문
    • 만약 조건이 True라면 ~를 해라
    • 참과 거짓을 만드는 것이 포인트
In [31]:
x = int(input('점수를 입력하세요')) if x >= 90 : # 조건문을 직접 설계하는게 포인트 print('합격')
점수를 입력하세요100
합격
In [32]:
x = int(input('점수를 입력하세요')) if x >= 90 : # 조건문을 직접 설계하는게 포인트 print('합격') else: print('불합격')
점수를 입력하세요70
불합격
In [ ]:
x = int(input('점수를 입력하세요')) if x >= 90 : # 조건문을 직접 설계하는게 포인트 print('합격') elif x >= 80: print('부분합격') else: print('불합격')

문제

  • 학생성적에 따라 등급정하기
  • A, B, C, D, F
    • 90점 이상 A
In [34]:
x = int(input('점수를 입력하세요')) if x >= 90 : # 조건문을 직접 설계하는게 포인트 print('A') elif x >= 80: print('B') elif x >= 70: print('C') elif x >= 60: print('D') else: print('F')
점수를 입력하세요60
D

중첩 조건문

  • if조건문 내부에 또다른 조건문 생성
In [35]:
 
점수를 입력하세요100
부분합격
In [37]:
x = int(input('점수를 입력하세요')) if x >= 90 : # 조건문을 직접 설계하는게 포인트 if x == 100: print('장학금 수여') print('합격') elif x >= 80: print('부분합격') else: print('불합격')
점수를 입력하세요99
합격

반복문

  • for-loop, while
  • 반복문의 필요성
In [52]:
for i in range(10) : print('hello')
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello

for - loop 특징

In [56]:
for i in range(3): print(f'{i}번째 hello')
0번째 hello
1번째 hello
2번째 hello
  • 반복 범위 지정 시, 시퀀스 자료형도 사용 가능
    • 오늘/내일 블로그 주제 : 시퀀스 자료형에 대해서 정리
    • 대표적인 것 : 리스트, 문자열
In [59]:
nums = [1, 2, 3, 4, 5] for num in nums : print('안녕하세요')
안녕하세요
안녕하세요
안녕하세요
안녕하세요
안녕하세요
In [60]:
stri = "hello" for text in stri : print('text')
text
text
text
text
text
In [63]:
tuples = (1,2,3,4) for num in tuples : print(num)
1
2
3
4
In [76]:
country_capital for country in country_capital : print(country) #value값 추출 print(country_capital[country]) #[키값을 대입 시킨 것] print(f'{country}의 수도는 {country_capital[country]}이다.')
대한민국
부산
대한민국의 수도는 부산이다.
일본
도쿄
일본의 수도는 도쿄이다.
미국
워싱턴
미국의 수도는 워싱턴이다.
In [78]:
# 중첩 for문 # 반복문 내 또 다른 반복문 x_list = ['x1','x2'] y_list = ['y1','y2'] for x in x_list : #print(x) for y in y_list: print(x,y)
x1 y1
x1 y2
x2 y1
x2 y2

구구단

  • 2 x 1 = 2
In [93]:
x_list = [2, 3 ,4 ,5 ,6 , 7, 8, 9] y_list = [1, 2, 3 ,4 ,5 ,6 , 7, 8, 9] for x in x_list: for y in y_list : print(f'{x} * {y} = {x * y}')
2 * 1 = 2
2 * 2 = 4
2 * 3 = 6
2 * 4 = 8
2 * 5 = 10
2 * 6 = 12
2 * 7 = 14
2 * 8 = 16
2 * 9 = 18
3 * 1 = 3
3 * 2 = 6
3 * 3 = 9
3 * 4 = 12
3 * 5 = 15
3 * 6 = 18
3 * 7 = 21
3 * 8 = 24
3 * 9 = 27
4 * 1 = 4
4 * 2 = 8
4 * 3 = 12
4 * 4 = 16
4 * 5 = 20
4 * 6 = 24
4 * 7 = 28
4 * 8 = 32
4 * 9 = 36
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
6 * 1 = 6
6 * 2 = 12
6 * 3 = 18
6 * 4 = 24
6 * 5 = 30
6 * 6 = 36
6 * 7 = 42
6 * 8 = 48
6 * 9 = 54
7 * 1 = 7
7 * 2 = 14
7 * 3 = 21
7 * 4 = 28
7 * 5 = 35
7 * 6 = 42
7 * 7 = 49
7 * 8 = 56
7 * 9 = 63
8 * 1 = 8
8 * 2 = 16
8 * 3 = 24
8 * 4 = 32
8 * 5 = 40
8 * 6 = 48
8 * 7 = 56
8 * 8 = 64
8 * 9 = 72
9 * 1 = 9
9 * 2 = 18
9 * 3 = 27
9 * 4 = 36
9 * 5 = 45
9 * 6 = 54
9 * 7 = 63
9 * 8 = 72
9 * 9 = 81
In [89]:
for x in range(2,10): for y in range(1,10): print(f'{x} * {y} = {x * y}')
2 * 1 = 2
2 * 2 = 4
2 * 3 = 6
2 * 4 = 8
2 * 5 = 10
2 * 6 = 12
2 * 7 = 14
2 * 8 = 16
2 * 9 = 18
3 * 1 = 3
3 * 2 = 6
3 * 3 = 9
3 * 4 = 12
3 * 5 = 15
3 * 6 = 18
3 * 7 = 21
3 * 8 = 24
3 * 9 = 27
4 * 1 = 4
4 * 2 = 8
4 * 3 = 12
4 * 4 = 16
4 * 5 = 20
4 * 6 = 24
4 * 7 = 28
4 * 8 = 32
4 * 9 = 36
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
6 * 1 = 6
6 * 2 = 12
6 * 3 = 18
6 * 4 = 24
6 * 5 = 30
6 * 6 = 36
6 * 7 = 42
6 * 8 = 48
6 * 9 = 54
7 * 1 = 7
7 * 2 = 14
7 * 3 = 21
7 * 4 = 28
7 * 5 = 35
7 * 6 = 42
7 * 7 = 49
7 * 8 = 56
7 * 9 = 63
8 * 1 = 8
8 * 2 = 16
8 * 3 = 24
8 * 4 = 32
8 * 5 = 40
8 * 6 = 48
8 * 7 = 56
8 * 8 = 64
8 * 9 = 72
9 * 1 = 9
9 * 2 = 18
9 * 3 = 27
9 * 4 = 36
9 * 5 = 45
9 * 6 = 54
9 * 7 = 63
9 * 8 = 72
9 * 9 = 81
In [94]:
#짝지어주는것 names = ['A','B','C'] ages = [10, 20, 30] for name, age in zip(names, ages): print(name, age)
A 10
B 20
C 30
In [95]:
#인덱싱 names = ['A','B','C'] for idx, name in enumerate(names): print(idx, name)
0 A
1 B
2 C

While 특징

  • for-loop 특징 : 항상 범위를 지정한다
  • 몆번 반복문을 수행할지 숫자로 컨트롤이 가능
  • While 특징
  • 조건문이 False가 될 떄까지 반복문을 수행
  • 조건문이 True 이면 반복문 무한 수행
In [96]:
#초기값 지정 i = 1 n = 3 while i <= n : #특정 조건이 False가 되도록 작성 print(f'현재 {i}번') i += 1
현재 1번
현재 2번
현재 3번

for-loop, While 비교

  • Only 데이터 분석 (for-loop만 집중 공부)
    • 행과 열은 거의 고정
    • 범위가 주어져 있음
  • 개발자 경력 (둘 다)
    • 카메라가 켜진 상태에서 필터 추가
    • 카메라 온 (True상태)
    • 카메라 오프 (False상태)

break 문

  • 중간에 반복문 강제 종료 -특정 시점에 반복문 강제 종료

문자열과 for-loop

In [97]:
texts = 'phthon' for text in texts: print(text) #text가 t가 되면 break if text == 't': #조건식을 숫자로 비교, 문자 매칭 여부로 True/False를 나눔 print('text는 t입니다.') break
p
h
t
text는 t입니다.

리스트 컴프리헨션

  • forloop 및 for loop if 조건문 한줄로 처리
In [98]:
#pythonic 코드 numbers = [1, 2, 3, 4, 5] result = [1, 4, 9, 16, 25] #거듭제곱
In [102]:
numbers = [1, 2, 3, 4, 5] result =[] for number in numbers: result.append(number**2) print(result) #이 코드를 한줄로
[1, 4, 9, 16, 25]
In [104]:
numbers = [1, 2, 3, 4, 5] result2 =[i ** 2 for i in numbers] result2
Out[104]:
[1, 4, 9, 16, 25]

조건문 추가

In [105]:
numbers = [1, 2, 3, 4, 5] result =[] for i in numbers: if i >= 3: result.append(i ** 2) print(result)
[9, 16, 25]
In [106]:
numbers = [1, 2, 3, 4, 5] result2 =[i ** 2 for i in numbers if i >= 3] result2
Out[106]:
[9, 16, 25]
  • 시각화 라이브러리
    • matplotlib, plotly 옵션 설정 할때, 자주 사용됨
    • 5 - 1.3, 5 - 1.4

파이썬 문서화 (Docstring)

  • 코딩을 한다. 프로그래밍을 한다.
  • 누군가에게 관련 지식을 전달하는 것과 동일
    • 혼자 코딩하고, 혼자만 알 수 있는 언어로 코딩을 했다 ==> 협업 불가능
    • 취업, 퇴사, 이직 ==> 업무 인수인계를 해야 함
    • 코딩한 것에 문서화를 하지 못하면 업무 인수인계 자체가 불가능
  • 프로젝트 진행
    • 3주 / 4주 ==> 마지막주
      • 2-3명, ppt보고서 작성
      • 남은 인원, Docstring을 사용해서 문서화
    • help() 명령어를 사용해서 불러오기 할 수 있음
In [107]:
help(print)
Help on built-in function print in module builtins:

print(...)
    print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
    
    Prints the values to a stream, or to sys.stdout by default.
    Optional keyword arguments:
    file:  a file-like object (stream); defaults to the current sys.stdout.
    sep:   string inserted between values, default a space.
    end:   string appended after the last value, default a newline.
    flush: whether to forcibly flush the stream.

In [109]:
import math help(math)
Help on built-in module math:

NAME
    math

DESCRIPTION
    This module provides access to the mathematical functions
    defined by the C standard.

FUNCTIONS
    acos(x, /)
        Return the arc cosine (measured in radians) of x.
        
        The result is between 0 and pi.
    
    acosh(x, /)
        Return the inverse hyperbolic cosine of x.
    
    asin(x, /)
        Return the arc sine (measured in radians) of x.
        
        The result is between -pi/2 and pi/2.
    
    asinh(x, /)
        Return the inverse hyperbolic sine of x.
    
    atan(x, /)
        Return the arc tangent (measured in radians) of x.
        
        The result is between -pi/2 and pi/2.
    
    atan2(y, x, /)
        Return the arc tangent (measured in radians) of y/x.
        
        Unlike atan(y/x), the signs of both x and y are considered.
    
    atanh(x, /)
        Return the inverse hyperbolic tangent of x.
    
    ceil(x, /)
        Return the ceiling of x as an Integral.
        
        This is the smallest integer >= x.
    
    comb(n, k, /)
        Number of ways to choose k items from n items without repetition and without order.
        
        Evaluates to n! / (k! * (n - k)!) when k <= n and evaluates
        to zero when k > n.
        
        Also called the binomial coefficient because it is equivalent
        to the coefficient of k-th term in polynomial expansion of the
        expression (1 + x)**n.
        
        Raises TypeError if either of the arguments are not integers.
        Raises ValueError if either of the arguments are negative.
    
    copysign(x, y, /)
        Return a float with the magnitude (absolute value) of x but the sign of y.
        
        On platforms that support signed zeros, copysign(1.0, -0.0)
        returns -1.0.
    
    cos(x, /)
        Return the cosine of x (measured in radians).
    
    cosh(x, /)
        Return the hyperbolic cosine of x.
    
    degrees(x, /)
        Convert angle x from radians to degrees.
    
    dist(p, q, /)
        Return the Euclidean distance between two points p and q.
        
        The points should be specified as sequences (or iterables) of
        coordinates.  Both inputs must have the same dimension.
        
        Roughly equivalent to:
            sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q)))
    
    erf(x, /)
        Error function at x.
    
    erfc(x, /)
        Complementary error function at x.
    
    exp(x, /)
        Return e raised to the power of x.
    
    expm1(x, /)
        Return exp(x)-1.
        
        This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x.
    
    fabs(x, /)
        Return the absolute value of the float x.
    
    factorial(x, /)
        Find x!.
        
        Raise a ValueError if x is negative or non-integral.
    
    floor(x, /)
        Return the floor of x as an Integral.
        
        This is the largest integer <= x.
    
    fmod(x, y, /)
        Return fmod(x, y), according to platform C.
        
        x % y may differ.
    
    frexp(x, /)
        Return the mantissa and exponent of x, as pair (m, e).
        
        m is a float and e is an int, such that x = m * 2.**e.
        If x is 0, m and e are both 0.  Else 0.5 <= abs(m) < 1.0.
    
    fsum(seq, /)
        Return an accurate floating point sum of values in the iterable seq.
        
        Assumes IEEE-754 floating point arithmetic.
    
    gamma(x, /)
        Gamma function at x.
    
    gcd(*integers)
        Greatest Common Divisor.
    
    hypot(...)
        hypot(*coordinates) -> value
        
        Multidimensional Euclidean distance from the origin to a point.
        
        Roughly equivalent to:
            sqrt(sum(x**2 for x in coordinates))
        
        For a two dimensional point (x, y), gives the hypotenuse
        using the Pythagorean theorem:  sqrt(x*x + y*y).
        
        For example, the hypotenuse of a 3/4/5 right triangle is:
        
            >>> hypot(3.0, 4.0)
            5.0
    
    isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0)
        Determine whether two floating point numbers are close in value.
        
          rel_tol
            maximum difference for being considered "close", relative to the
            magnitude of the input values
          abs_tol
            maximum difference for being considered "close", regardless of the
            magnitude of the input values
        
        Return True if a is close in value to b, and False otherwise.
        
        For the values to be considered close, the difference between them
        must be smaller than at least one of the tolerances.
        
        -inf, inf and NaN behave similarly to the IEEE 754 Standard.  That
        is, NaN is not close to anything, even itself.  inf and -inf are
        only close to themselves.
    
    isfinite(x, /)
        Return True if x is neither an infinity nor a NaN, and False otherwise.
    
    isinf(x, /)
        Return True if x is a positive or negative infinity, and False otherwise.
    
    isnan(x, /)
        Return True if x is a NaN (not a number), and False otherwise.
    
    isqrt(n, /)
        Return the integer part of the square root of the input.
    
    lcm(*integers)
        Least Common Multiple.
    
    ldexp(x, i, /)
        Return x * (2**i).
        
        This is essentially the inverse of frexp().
    
    lgamma(x, /)
        Natural logarithm of absolute value of Gamma function at x.
    
    log(...)
        log(x, [base=math.e])
        Return the logarithm of x to the given base.
        
        If the base not specified, returns the natural logarithm (base e) of x.
    
    log10(x, /)
        Return the base 10 logarithm of x.
    
    log1p(x, /)
        Return the natural logarithm of 1+x (base e).
        
        The result is computed in a way which is accurate for x near zero.
    
    log2(x, /)
        Return the base 2 logarithm of x.
    
    modf(x, /)
        Return the fractional and integer parts of x.
        
        Both results carry the sign of x and are floats.
    
    nextafter(x, y, /)
        Return the next floating-point value after x towards y.
    
    perm(n, k=None, /)
        Number of ways to choose k items from n items without repetition and with order.
        
        Evaluates to n! / (n - k)! when k <= n and evaluates
        to zero when k > n.
        
        If k is not specified or is None, then k defaults to n
        and the function returns n!.
        
        Raises TypeError if either of the arguments are not integers.
        Raises ValueError if either of the arguments are negative.
    
    pow(x, y, /)
        Return x**y (x to the power of y).
    
    prod(iterable, /, *, start=1)
        Calculate the product of all the elements in the input iterable.
        
        The default start value for the product is 1.
        
        When the iterable is empty, return the start value.  This function is
        intended specifically for use with numeric values and may reject
        non-numeric types.
    
    radians(x, /)
        Convert angle x from degrees to radians.
    
    remainder(x, y, /)
        Difference between x and the closest integer multiple of y.
        
        Return x - n*y where n*y is the closest integer multiple of y.
        In the case where x is exactly halfway between two multiples of
        y, the nearest even value of n is used. The result is always exact.
    
    sin(x, /)
        Return the sine of x (measured in radians).
    
    sinh(x, /)
        Return the hyperbolic sine of x.
    
    sqrt(x, /)
        Return the square root of x.
    
    tan(x, /)
        Return the tangent of x (measured in radians).
    
    tanh(x, /)
        Return the hyperbolic tangent of x.
    
    trunc(x, /)
        Truncates the Real x to the nearest Integral toward 0.
        
        Uses the __trunc__ magic method.
    
    ulp(x, /)
        Return the value of the least significant bit of the float x.

DATA
    e = 2.718281828459045
    inf = inf
    nan = nan
    pi = 3.141592653589793
    tau = 6.283185307179586

FILE
    (built-in)


In [110]:
def myPower(n): '''숫자 n을 입력하면 n의 거듭제곱으로 반환''' result = n ** 2 return result
In [111]:
print(myPower(3))
9
In [112]:
print(myPower.__doc__)
숫자 n을 입력하면 n의 거듭제곱으로 반환
In [113]:
print(print.__doc__)
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)

Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file:  a file-like object (stream); defaults to the current sys.stdout.
sep:   string inserted between values, default a space.
end:   string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
In [115]:
def read_csv(sep, header): ''' Returns the sum of~~~. Parmeters: sep (str) : ~~~~ header(int) : ~~~~ Returns: c(int) : Sum of ~~ ''' c = sep + header return c
In [116]:
print(read_csv.__doc__)
  Returns the sum of~~~.
    Parmeters:
      sep (str) : ~~~~
      header(int) : ~~~~
      
    Returns:
      c(int) : Sum of ~~
  

클래스 상속

  • 부모 > 자식
  • 대분류 > 중분류 > 소분류
  • 동물
    • 동물의 공통적인 특징 : 살아 움직인다
    • 포유류
      • 새끼를 낳는다
    • 파충류
      • 알을 낳는다
In [118]:
class Animal : #Attribute 정의(=클래스 변수) name = '' # 공통함수 def eat(self): print("나는 먹을 수 있음") class dog(Animal): # 클래스 상속을 했다. #동물 ==> 강아지로 기본 기능 제공함 #name = '' 이코드는 불필요함 # 새로운 메서드 def dance(self): print(f'{self.name}강아지가 춤을 춘다' ) # 객체 생성 a = dog() # 객체생성을 dog로 했지만 Animal 클래스를 쓸 수 있구나 이 정도만 이해 a.name = '코코' a.eat()
나는 먹을 수 있음
In [119]:
b = Animal() b.name = '시고르자브종' b.eat()
나는 먹을 수 있음
In [120]:
b.dance() # 상속을 받지 않아서
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-120-a091c07220b8> in <cell line: 1>()
----> 1 b.dance()

AttributeError: 'Animal' object has no attribute 'dance'

클래스 Docstring

In [ ]:
class Person: """ 자기 소개하는 Person 클래스. ''' Attributes # Parameters ----------- name : str 사람의 이름을 의미 age : int 사람의 나이를 의미 grade : int 사람의 현재 학년을 의미 Methods ----------- info(comment=""): 사람의 개인정보를 출력 """ def __init__(self, name, age, grade): """ """ self.name = name self.age = age self.grade = grade def info(self, comment = ""): """ """ print(f'내 이름은 {self.name}. 내 나이는 {self.age}. 현재 학년은 {self.grade}. {comment}')