Python Basics

Python is a high-level, interpreted programming language known for its readability and simplicity. Its syntax is designed to be close to human language, making it an ideal choice for AI and scripting.

Core Concepts

1. Functions (The “Box” Analogy)

In Python, a function is a named “box” that wraps a set of instructions. This allows for code reuse and modular design.

  • Syntax: Defined using the def keyword followed by the function name and parentheses.
  • Example:
    def make_chai():
        # instructions go here
        pass

2. Indentation

Unlike many other languages that use curly braces {} to define code blocks, Python uses indentation.

  • Standard: 4 spaces are the industry-standard recommendation.
  • Importance: Correct indentation is not just for readability; it is a structural requirement. Incorrect indentation will cause the code to fail.

3. Readability & Logic

Python’s philosophy emphasizes the “readability” of code. Statements like if not kettle_has_water: are intuitive and closely mimic logical thinking.

Tooling & Environment

  • IDE: VS Code is highly recommended.
  • Theme: “Chai Theme” (Dark) is a popular choice for developers who prefer a warm, readable color palette.
  • Extensions:
    • Python: Provides color coding, IntelliSense, and debugging support.
    • Pylance: Enhances type hinting and performance in VS Code.

References

python programming vscode syntax