Getting Started with Python
Checking access...
Python is a high-level, interpreted programming language known for its readability and versatility. Let’s get you set up and writing code.
Installing Python
Download Python from python.org (version 3.11+ recommended). During installation on Windows, check “Add Python to PATH”.
Verify the installation:
python --version# Python 3.12.0The Python REPL
Python includes an interactive shell called the REPL (Read-Eval-Print Loop). Type python in your terminal to start it:
>>> print("Hello, Python!")Hello, Python!>>> 2 + 35>>> exit()Your First Python Script
Create a file called hello.py:
print("Hello, Python!")Run it:
python hello.py# Hello, Python!Python Syntax at a Glance
Python uses indentation instead of braces to define code blocks:
# No semicolons neededname = "Alice"
# Indentation matters — 4 spaces is standardif name == "Alice": print("Hello, Alice!")else: print("Hello, stranger!")
# Comments use #Tip
Python’s print() function is your best debugging friend. Use it freely as you learn.
Using the Help System
Python’s built-in help() function is invaluable:
>>> help(print)# Shows documentation for the print function
>>> help(str)# Shows all methods available on stringsWriting Clean Python
Python enforces clean code through its syntax:
# ✅ Pythonic — clear and readablenumbers = [1, 2, 3, 4, 5]squares = [n ** 2 for n in numbers]
# ❌ Not Pythonic (but works)squares = []for n in [1, 2, 3, 4, 5]: squares.append(n ** 2)Key Takeaways
- Python uses indentation for code blocks — be consistent with 4 spaces
- The REPL is great for experimenting
print()andhelp()are your primary tools- Python values readability and simplicity
Up next: variables, data types, and the core building blocks of Python.