Introduction to Python
Scripts, the REPL, and your first program
Skills taught: python.print, python.comments, python.repl, python.script
Running Python
# Check your Python version
python --version
# Python 3.12.0
# Start the interactive REPL
python
# >>> (prompt — type Python here)
# >>> 2 + 2
# 4
# >>> exit()
# Run a script file
python hello.py
Your first Python program
# This is a comment — Python ignores it
print('Hello, World!')
print('Python is fun')
print(2 + 2) # prints 4
print('2 + 2 =', 2 + 2) # prints: 2 + 2 = 4
print() — your main output tool
# Print a string
print('Hello')
# Print a number
print(42)
print(3.14)
# Print multiple values (separated by space by default)
print('Name:', 'Prashant', 'Age:', 28)
# → Name: Prashant Age: 28
# Custom separator
print('a', 'b', 'c', sep='-')
# → a-b-c
# No newline at the end
print('Loading', end='...')
print('done')
# → Loading...done
Frequently Asked Questions
Python 2 or Python 3?
Python 3 — always. Python 2 reached end-of-life in 2020. All libraries, tutorials, and tools now target Python 3. Current stable: Python 3.12.
How do I install Python?
Download from python.org/downloads (Windows/macOS). Linux: sudo apt install python3. macOS with Homebrew: brew install python. Verify: python --version or python3 --version.