week 1


Week 1: Introduction to Python

Setting up Python & Development Environment

  1. Checking Python Version

    import sys
    print(sys.version)
  2. Installing a Package using pip

    pip install requests
  3. Running a Simple Python Script

    print("Hello, Python!")
  4. Using Virtual Environments

    python -m venv my_env
    source my_env/bin/activate  # On macOS/Linux
    my_env\Scripts\activate     # On Windows
  5. Using IDLE (Python’s Built-in IDE)

    python -m idlelib
  6. Checking Installed Packages

    import pkg_resources
    installed_packages = {pkg.key: pkg.version for pkg in pkg_resources.working_set}
    print(installed_packages)
  7. Writing a Python Script and Running It Create hello.py:

    print("Hello, World!")

    Run it:

    python hello.py
  8. Basic REPL (Read-Eval-Print Loop) Usage

    python
    >>> 5 + 3
  9. Installing Jupyter Notebook

    pip install notebook
    jupyter notebook
  10. Running Python from a Jupyter Notebook

    print("Running Python in Jupyter Notebook!")

Basic Syntax, Data Types, and Variables

  1. Declaring Variables

  2. Using type() Function

  3. String Formatting

  4. Arithmetic Operations

  5. Multi-line Strings

  6. Boolean Logic

  7. User Input

  8. Type Casting

  9. String Slicing

  10. Checking Variable Scope


Last updated