Good to know
- 가장 최신 버전의 파이썬은 Python 3이지만, 보안패치 이외에 업데이트되지 않는 Python 2 버전도 여전히 인기가 많다.
- Thonny, Pycharm, Netbeans or Eclipse를 이용해 IDE에서 파이썬을 사용할 수 있다.
print("Hello, World!")
Python Syntax
- Python은 command line에서 바로 작성해 실행하거나, 서버에 .py 파일을 만들어 실행할 수 있다.
C:\Users\Your Name>python myfile.py
>>> print("Hello, World!")
Hello, World!
Python Identation
- 다른 프로그래밍 언어에서 공백(tab)은 읽기 간편하도록 사용하지만, 파이썬에서는 중요한 역할을 한다.
- Python에서 공백은 코드 블럭을 나타낸다.
- 공백은 최소 한칸 이상이어야 한다.
- 같은 코드 블럭에서는 같은 크기의 공백을 써야 한다.
if 5 > 2
print("Five is greater than two!")
print("Hello, World!")
Python Comments
Creating a Comment
- 코멘트를 코드에 입력하기 위해서는 #을 사용한다.
#This is a comment.
print("Hello, World!")
- 코멘트를 줄의 마지막에 입력하면, 그 뒤의 코드는 무시된다.
print("Hello, World!") #This is a comment.
- 코멘트를 코드를 실행시키지 않기 위해 사용할 수도 있다.
#print("Hello, World!")
print("Cheers, Mate!")
- 여러 줄의 코멘트를 입력하기 위해서는 각 줄에 #을 입력하거나 """을 이용한다.
#This is a comment
#written in
#more than just one line
"""
This is a comment
written in
more than just one line
"""
print("Hello, World!")
Source : https://www.w3schools.com/python/