Skip to content

tashfeen786/Python_Programming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

62 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ Python Programming โ€” Complete Learning Repository

Python Jupyter Commits Stars Topics License

๐Ÿ“š A complete structured Python programming repository covering fundamentals to advanced concepts โ€” from data types and loops to OOP, decorators, exception handling, file I/O, FastAPI Routers, HTTP Methods, and AI API integration.


๐Ÿ“‹ Topics Index

๐Ÿ”ฐ Foundations

Lecture Topic
Lecture 04 (Part 1) Python Basics โ€” Variables, Strings, Input
Lecture 04 (Part 2) Python Data Types โ€” int, float, list, dict, tuple, set
Lecture 05 Operators โ€” Arithmetic, Comparison, Logical, Assignment
Lecture 06 Loops โ€” for, while, nested loops, break, continue
Lecture 07 Conditional Statements โ€” if, elif, else

๐Ÿ”ง Functions

Lecture Topic
Lecture 08 Introduction to Functions & Built-in Functions
Lecture 09 User Defined Functions โ€” def, return, arguments
Lecture 09 (Final) User Defined Functions โ€” advanced examples
Lecture 10 Local vs Global Scope ยท is vs ==
Lecture 11 Higher Order Functions โ€” map, filter, lambda
Lecture 12 Decorators in Python
Lecture 22 Required and Optional Parameters

๐Ÿ›ก๏ธ Error Handling & File I/O

Lecture Topic
Lecture 13 File Handling & JSON โ€” read, write, parse
Lecture 14 Exception Handling โ€” try, except, finally

๐Ÿ—๏ธ Object Oriented Programming

Lecture Topic
Lecture 16 OOP Basics โ€” Classes, Objects, Methods, Exercises

โšก FastAPI & Web Development

Lecture Topic
intro_to_fastapi_basic.ipynb FastAPI Introduction โ€” building first REST API
Lecture 23 FastAPI Routers โ€” HTTP Methods, Path & Query Parameters, APIRouter
Lecture 24 HTTP Methods Deep Dive โ€” GET, POST, PUT, DELETE, Modular API Design

๐Ÿค– AI Integration

File Topic
intro_to_ai_apis.ipynb AI API Integration โ€” calling LLMs from Python

๐Ÿ“ Assignments & Practice

File Description
Assignment_01.ipynb Python fundamentals practice
Assignment_02.ipynb Functions & control flow exercises
Practice_Lec_01.ipynb Hands-on practice notebook

๐Ÿ’ก Key Concepts with Code Examples

๐Ÿ”ท Decorators

import time

def timer(func):
    def wrapper(*args, **kwargs):
        start = time.time()
        result = func(*args, **kwargs)
        end = time.time()
        print(f"{func.__name__} ran in {end-start:.4f}s")
        return result
    return wrapper

@timer
def slow_function():
    time.sleep(1)
    return "Done!"

slow_function()
# Output: slow_function ran in 1.0012s

๐Ÿ”ท Higher Order Functions

numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

# map โ€” apply function to each element
squared = list(map(lambda x: x**2, numbers))

# filter โ€” keep elements matching condition
evens = list(filter(lambda x: x % 2 == 0, numbers))

# lambda โ€” anonymous function
multiply = lambda x, y: x * y
print(multiply(3, 4))   # 12

๐Ÿ”ท OOP โ€” Classes & Objects

class BankAccount:
    def __init__(self, owner, balance=0):
        self.owner = owner
        self.__balance = balance   # private attribute

    def deposit(self, amount):
        self.__balance += amount
        return f"Deposited {amount}. Balance: {self.__balance}"

    def withdraw(self, amount):
        if amount > self.__balance:
            raise ValueError("Insufficient funds!")
        self.__balance -= amount

    @property
    def balance(self):
        return self.__balance

acc = BankAccount("Tashfeen", 1000)
print(acc.deposit(500))    # Deposited 500. Balance: 1500

๐Ÿ”ท Exception Handling

def safe_divide(a, b):
    try:
        result = a / b
    except ZeroDivisionError:
        print("Error: Cannot divide by zero!")
        return None
    except TypeError:
        print("Error: Invalid input type!")
        return None
    else:
        return result
    finally:
        print("Operation complete.")

safe_divide(10, 2)    # 5.0
safe_divide(10, 0)    # Error: Cannot divide by zero!

๐Ÿ”ท HTTP Methods in FastAPI (Lecture 23)

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()

class Item(BaseModel):
    name: str
    price: float

# GET โ€” retrieve data
@app.get("/items/")
def get_items():
    return {"items": []}

# POST โ€” create new resource
@app.post("/items/")
def create_item(item: Item):
    return {"id": 1, "item": item}

# PUT โ€” update existing resource
@app.put("/items/{item_id}")
def update_item(item_id: int, item: Item):
    return {"id": item_id, "updated": item}

# DELETE โ€” remove resource
@app.delete("/items/{item_id}")
def delete_item(item_id: int):
    return {"message": f"Item {item_id} deleted"}

๐Ÿ”ท FastAPI Routers โ€” Modular Design (Lecture 24)

# items_router.py โ€” separate file for item routes
from fastapi import APIRouter

items_router = APIRouter()

@items_router.get("/")
def get_all_items():
    return {"items": ["laptop", "phone", "tablet"]}

@items_router.post("/")
def add_item(name: str, price: float):
    return {"message": f"{name} added", "price": price}


# main.py โ€” include routers in main app
from fastapi import FastAPI
from items_router import items_router

app = FastAPI()

# Include router with prefix
app.include_router(items_router, prefix="/items", tags=["Shop Items"])

# Now /items/ โ†’ items_router endpoints
# Docs at: http://127.0.0.1:8000/docs

๐Ÿ”ท Path & Query Parameters (Lecture 23)

# Path Parameter โ€” part of URL
@app.get("/items/{item_id}")
def get_item(item_id: int):
    return {"item_id": item_id}
# Usage: GET /items/42

# Query Parameter โ€” optional, after ?
@app.get("/items/")
def get_items(skip: int = 0, limit: int = 10, q: str = None):
    return {"skip": skip, "limit": limit, "search": q}
# Usage: GET /items/?skip=0&limit=5&q=laptop

๐Ÿ”ท AI API Integration

import requests

def ask_llm(prompt: str, api_key: str) -> str:
    response = requests.post(
        "https://api.groq.com/openai/v1/chat/completions",
        headers={"Authorization": f"Bearer {api_key}"},
        json={
            "model": "llama3-8b-8192",
            "messages": [{"role": "user", "content": prompt}]
        }
    )
    return response.json()["choices"][0]["message"]["content"]

result = ask_llm("Explain FastAPI in one line", api_key="your_key")
print(result)

๐Ÿš€ Getting Started

# Clone the repo
git clone https://github.com/tashfeen786/Python_Programming.git
cd Python_Programming

# Install dependencies
pip install jupyter fastapi uvicorn requests pydantic

# Launch Jupyter notebooks
jupyter notebook

# Run FastAPI server
uvicorn main:app --reload
# Docs at: http://localhost:8000/docs

๐Ÿ—๏ธ Project Structure

Python_Programming/
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ Foundations
โ”‚   โ”œโ”€โ”€ Lecture_04.ipynb                          # Python basics
โ”‚   โ”œโ”€โ”€ Python_Lecture_04_part02_Data_types.ipynb # Data types
โ”‚   โ”œโ”€โ”€ Python_Lecture_05_Operators.ipynb         # Operators
โ”‚   โ”œโ”€โ”€ Python_Lecture_06_Loops.ipynb             # Loops
โ”‚   โ””โ”€โ”€ Lecture_07_Conditional_Statements.ipynb   # Conditionals
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ Functions
โ”‚   โ”œโ”€โ”€ Lecture 08 โ€” Built-in Functions.ipynb
โ”‚   โ”œโ”€โ”€ Lecture_09_User_Defined_Functions.ipynb
โ”‚   โ”œโ”€โ”€ Lecture 10 โ€” Scope & Identity.ipynb
โ”‚   โ”œโ”€โ”€ Lecture 11 โ€” Higher Order Functions.ipynb
โ”‚   โ”œโ”€โ”€ Lecture 12 โ€” Decorators.ipynb
โ”‚   โ””โ”€โ”€ Lecture 22 โ€” Required & Optional Parameters/
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ Error Handling & File I/O
โ”‚   โ”œโ”€โ”€ Lecture-13-file_Handling_json.ipynb
โ”‚   โ””โ”€โ”€ Lecture 14 โ€” Exception Handling.ipynb
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ OOP
โ”‚   โ””โ”€โ”€ Lecture 16 โ€” OOP Basics.ipynb
โ”‚
โ”œโ”€โ”€ โšก FastAPI & Web Development
โ”‚   โ”œโ”€โ”€ intro_to_fastapi_basic.ipynb              # FastAPI intro
โ”‚   โ”œโ”€โ”€ Lecture_23_FastAPI_Routers.pptx           # HTTP Methods + Routers
โ”‚   โ””โ”€โ”€ Lecture_24-HTTP-Methods.pptx              # Modular API design
โ”‚
โ”œโ”€โ”€ ๐Ÿค– AI Integration
โ”‚   โ””โ”€โ”€ intro_to_ai_apis.ipynb                    # LLM API calls
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ Assignments & Practice
โ”‚   โ”œโ”€โ”€ Assignment_01.ipynb
โ”‚   โ”œโ”€โ”€ Assignment_02.ipynb
โ”‚   โ””โ”€โ”€ Practice_Lec_01.ipynb
โ”‚
โ””โ”€โ”€ ๐Ÿ“ Notes/                                     # Study notes

๐Ÿ”— How This Connects to Real Projects

Skill Learned Applied In
OOP & Classes FastAPI models, Pydantic schemas
Decorators @app.get(), @app.post() route decorators
Exception Handling Production API error handling
File & JSON I/O Data loading in ML pipelines
FastAPI basics CryptoChat backend
FastAPI Routers HelmetEye modular API structure
HTTP Methods REST API design in all backend projects
AI API integration LangChain ยท RAG systems

๐Ÿ”ฎ Coming Soon

  • Async Python โ€” asyncio, async/await
  • FastAPI Middleware & Authentication
  • FastAPI + PostgreSQL โ€” database integration
  • Generators & iterators
  • Context managers (with statement)
  • Type hints & mypy

๐Ÿ‘จโ€๐Ÿ’ป Author

Tashfeen Aziz โ€” AI/ML Engineer & Python Developer

LinkedIn GitHub Email


โญ If you found this helpful, please give it a star!

About

๐Ÿ Complete Python course โ€” Functions, OOP, Decorators, FastAPI Routers, HTTP Methods & AI API Integration | 58+ commits | Jupyter Notebooks๐Ÿ Complete Python course โ€” Functions, OOP, Decorators, FastAPI Routers, HTTP Methods & AI API Integration | 58+ commits | Jupyter Notebooks

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors