Get started learning Python with DataCamp's free Intro to Python tutorial. Learn Data Science by completing interactive coding challenges and watching videos by expert instructors. Start Now!
This site is generously supported by DataCamp. DataCamp offers online interactive Python Tutorials for Data Science. Join 11 million other learners and get started learning Python for data science today!
Good news! You can save 25% off your Datacamp annual subscription with the code LEARNPYTHON23ALE25 - Click here to redeem your discount
안녕, 세상!
Python은 매우 간단한 언어이며, 매우 직관적인 구문을 가지고 있습니다. 이 언어는 프로그래머가 기본 코드 없이 프로그래밍을 하도록 장려합니다. Python에서 가장 간단한 지시문은 "print" 지시문입니다 - 이는 그냥 한 줄을 출력하며 (C와 달리 줄 바꿈도 포함됩니다).
Python에는 두 가지 주요 버전인 Python 2와 Python 3가 있습니다. Python 2와 3는 상당히 다릅니다. 이 튜토리얼은 Python 3를 사용합니다. 그 이유는 Python 3가 더 의미론적으로 올바르고, 최신 기능을 지원하기 때문입니다.
예를 들어, Python 2와 3의 차이점 중 하나는 print
문입니다. Python 2에서는 "print" 문이 함수가 아니며, 따라서 괄호 없이 호출됩니다. 그러나 Python 3에서는 함수로서 괄호와 함께 호출되어야 합니다.
Python 3에서 문자열을 출력하려면 다음과 같이 작성합니다:
print("This line will be printed.")
들여쓰기
Python은 중괄호 대신 들여쓰기를 사용하여 블록을 구분합니다. 탭과 공백 모두 지원되지만, 표준 Python 코드에서는 네 개의 공백을 사용하는 것이 표준입니다. 예를 들어:
x = 1
if x == 1:
# 네 칸 들여쓰기
print("x is 1.")
연습 문제
"print" 함수를 사용하여 "Hello, World!"라는 줄을 출력하세요.
print("Goodbye, World!")
print("Hello, World!")
test_output_contains("Hello, World!")
success_msg('Great job!')
This site is generously supported by DataCamp. DataCamp offers online interactive Python Tutorials for Data Science. Join over a million other learners and get started learning Python for data science today!