←Back to Subject
Notes
Notes
Study material and explanations
Diagrams
Diagrams
Visualize concepts easily
Mnemonics
Mnemonics
Tricks to remember faster
One Night Prep
One Night Prep
Short and focused revision
Revision
Revision
Quick summary and key points
Important Questions
Important Questions
Practice most relevant questions
Diagrams

Diagrams

Visual representations for Unit 5

Life Cycle of a Thread in Python

Life Cycle of a Thread in Python
1. New (Born)
t = Thread()
→ t.start() →
2. Runnable (Ready)
Waiting for CPU
→ Scheduler →
3. Running
Executing run()
→ Done →
5. Terminated
(Dead State)
4. Blocked / Waiting State (Triggered by sleep(), join(), or waiting for Lock.acquire())
Explanation
  • Calling start schedules the thread's work and its target may run or wait.
  • The thread finishes when its target returns or exits through an unhandled exception.
Detailed Notes →Quick Revision →

How Thread Synchronization Works with Lock

How Thread Synchronization Works with Lock
1. Acquire Lock
lock.acquire()
(Door Locked 🔒)
→
2. Critical Section
Only 1 Thread Updates Shared Data
→
3. Release Lock
lock.release()
(Door Unlocked 🔓)
Explanation
  • A thread acquires the lock before changing shared state.
  • Other threads using that lock wait until the complete protected update is finished.
Detailed Notes →Quick Revision →

5 Steps of Python Database Communication (PDBC)

5 Steps of Python Database Communication (PDBC)
Step 1: Import Driver
import sqlite3
or mysql.connector
Step 2: Connect
con = connect(...)
Establishes DB link
Step 3: Create Cursor
cur = con.cursor()
SQL execution handle
Step 4: Execute SQL
cur.execute(sql)
& con.commit()
Step 5: Close
cur.close()
con.close()
Explanation
  • Open a connection, create a cursor and execute a parameterised statement.
  • Read or commit the result as appropriate and release the resources afterwards.
Detailed Notes →Quick Revision →

The Golden Trio of Python Data Science Libraries

The Golden Trio of Python Data Science Libraries
1. NumPy (Numerical Python)
Fast multi-dimensional arrays (ndarray), matrices, and linear algebra calculations.
2. Pandas (Panel Data)
Tabular data manipulation using Series (1D) and DataFrame (2D Excel-like tables).
3. Matplotlib
Data visualization library for drawing 2D graphs (Line, Bar, Scatter, Histogram, Pie charts).
Explanation
  • NumPy works with numerical arrays and pandas organises labelled data.
  • Matplotlib turns the selected values into a plot for interpretation.
Detailed Notes →Quick Revision →