Keywords are the reserved words in Python.
A keyword can't be used as a variable name, function name, or any other identifier.

An identifier is a name given to entities like class, functions, variables, etc. It helps to differentiate one entity from another.
.은 이름에 넣으면 안된다.)Instructions that a Python interpreter can execute are called statements. For example, a = 1 is an assignment statement. if statement, for statement, while statement, etc. are other kinds of statements.
if,forandwhileare allreserved words.
파이썬에서, statement는 개행을 하면 끝난다. 하지만, \문자를 끝에 붙여서 다음과 같이 계속 확장시킬 수 있다.
a = 1 + 2 + 3 + \
4 + 5 + 6 + \
7 + 8 + 9
또한, 소괄호(), 중괄호{}, 대괄호[] 안에서는 개행을 해도 statement가 끝난거로 간주되지 않기 때문에 위의 예시를 다음과 같이 표현할 수도 있다.
a = ( 1 + 2 + 3 +
4 + 5 + 6 +
7 + 8 + 9 )
대괄호와 중괄호도 마찬가지이다.
color = ['red',
'yellow',
'blue']
;을 statements사이에 넣어주면 한 줄에 여러 statements도 가능하다
a = 1; b = 2; c = 3
다른 프로그래밍 언어들은 괄호로 감싸주어 블럭을 구분지어 주지만 파이썬에서는 들여쓰기를 해서 구분지어주기 때문에 괄호를 쓸 필요가 없다.
for i in range(1,11):
print(i)
if i == 5:
break
;을 이용하여 들여쓰기 없이 한 줄에 모두 표현할 수도 있지만 가독성을 위해서 들여쓰기하는 것이 좋다.
파이썬에서는 주석을 달 때 #를 이용한다.
#this is to print out hello world
print('hello world')
#hello world has been printed!
여러 줄을 주석 처리 하기 위해선 앞,뒤에 """ 혹은 ''' 를 붙여준다.
"""
this is
to print out
hello world
"""
print('hello world')
A docstring is short for documentation string.
docstring은 함수, 클래스, 모듈 등의 정의 다음에 적어주며 """가 이용된다.
def double(num): """function to double the value""" return 2*num print(double.__doc__)output
function to double the value