알파카징징이 알파카징징이 코딩하는 알파카

데이터 구조 및 분석 ch_1_3 Naming, Styling and Comments

» writing

KAIST 산업및시스템공학과 문일철_ 데이터 구조 및 분석 수업을 참고하여 작성하였습니다

ch_1_3 Naming, Styling and Comments

정의


Naming, Styling and Comments

1. Naming, Styling and Comments
- Naming : Use names clearly conveying the meaning (의미를 잘 전달)
    # 1 class camel casing
    1) Class name
    - 명사 위주로
    - Capitalize the first letter 
    ex) HelloWorld

    2) Variable name
    - contents to be stored
    - start with lower case
    - acceptable (but python X)
    ex) numberOfStudents = 100
        intCount = 0

    3) Method name
    - Verb for the method action (움직이는거라 동사로 명)
    - start with lower case
    ex) def performAverage(self, val1, val2)

2. Indentation
: 4 spaces per each level (4칸 들여쓰기)

3. Comments
- block 주석 ``` ~~~ ``` or """ ~~~ """ : beginning and ending of multiline comments
- # 주석 : beginning of single-line comments

"""
징징이는 공부를 해요
징징이는 놀고 싶어요
징징이는 떡볶이를 좋아해요
"""

class HelloWorld :  # class
    def __init__(self) :    # fucntion
        print("Helllo world! just one more time! ")
    def __del__(self) :
        print("Good bye!")
    def performAverage(self, val1, val2) :
        average = (val1 + val2) /2.0
        print("The average of the scores is : ", average)