1. Features of Python

  • Simple & Easy to Learn: Python has a clean and readable syntax.
  • Freeware & Open Source: It is freely available and open-source.
  • Dynamically Typed: No need to declare variable types explicitly.
  • Interpreted: Python executes code line-by-line.
  • High-Level & Robust: Python provides memory management and strong error handling.

2. Comments in Python

  • Single-line Comment: Uses # (e.g., # This is a comment).
  • Multi-line Comment: Uses triple quotes """ ... """ or ''' ... '''.
  • Comments help in documentation and code readability.

3. Python Keywords

  • Control Flow: if, else, elif, for, while, break, continue, pass.
  • Exception Handling: try, except, finally, raise.
  • Functions & Modules: def, return, import, from, lambda.
  • Other Keywords: True, False, None, global, nonlocal, yield.

4. Identifiers & Case Styles

  • Identifiers: Variable names must start with a letter (A-Z or a-z) or _ and cannot be a keyword.
  • Case Sensitivity: Python is case-sensitive (abc and ABC are different).
  • Valid Identifiers: myVar, _my_var, abc123.
  • Invalid Identifiers: 123abc, for (reserved keyword).
  • Naming Conventions:
    • camelCase: myVariableName
    • PascalCase: MyClassName
    • snake_case: my_variable_name
    • kebab-case: Not used in Python (my-variable-name is invalid).

5. Arithmetic & Assignment Operators

  • Arithmetic Operators: +, -, *, /, // (floor division), % (modulus), ** (exponent).

  • Assignment Operators: =, +=, -=, *=, /=, %=, **=.

  • Example:

    x = 5  
    y = 2  
    print(x + y)  # Output: 7  
    x *= y  # Equivalent to x = x * y  
    print(x)  # Output: 10