Posts

Showing posts with the label Basic Concepts in Python

Basic Concepts in Python

**Basic Concepts in Python** 1. **Syntax and Structure**      - **Indentation**: Python uses indentation (whitespace) to define code blocks (e.g., loops, functions) instead of braces.      - **Comments**: Start with `#`. Multi-line comments use triple quotes (`'''` or `"""`).      - **Statements**: End of line terminates a statement; use `\` for line continuation or parentheses for multi-line statements. 2. **Variables and Data Types**      - **Variables**: No explicit declaration; dynamically typed (e.g., `x = 5`, then `x = "hello"`).      - **Basic Types**:        - `int` (integer), `float` (decimal), `str` (text), `bool` (`True`/`False`), `NoneType` (`None`).      - **Collections**:        - **List**: Mutable, ordered (`[1, 2, 3]`).        - **Tuple**: Immutable, ordered (`(1, 2, 3)`). ...