0% found this document useful (0 votes)
3 views195 pages

Python Final Notes Genai

The document outlines a comprehensive roadmap for learning Python, covering various modules from basic introduction to advanced topics like API integration and data visualization. Each module includes key concepts, examples, and practice tasks to reinforce learning. Additionally, it emphasizes a structured learning sequence to effectively grasp Python programming and its applications in fields like AI and automation.

Uploaded by

sonukr77.in
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views195 pages

Python Final Notes Genai

The document outlines a comprehensive roadmap for learning Python, covering various modules from basic introduction to advanced topics like API integration and data visualization. Each module includes key concepts, examples, and practice tasks to reinforce learning. Additionally, it emphasizes a structured learning sequence to effectively grasp Python programming and its applications in fields like AI and automation.

Uploaded by

sonukr77.in
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

================PYTHON FINAL NOTES FOR GEN AI PREP

==============================================

*Python Complete Roadmap (Sequence Wise)

# MODULE 1 — Python Introduction & Setup:--


Python kya hai?
Python installation
IDE setup
Visual Studio Code
PyCharm
First Python program
Print statement
Comments
Variables
Naming conventions
Keywords
Input/output basics

# MODULE 2 — Data Types:--


Integer
Float
String
Boolean
Type conversion
Type checking
Type casting
Memory basics

Practice:
Salary calculator
Age conversion

# MODULE 3 — Operators
Arithmetic operators
Assignment operators
Comparison operators
Logical operators
Membership operators
Identity operators
Bitwise basics

Practice:
EMI calculator
Percentage system

# MODULE 4 — Strings (Very Important)


String basics
Indexing
Slicing
String methods
upper()
lower()
replace()
split()
strip()
f-string formatting
String concatenation
Escape sequence
String validations

Practice:
Email formatter
Name cleaner

# MODULE 5 — List (Very Important)


List basics
Indexing
Negative indexing
Slicing
append()
insert()
remove()
pop()
sort()
reverse()
Nested list
Looping list
List functions
List copying

Practice:
Student marks list
Product list manager

# MODULE 6 — Tuple
Tuple basics
Immutable concept
Indexing
Slicing
Packing/unpacking
Tuple methods

Practice:
Fixed company data
# MODULE 7 — Set
Set basics
Unique values
add()
remove()
union()
intersection()
difference()
frozenset basics

Practice:
Duplicate removal system

# MODULE 8 — Dictionary (Most Important)


Dictionary basics
Key-value pair
Accessing data
add/update/delete
keys()
values()
items()
Nested dictionary
Loop dictionary
Dictionary methods

Practice:
Employee management system
Company database

# MODULE 9 — Conditional Statements


if
if else
elif
Nested if
Multiple conditions
Logical conditions

Practice:
Voting eligibility
Salary bonus system

# MODULE 10 — Loops (Super Important)


for loop
while loop
nested loop
break
continue
pass
range()
enumerate()

Practice:
Multiplication table
Attendance checker

# MODULE 11 — Functions
Function basics
Parameters
Arguments
Return statement
Default arguments
Keyword arguments
Lambda function
Recursive function
Scope (local/global)

Practice:
Calculator app

# MODULE 12 — Exception Handling


try
except
finally
else
Custom exception
Error debugging

Practice:
Login validation

# MODULE 13 — File Handling


Read file
Write file
Append file
CSV handling
JSON file handling
Context manager

Practice:
Employee records system

# MODULE 14 — OOPs (Object Oriented Programming)


Class
Object
Constructor
Inheritance
Polymorphism
Encapsulation
Abstraction
Method overriding

Practice:
Bank management system

# MODULE 15 — Modules & Packages


Import module
Custom module
math module
random module
datetime
os module
sys module

# MODULE 16 — Advanced Python


List comprehension
Dictionary comprehension
Generator
Iterator
Decorator
Regex
zip()
map()
filter()
reduce()

# MODULE 17 — NumPy
Arrays
Operations
Shape
Indexing
Broadcasting

Practice:
Data calculations

# MODULE 18 — Pandas
DataFrame
Series
Read CSV
Filtering
Groupby
Merge
Cleaning
Practice:
Excel automation

# MODULE 19 — SQL + Python Integration


Database connection
CRUD operations
Insert data
Fetch data
API to SQL
SQL automation

# MODULE 20 — API Integration (Very Important)


API basics
GET request
POST request
JSON response
Headers
API key
Authentication
Error handling
REST API

Practice:
Weather API
Cricket API
Finance API

# MODULE 21 — Automation with Python


Email automation
Excel automation
WhatsApp automation
File automation
Scheduling

# MODULE 22 — Data Visualization


Matplotlib
Charts
Bar graph
Line graph
Pie chart

# MODULE 23 — Web Scraping


HTML basics
BeautifulSoup
Requests
Data extraction

Practice:
News scraper
Product price tracker
# MODULE 24 — Gen AI Python
LLM basics
OpenAI API
Prompt engineering
RAG basics
Embeddings
Vector DB
AI agents
LangChain basics

# MODULE 25 — Projects (Mandatory)


Beginner
Calculator
ATM
Student management
Intermediate
Expense tracker
Employee management
API dashboard
Advanced
AI chatbot
Finance automation
SQL + API project
Gen AI assistant

!!!!!!!!!!!Learning Sequence (Follow This Exactly)!!!!!!!!!!!


Basic Python

Data Types

Strings

List/Tuple/Set/Dictionary

Condition

Loops

Functions

Exception Handling

File Handling

OOP

Advanced Python

Pandas + NumPy

SQL Integration

API Integration

Automation

Gen AI

Projects

****************************************
# MODULE 1 — Python Introduction & Setup:--
Python kya hai?
Python installation
IDE setup
Visual Studio Code
PyCharm
First Python program
Print statement
Comments
Variables
Naming conventions
Keywords
Input/output basics:-----

PART 1)Python Introduction & Setup:--


Python kya hai?
Python installation
IDE setup
Visual Studio Code
PyCharm---
MODULE 1 — Python Introduction & Setup (Simple Way)
1. Python Kya Hai?
Python ek programming language hai jisse hum:
Software bana sakte hain
Automation kar sakte hain
Website backend bana sakte hain
Data analysis kar sakte hain
AI / Gen AI projects bana sakte hain
API connect kar sakte hain

Simple language me:


Python ek language hai jisse hum computer ko instruction dete hain ki kya kaam
karna hai.

Example:
Tum computer ko bolte ho:
print("Hello Sonu")

Output:
Hello Sonu
Computer screen pe print karega:
Hello Sonu

Real Life Example:-


Jaise tum kisi worker ko instruction dete ho:
Ye saman warehouse me rakh do
Waise hi Python me computer ko instruction dete ho.

Example:
print("Open File")
Python kyu famous hai?

Python easy hai because:


✅ Easy syntax
✅ English jaisi language
✅ Beginner friendly
✅ AI/Gen AI me use hota hai
✅ SAP + Finance automation me useful
✅ SQL aur API ke saath connect hota hai

Example:
Difficult language:
public class Main {
public static void main(String[] args)
{
[Link]("Hello");
}
}
Python:
print("Hello")
Dekho kitna easy hai 😄

2. Python Installation::--
Python use karne ke liye install karna padta hai.

Step 1:
Official website kholo:
Python Official Website

Step 2:
Download Python pe click karo.

Step 3:
Latest version install karo.

Example:
Python 3.x.x

Step 4 (Most Important):


Install karte time:

✅ Add Python to PATH tick karna

Phir:
Install Now
Click kar dena.
Check Python Install Hua ya Nahi

Computer me:
CMD open karo

Search:
cmd
Command likho:
python --version

Output aisa aayega:


Python 3.13
Matlab Python successfully install ho gaya.

3. IDE Kya Hota Hai?


IDE = Jaha hum code likhte hain.

Simple meaning:
Coding karne ka software.

Jaise:
MS Word → typing
VS Code → coding

Python coding ke liye popular IDE:


Visual Studio Code (Best for beginners)
PyCharm (Professional)

4. Visual Studio Code Setup (Recommended)


Ye beginner ke liye best hai.

Step 1
Install:
VS Code Official Website
Install kar lo.

Step 2
VS Code open karo.

Step 3
Extension install karo.

Left side me:


Extensions pe click karo.

Search:
Python

Install:
Python Extension
(by Microsoft)

Step 4
New file banao.

File name:
[Link]

Important:
.py lagana compulsory hai.

Step 5
Code likho:
print("Hello Sonu")
Run button dabao.

Output:
Hello Sonu
Congrats 🎉
Tumhari first Python program run ho gayi.

5. PyCharm Setup
Professional IDE hai.
Thoda heavy hota hai but powerful hai.

Install:
PyCharm Official Website

Steps:
Install PyCharm
Open karo
New Project
Python interpreter select karo
New file:
[Link]

Code:
print("Hello World")
Run ▶
Output:
Hello World
VS Code vs PyCharm

Feature:---VS Code PyCharm


Easy ✅ Medium
Fast ✅ Heavy
Beginner Friendly✅ Good
Professional Use✅ ✅
Best For Beginners Big Projects

Recommendation:
Start with Visual Studio Code
Later professional level pe PyCharm use karna.

Simple Summary
Python = Programming language

Install Python

Install VS Code

Install Python extension

Create .py file

Write code

Run program

--------------------------------------
PART 2)First Python program
Print statement
Comments
Variables
Naming conventions
Keywords
Input/output basics:----

MODULE 1 Continue — Python Basics (Simple Way)


Ab hum Python ke basic topics easy language me samjhenge.

1. First Python Program

Program matlab:
Computer ko diya gaya instruction.
Sabse pehla program:
print("Hello World")
Output:
Hello World
Samjho:
print()

ka meaning:
Screen pe kuch show karna.

Example:
print("Sonu")

Output:
Sonu

Another example:
print("Welcome to Python")

Output:
Welcome to Python

2. Print Statement:--
Print statement = Screen pe output dikhana

Syntax:
print("Text")

Example 1:
print("Good Morning")

Output:
Good Morning

Example 2:
Number print:
print(100)

Output:
100

Example 3:
Multiple print:
print("Name: Sonu")
print("Age: 25")
print("City: Delhi")

Output:
Name: Sonu
Age: 25
City: Delhi
3. Comments
Comment ka matlab:
Note likhna jo computer ignore karta hai.

Use:
Explanation likhne ke liye
Reminder ke liye
Code samjhane ke liye

Single line comment::-----


# This is comment
print("Hello")

Output:
Hello
Computer:
# wali line ignore karega

Example:
# Employee Name
print("Sonu")
Multi-line Comment
"""
This is Python
learning code
"""
4. Variables (Very Important)
Variable = Data store karne ka box

Simple meaning:
Data ko memory me rakhna.

Example:
Without variable:
print("Sonu")

Variable ke saath:
name = "Sonu"
print(name)

Output:
Sonu
Samjho:
name = box
Sonu = data

Real life:
Bottle = Water
Bag = Books
Variable = Data
Variable Examples
Store name
name = "Sonu"
print(name)
Store age
age = 25

print(age)
Multiple variables
name = "Sonu"
age = 25
city = "Delhi"

print(name)
print(age)
print(city)

Output:
Sonu
25
Delhi

5. Naming Conventions (Bahut Important)


Variable ka name sahi rakhna hota hai.

Good naming
employee_name = "Sonu"
salary = 50000
phone_number = 9876543210
Easy samajh aata hai.

Bad naming
a = "Sonu"
x = 50000
abc = 20

Confusing hota hai.


Rules of Variable Name
Rule 1: Number se start nahi

❌ Wrong
1name = "Sonu"

✅ Correct
name1 = "Sonu"
Rule 2: Space nahi

❌ Wrong
my name = "Sonu"
✅ Correct
my_name = "Sonu"
Rule 3: Special character nahi

❌ Wrong
salary@ = 50000

✅ Correct
salary = 50000
Best Style

Use:
snake_case

Example:
employee_salary
employee_name
total_marks

6. Keywords
Keywords = Python ke reserved words.

Matlab:
Inka special meaning hota hai.
Inko variable name nahi bana sakte.

Example:
❌ Wrong
if = 10

Kyuki:
if
Python keyword hai.

Common keywords:
if
else
for
while
break
continue
True
False
class
try
except
return

Example:
if age > 18:
print("Adult")

Yaha:
if
keyword hai.

7. Input/Output Basics
Output
Already padha:
print()

Example:
print("Hello")

Output:
Hello
Input (Very Important)
Input = User se data lena.

Example:
name = input("Enter your name: ")
print(name)

Output:-
Enter your name:
User type kare:
Sonu

Final output:
Sonu

Example 2
Age input:
age = input("Enter age: ")

print(age)
Example 3 (Real Example)
name = input("Enter Name: ")
city = input("Enter City: ")

print(name)
print(city)

Output:
Enter Name: Sonu
Enter City: Delhi

Sonu
Delhi
Small Practice Program
name = input("Enter Name: ")
age = input("Enter Age: ")

print("Your Name Is:")


print(name)

print("Your Age Is:")


print(age)

#####n Quick Revision:---


First Program → print("Hello")

Print → Output show

Comments → Notes

Variables → Data store

Naming Rules → Correct names

Keywords → Reserved words

Input → User data lena

Output → Screen pe show

Practice Task:----
Program banao:
Input lo:
Name
Age
City
Salary

Fir print karo:


Employee Details
Name:
Age:
City:
Salary:

****************************************
# MODULE 2 — Data Types:--
Integer
Float
String
Boolean
Type conversion
Type checking
Type casting
Memory basics:--------

PART 1) Data Types:--


Integer
Float
String
Boolean:----------------------------------

MODULE 2 — Data Types (Simple Way)


Data Type Kya Hota Hai?
Data Type ka matlab:
Kis type ka data store ho raha hai.

Simple language me:


Computer ko samajhna hota hai ki:
Ye number hai?
Ye text hai?
Ye true/false hai?

Python me main 4 basic data types:


1. Integer
2. Float
3. String
4. Boolean

1. Integer (int)
Integer = Normal Number
Matlab:
Decimal (point) ke bina number.

Example:
age = 25
print(age)

Output:
25

More examples:
salary = 50000
marks = 90
year = 2026

print(salary)
print(marks)
print(year)

Output:
50000
90
2026
Integer Example

✅ Correct:
10
50
1000
-20

❌ Not integer:
10.5
20.2
Kyuki decimal hai.

2. Float (float)
Float = Decimal Number

Matlab:
Point wala number.

Example:
price = 99.99
print(price)

Output:
99.99

More examples:
height = 5.9
temperature = 36.5
percentage = 85.7

print(height)
print(temperature)
print(percentage)

Output:
5.9
36.5
85.7
Float Example

✅ Correct:
10.5
100.25
5.7
Integer vs Float
Integer Float
No decimal Decimal
10 10.5
100 100.25
Example:

age = 25
height = 5.8

print(age)
print(height)

Output:
25
5.8

3. String (str)
String = Text / Word

Matlab:
Jo bhi text ho.
Always:
" "
ya
' '
ke andar likhte hain.

Example:
name = "Sonu"
print(name)

Output:
Sonu
More examples:
city = "Delhi"
company = "HCL"
course = "Python"

print(city)
print(company)
print(course)

Output:
Delhi
HCL
Python

##### Important Rule:-----


Text ko quotes me likho.

✅ Correct:
name = "Sonu"
❌ Wrong:
name = Sonu
Error aa jayega.

Kyuki Python sochega:


Sonu variable hai
Number bhi string ho sakta hai

Example:
number = "100"
print(number)
Ye string hai, integer nahi.
Kyuki quotes me hai.

4. Boolean (bool)
Boolean = Sirf 2 values
True
False

Use hota hai:


Yes / No
On / Off
Pass / Fail

Example:
is_pass = True
print(is_pass)

Output:
True

Example 2:
is_raining = False
print(is_raining)

Output:
False

!!!Real Example

Age check:
is_adult = True
print(is_adult)

Employee active hai:


employee_active = False
print(employee_active)

!!!Type Check Karna


Hum check kar sakte hain data type.
Using:
type()

Example:
Integer
age = 25
print(type(age))

Output:
<class 'int'>
Float
salary = 50.5

print(type(salary))

Output:
<class 'float'>
String
name = "Sonu"

print(type(name))

Output:
<class 'str'>
Boolean
status = True

print(type(status))

Output:
<class 'bool'>

!!! Real Life Example Program


name = "Sonu"
age = 25
salary = 50000.50
is_employee = True

print(name)
print(age)
print(salary)
print(is_employee)

Output:
Sonu
25
50000.5
True
!!!! Easy Trick Yaad Rakho
Integer → Full Number
Float → Decimal Number
String → Text
Boolean → True/False

Example:
25 → Integer
25.5 → Float
"Sonu" → String
True → Boolean
Small Practice

!!! Create variables:


Name = Sonu
Age = 25
Salary = 50000.75
Working = True

Then print all.


Expected Code:
name = "Sonu"
age = 25
salary = 50000.75
working = True

print(name)
print(age)
print(salary)
print(working)

PART 2) Data Types:--


Type conversion
Type checking
Type casting
Memory basics:----------------------------------

1. Type Conversion Kya Hai?


Type conversion matlab:
Ek data type ko dusre data type me change karna.

Example:
String → Integer
Integer → Float
Float → String

Real life:

Jaise:
Ice → Water → Steam
Waise hi data type change hota hai.

Example 1: String to Integer

Suppose:
age = "25"

Ye string hai because quotes me hai


Ab ise integer banana hai.

age = int("25")
print(age)

Output:
25

Ab ye integer ban gaya.


Example 2: Integer to Float
number = 50

new_number = float(number)
print(new_number)

Output:
50.0
Integer → decimal ban gaya.

Example 3: Integer to String


salary = 50000

salary_text = str(salary)
print(salary_text)

Output:
50000
Ab ye text ban gaya.

2. Type Checking:---
Type checking matlab:
Check karna data ka type kya hai.

Use:
type()
Integer Check
age = 25

!!!! print(type(age))

Output:
<class 'int'>
Meaning:
Integer
Float Check
height = 5.9

!!!!print(type(height))

Output:
<class 'float'>
String Check
name = "Sonu"

!!!!print(type(name))

Output:
<class 'str'>
Boolean Check
status = True

!!!print(type(status))

Output:
<class 'bool'>
Real Example
name = "Sonu"
age = 25
salary = 50000.5
working = True

print(type(name))
print(type(age))
print(type(salary))
print(type(working))

Output:
<class 'str'>
<class 'int'>
<class 'float'>
<class 'bool'>

3. Type Casting (Very Important)


Type casting =
Forcefully data type change karna.

Python functions:
int() → Integer
float() → Float
str() → String
bool() → Boolean
int()

!!!! Convert to integer.


number = "100"

new_number = int(number)
print(new_number)

Output:
100
float()

!!!! Convert to decimal.


marks = 90
new_marks = float(marks)
print(new_marks)

Output:
90.0
str()

!!!! Convert to string.

age = 25
text_age = str(age)
print(text_age)

Output:
25
bool()

!!!! Convert to boolean.

value = 1
print(bool(value))

Output:
True

Example:
print(bool(0))

Output:
False

!!!!! Why Type Casting Important?

Sabse common beginner error:


age = input("Enter age: ")
print(age + 10)
Error aayega ❌

Kyuki:

!!! input() always string deta hai


Correct Way
age = int(input("Enter age: "))
print(age + 10)

Input:
25

Output:
35
Samjho:
Input → String

int()

Integer

Calculation possible

4. Memory Basics (Very Simple)


Memory matlab:
Data computer me temporarily kaha store hota hai.

Example:
name = "Sonu"
Python memory me save karta hai.

Simple samjho:
Variable = Box
Memory = Store Room
Data = Item

Example:
name = "Sonu"

Behind scene:
Box(name)

Store room(memory)

Sonu
Example
x = 10
y = x

print(y)
Output:
10

Meaning:
Python memory me value store karta hai.

Variable Update
salary = 50000
salary = 60000
print(salary)

Output:
60000

Old value replace ho gayi.


Python memory update kar deta hai.

!!!!! Easy Summary


Type Conversion

Data type change

Type Checking

type()

Type Casting

int()
float()
str()
bool()

Memory

Variable stores data in RAM
Golden Rule (Very Important)
input() → always string

Agar calculation karni hai:

Use:
int(input())

Example:
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
print(num1 + num2)
Input:
10
20

Output:
30

**************************************************
# MODULE 3 — Operators
Arithmetic operators
Assignment operators
Comparison operators
Logical operators
Membership operators
Identity operators
Bitwise basics:------

PART 1)Operators
Arithmetic operators
Assignment operators
Comparison operators:----

MODULE 3 — Operators (Simple Way)


Operator Kya Hota Hai?
Operator matlab:
Calculation ya comparison karne ke symbols.

Example:
+-*/=><

Real life:
Jaise calculator me:
10 + 5
Waise hi Python me operators use hote hain.

Aaj hum samjhenge:


1. Arithmetic operators
2. Assignment operators
3. Comparison operators

1. Arithmetic Operators
Arithmetic = Math calculation

Operator Meaning
+ Add
- Minus
* Multiply
/ Divide
% Modulus
// Floor division
** Power
1. Addition (+)
Use:
Number add karna

Example:
a = 10
b = 5
print(a + b)

Output:
15

2. Subtraction (-)

Example:

a = 20
b = 5

print(a - b)

Output:
15

3. Multiplication (*)

Example:
a = 10
b = 5
print(a * b)

Output:
50

4. Division (/)

Example:
a = 20
b = 5
print(a / b)

Output:
4.0

Notice:
Division always float deta hai

5. Modulus (%)
Remainder nikalta hai.

Example:
print(10 % 3)

Output:
1

Samjho:
10 ÷ 3
Remainder = 1

6. Floor Division (//)


Decimal hata deta hai.

Example:
print(10 // 3)

Output:
3

7. Power (**)
Square / power.

Example:
print(2 ** 3)

Output:
8

Meaning:
2 × 2 × 2

Arithmetic Example
a = 20
b = 5
print(a + b)
print(a - b)
print(a * b)
print(a / b)

Output:
25
15
100
4.0

2. Assignment Operators
Assignment =
Value assign/store karna.
Most common:
=

Example:
age = 25

Meaning:
25 ko age variable me store karo

**** Types of Assignment Operators


Operator Meaning
= Assign
+= Add and assign
-= Minus and assign
*= Multiply and assign
/= Divide and assign
= Operator

Example:
x = 10

print(x)

Output:

10
+= Operator

Shortcut for add.


Example:
x = 10
x += 5
print(x)

Output:
15

Samjho:
x = x + 5
-= Operator

Example:
x = 20
x -= 5

print(x)
Output:
15
*= Operator
Example:
x = 10
x *= 2
print(x)

Output:
20
/= Operator

Example:
x = 20
x /= 2

print(x)
Output:
10.0

3. Comparison Operators
Comparison =
Compare karna

Result:
True
False
Operator Meaning
== Equal
!= Not equal
> Greater than
< Less than
>= Greater equal
<= Less equal
Equal (==)

Example:
print(10 == 10)

Output:
True

Example:
print(10 == 5)

Output:
False
Not Equal (!=)

Example:
print(10 != 5)
Output:
True
Greater Than (>)

Example:
print(20 > 10)

Output:
True
Less Than (<)

Example:
print(5 < 10)

Output:
True
Greater Equal (>=)

Example:
print(10 >= 10)

Output:
True
Less Equal (<=)

Example:
print(5 <= 10)

Output:
True
Real Example

Age checking:
age = 18
print(age >= 18)

Output:
True

Meaning:
Adult
Easy Formula Yaad Rakho
Arithmetic

Calculation

Assignment

Value store/update
Comparison

Check (True/False)
Practice Program
a = 20
b = 10

print(a + b)
print(a - b)
print(a * b)
print(a > b)
print(a == b)

Expected Output:
30
10
200
True
False
--------------------------------------------------------------
PART 2) Logical operators
Membership operators
Identity operators
Bitwise basics:------

1. Logical Operators
Logical operator use hota hai:
Multiple conditions check karne ke liye

Main 3 operators:
and
or
not

1. AND Operator
Rule:
Dono condition True honi chahiye.

Example:
print(10 > 5 and 20 > 10)

Output:
True

Kyuki:
10 > 5 = True
20 > 10 = True
Dono true.

Example 2:
print(10 > 5 and 20 < 10)

Output:
False

Kyuki:
True and False
= False
Easy Rule
True + True = True
Baaki sab = False

2. OR Operator
Rule:
Ek bhi condition True ho to answer True.

Example:
print(10 > 5 or 20 < 10)

Output:
True

Kyuki:
True or False
= True

Example 2:
print(2 > 5 or 10 < 2)

Output:
False
Kyuki dono false.
Easy Rule
Ek bhi True
= True

3. NOT Operator
Meaning:
Result ulta kar deta hai.

Example:
print(not True)

Output:
False

Example:
print(not False)

Output:
True
Real Example
is_logged_in = True
print(not is_logged_in)

Output:
False

2. Membership Operators
Membership operator check karta hai:
Koi item list/string ke andar hai ya nahi.

Operators:
in
not in
in Operator

Example:
fruits = ["apple", "banana", "mango"]
print("apple" in fruits)

Output:
True
Kyuki apple list me hai.

Example 2:
print("grapes" in fruits)

Output:
False
not in Operator

Example:
fruits = ["apple", "banana"]
print("mango" not in fruits)

Output:
True
String Example
text = "python"
print("p" in text)

Output:
True

3. Identity Operators
Identity operator check karta hai:
Dono same object hain ya nahi.

Operators:
is
is not

Simple language:
!!!Same ya different?
is Operator

Example:
x = 10
y = 10
print(x is y)

Output:
True

Example 2:
x = [1,2]
y = [1,2]
print(x is y)

Output:
False
Kyuki memory alag hai.
is not Operator

Example:
x = [1,2]
y = [1,2]

print(x is not y)
Output:
True
Simple Difference
== → value compare

is → memory compare

Example:
x = [1,2]
y = [1,2]
print(x == y)

Output:
True
Kyuki values same.

But:
print(x is y)

Output:
False
Memory alag.

4. Bitwise Basics
Ye advanced hai but basics samjho.
Computer internally:
0 and 1
(binary)
pe kaam karta hai.

Bitwise operator:
&
|
^
Abhi basics only.

Bitwise AND (&)


Example:
print(5 & 3)

Output:
1
Bitwise OR (|)

Example:
print(5 | 3)

Output:
7
Kya yaad rakhna hai?
Abhi sirf:
Bitwise = Binary operation
(0 and 1 pe kaam karta hai)
Later advanced me deeply karenge.

!!!!!Interview/basic ke liye enough.

!!!!!Easy Summary:---
Logical Operators

and
or
not

Membership Operators

in
not in

Identity Operators

is
is not

Bitwise

binary basics
Real Life Example

Employee login:
username = "sonu"
password = "123"

print(
username == "sonu"
and password == "123"
)

Output:
True
Ye logical operator ka real use hai.

!!! Practice Task:---


Try this:
numbers = [10,20,30]
print(10 in numbers)
print(50 not in numbers)

print(10 > 5 and 5 > 2)


print(10 < 5 or 5 > 2)

Expected Output:
True
True
True
True
***********************************************************************************
***************
# MODULE 4 — Strings (Very Important)
String basics
Indexing
Slicing
String methods
upper()
lower()
replace()
split()
strip()
f-string formatting
String concatenation
Escape sequence
String validations---

---------------PART 1)Strings (Very Important)


String basics
Indexing
Slicing
String methods
upper()
lower()
replace():---------

MODULE 4 — Strings (Very Important)


1.) String Kya Hoti Hai?
String = Text / Words
Simple meaning:
Jo bhi text ho wo string hota hai.

Example:
name = "Sonu"
city = "Delhi"
course = "Python"
Ye sab string hain.

Kyuki:
Quotes (" ") ke andar hain
String Basics

String ko:
" "
ya
' '
me likhte hain.

Example:
name = "Sonu"
print(name)

Output:
Sonu
Number bhi String ho sakta hai

Example:
number = "100"
print(number)
Ye string hai.

Kyuki:
Quotes me likha hua hai
2.) Indexing (Very Important)
Indexing matlab:
Character position number

Example:
text = "PYTHON"

Position:
P Y T H O N
0 1 2 3 4 5
First letter access
text = "PYTHON"

print(text[0])

Output:
P

Second letter
print(text[1])
Output:
Y

Last letter
print(text[5])

Output:
N

Negative Indexing
Last se access karna.

Example:
P Y T H O N
-6 -5 -4 -3 -2 -1

Example:
text = "PYTHON"
print(text[-1])

Output:
N
Second last
print(text[-2])

Output:
O

3.) Slicing
Slicing =
String ka kuch part nikalna

Syntax:
string[start:end]

Example:
text = "PYTHON"
print(text[0:3])

Output:
PYT

Samjho:
0 include hota hai
3 include nahi hota

Example 2
print(text[2:5])

Output:
THO

Start to end
print(text[:4])

Output:
PYTH

End se
print(text[2:])
Output:
THON

Full string
print(text[:])

Output:
PYTHON

4.) String Methods


Methods =
Ready-made functions
Python me already bane hote hain.

upper()
Use:
Small letters → CAPITAL

Example:
name = "sonu"
print([Link]())

Output:
SONU

Example 2:
city = "delhi"

print([Link]())
Output:
DELHI
lower()

Use:
CAPITAL → small letters

Example:
name = "SONU"
print([Link]())

Output:
sonu

Example:
course = "PYTHON"
print([Link]())

Output:
python
replace()

Use:
Word replace/change karna

Syntax:
replace(old, new)

Example:
text = "I love Java"
print([Link]("Java", "Python"))

Output:
I love Python

Example 2:
name = "Sonu"
print([Link]("Sonu", "Rahul"))

Output:
Rahul

!!!Real Example Program


name = "sonu kumar"
print([Link]())
print([Link]())
print([Link](
"sonu",
"rahul"
))

Output:
SONU KUMAR
sonu kumar
rahul kumar
Easy Summary
String

Text Data

Indexing

Position Number

Slicing

Part of string

Methods

upper() → CAPITAL
lower() → small

replace() → word change


Practice Task

Try this:
course = "python programming"

Do:
Convert to uppercase
Convert to lowercase
Replace python with SQL
Print first 6 letters
Print last letter

Expected idea:
PYTHON PROGRAMMING
python programming
SQL programming
python
g

PART 2)Strings (Very Important)


split()
strip()
f-string formatting
String concatenation
Escape sequence
String validations:---------

1. split()
Use:
String ko pieces me todna

Example:
text = "apple banana mango"

!! print([Link]())
Output:
['apple', 'banana', 'mango']
Samjho:
String

List me convert
split with comma

Example:
data = "apple,banana,mango"
print([Link](","))

Output:
['apple', 'banana', 'mango']
Real Example

Employee names:
employees = "Sonu Rahul Amit"
print([Link]())

Output:
['Sonu', 'Rahul', 'Amit']

2. strip()
Use:
Extra spaces remove karna

Example:
name = " Sonu "
print([Link]())
Output:
Sonu
Samjho

Before:
" Sonu "

After:
"Sonu"

!!!! Real Example:---


User input clean karna:
name = " Sonu Kumar "
print([Link]())

Output:
Sonu Kumar

3. f-string Formatting (Very Important)


Use:
Variable ko sentence me add karna

Old way:
name = "Sonu"
print("My name is " + name)

Easy modern way:


name = "Sonu"
print(f"My name is {name}")

Output:
My name is Sonu
Multiple variables
name = "Sonu"
age = 25
print(f"My name is {name} and age is {age}")

Output:
My name is Sonu and age is 25
Real Example
company = "HCL"
salary = 50000

print(
f"I work in {company} and salary is {salary}"
)

Output:
I work in HCL and salary is 50000
4. String Concatenation
Concatenation =
Do strings ko jodna (combine)

Using:
+

Example:
first_name = "Sonu"
last_name = "Kumar"

full_name = first_name + last_name


print(full_name)

Output:
SonuKumar

Space nahi aaya.

Correct way
full_name = first_name + " " + last_name
print(full_name)

Output:
Sonu Kumar
Example
city = "New"
place = "Delhi"
print(city + " " + place)

Output:
New Delhi

5. Escape Sequence
Escape sequence =
Special formatting symbols

Most common:
\n
\t
\"
\n (New Line)

Example:
print("Sonu\nRahul")

Output:
Sonu
Rahul
\t (Tab Space)

Example:
print("Name:\tSonu")

Output:
Name: Sonu
Quotes print karna

Example:
print("My name is \"Sonu\"")

Output:
My name is "Sonu"
6. String Validations

Validation =
Check karna string kaisi hai

Useful methods:
isdigit()
isalpha()
isalnum()
isdigit()

Check:
Number hai ya nahi

Example:
num = "1234"
print([Link]())

Output:
True

Example:
num = "12a"
print([Link]())

Output:
False
isalpha()

Check:
Sirf letters hain?

Example:
name = "Sonu"
print([Link]())
Output:
True

Example:
name = "Sonu123"
print([Link]())

Output:
False
isalnum()

Check:

Letter + number allowed

Example:
text = "Sonu123"
print([Link]())

Output:
True

Real Example Program


name = input("Enter name: ")
print([Link]())
print([Link]())

print(
f"Welcome {name}"
)

Input:
Sonu

Output:
SONU
Welcome Sonu

!!!! Easy Summary


split()

String todna

strip()

Extra space remove

f-string

Variable sentence me add
Concatenation

String jodna

Escape sequence

Formatting

Validation

Check string type
Practice Task

!!! Create:
name = " sonu kumar "

!!! Do:
Remove spaces
Uppercase
Split name
Print using f-string
Check only letters or not

!!!! Expected idea:


sonu kumar
SONU KUMAR
['sonu', 'kumar']
Hello sonu kumar
True/False
-**************************************************
MODULE 5 — List (Very Important)
List basics
Indexing
Negative indexing
Slicing
append()
insert()
remove()
pop()
sort()
reverse()
Nested list
Looping list
List functions
List copying:------------

PART-1)List (Very Important)


List basics
Indexing
Negative indexing
Slicing
append()
insert()
remove()----------

MODULE 5 — LIST (Very Important) (Simple Way)


List Kya Hoti Hai?
List = Multiple values ek saath store karna

Simple meaning:
Ek box jisme hum bahut saari values rakh sakte hain.

Example:
fruits = ["apple", "banana", "mango"]
print(fruits)

Output:
['apple', 'banana', 'mango']

1. List Basics
List ko hum [] me likhte hain.

Example:
numbers = [10, 20, 30, 40]
print(numbers)

Output:
[10, 20, 30, 40]

Important points:
✔ List me numbers, text, mix sab ho sakta hai
✔ Ordered hota hai
✔ Change (modify) kar sakte hain

Example:
data = ["Sonu", 25, True, 50000
print(data)

2. Indexing (Very Important)


Indexing = position number

Example:
fruits = ["apple", "banana", "mango"]

Index:
apple → 0
banana → 1
mango → 2
Access item
print(fruits[0])

Output:
apple
print(fruits[2])

Output:
mango

3. Negative Indexing
Negative indexing = last se start

Example:
fruits = ["apple", "banana", "mango"]
apple → -3
banana → -2
mango → -1
Example
print(fruits[-1])

Output:
mango
print(fruits[-2])

Output:
banana

4. Slicing
Slicing = list ka part nikalna

Syntax:
list[start:end]

Example:
numbers = [10, 20, 30, 40, 50]
print(numbers[1:4])

Output:
[20, 30, 40]
Easy rules:
start → include hota hai
end → include nahi hota
More examples
print(numbers[:3])

Output:
[10, 20, 30]
print(numbers[2:])

Output:
[30, 40, 50]
5. append()

Use:
List ke end me item add karna

Example:
fruits = ["apple", "banana"]
[Link]("mango")
print(fruits)

Output:
['apple', 'banana', 'mango']
Real life:
Student list me new student add
6. insert()

Use:
Specific position par item add karna

Syntax:
[Link](index, value)
Example:
fruits = ["apple", "mango"]
[Link](1, "banana")
print(fruits)

Output:
['apple', 'banana', 'mango']
Samjho:
0 → apple
1 → banana (inserted)
2 → mango
7. remove()

Use:
Value ko delete karna

Example:
fruits = ["apple", "banana", "mango"]
[Link]("banana")
print(fruits)

Output:
['apple', 'mango']
Important Rule:
remove() → value delete karta hai

Example:
numbers = [10, 20, 30]
[Link](20)
print(numbers)

Output:
[10, 30]

Real Example (All combined)


fruits = ["apple", "banana", "mango"]

print(fruits[0])
print(fruits[-1])

[Link]("grapes")
[Link](1, "orange")
[Link]("banana")

print(fruits)

Output:
apple
mango
['apple', 'orange', 'mango', 'grapes']
Easy Summary
List

Multiple values store

Indexing

Position (0,1,2)

Negative indexing

Last se start (-1,-2)

Slicing

Part of list

append()

End me add

insert()

Specific position

remove()

Value delete
Practice Task
numbers = [10, 20, 30, 40, 50]

Do:
Print first element
Print last element
Add 60
Insert 25 at position 2
Remove 30
Print final list

Expected idea:
[10, 20, 25, 40, 50, 60]

-----------------------------------------
# PART-2)pop()
sort()
reverse()
Nested list
Looping list
List functions
List copying:------------

MODULE 5 Continue — LIST (Advanced Basics, Simple Way)


Ab hum List ke next important concepts samjhenge:

1. pop()
2. sort()
3. reverse()
4. Nested list
5. Looping list
6. List functions
7. List copying

1. pop()
pop() kya karta hai?
List se item remove karta hai (index ke basis par)

Example:
fruits = ["apple", "banana", "mango"]
[Link]()
print(fruits)

Output:
['apple', 'banana']
👉 Last item remove ho gaya (default)

Index ke saath pop()


fruits = ["apple", "banana", "mango"]
[Link](1)
print(fruits)

Output:
['apple', 'mango']

👉 banana remove ho gaya


Simple rule:
pop() → last item remove
pop(index) → specific item remove

2. sort()
sort() kya karta hai?
List ko ascending order me arrange karta hai

Example:
numbers = [50, 10, 30, 20]
[Link]()
print(numbers)

Output:
[10, 20, 30, 50]

!!Reverse sort
[Link](reverse=True)
print(numbers)

Output:
[50, 30, 20, 10]
Important:
sort() → small to big
sort(reverse=True) → big to small

3. reverse()
reverse() kya karta hai?
List ka order ulta kar deta hai

Example:
fruits = ["apple", "banana", "mango"]
[Link]()
print(fruits)

Output:
['mango', 'banana', 'apple']

Important:
reverse() ≠ sort()
👉 reverse = ulta order
👉 sort = proper sorting
4. Nested List
Nested list kya hoti hai?
List ke andar list

Example:
students = [
["Sonu", 25],
["Rahul", 22],
["Amit", 24]
]
print(students)

Output:
[['Sonu', 25], ['Rahul', 22], ['Amit', 24]]
Access nested list
print(students[0])

Output:
['Sonu', 25]
Specific value
print(students[0][0])

Output:
Sonu
👉 first list → Sonu
👉 second index → name

5. Looping List
For loop se list print karna
fruits = ["apple", "banana", "mango"]

for item in fruits:


print(item)

Output:
apple
banana
mango
With index (enumerate)
for i, item in enumerate(fruits):
print(i, item)

Output:
0 apple
1 banana
2 mango

Simple meaning:
loop → list ke har item ko print karta hai
6. List Functions (Important)

len()
print(len(fruits))
👉 items count

min()
numbers = [10, 20, 5]
print(min(numbers))

Output:
5

max()
print(max(numbers))

Output:
20

sum()
print(sum(numbers))

Output:
35

Summary:
len() → count
min() → smallest
max() → largest
sum() → total

7. List Copying (Very Important)


Wrong way ❌
list1 = [1, 2, 3]
list2 = list1

[Link](4)
print(list1)

Output:
[1, 2, 3, 4]
👉 dono same ho gaye 😨

Correct way ✅
copy() method
list1 = [1, 2, 3]

list2 = [Link]()
[Link](4)
print(list1)
print(list2)

Output:
[1, 2, 3]
[1, 2, 3, 4]

Another method
list2 = list(list1)
Simple meaning:
copy() → new list banata hai

REAL EXAMPLE (All concepts combined)


numbers = [50, 10, 30, 20]

[Link]()
print(numbers)

[Link]()
print(numbers)

[Link]()
print(numbers)

[Link](100)
print(numbers)

!!! EASY SUMMARY


pop() → remove item
sort() → arrange order
reverse() → ulta order
nested list → list inside list
loop → list print
functions → len, min, max, sum
copy → duplicate list

!!! PRACTICE TASK


marks = [45, 80, 30, 90, 60]

Do:
sort list
reverse list
find max
remove 30
copy list
print with loop

************************************************
MODULE 6 — Tuple
Tuple basics
Immutable concept
Indexing
Slicing
Packing/unpacking
Tuple methods-----------------

MODULE 6 — Tuple (Simple Way)


Tuple Kya Hota Hai?
Tuple = List jaisa hota hai but change nahi kar sakte

Simple meaning::---
Fixed data store karne ke liye use hota hai.

Example:
employee = ("Sonu", 25, "Delhi")

print(employee)

Output:
('Sonu', 25, 'Delhi')
Tuple vs List
List
fruits = ["apple", "banana"]

✔ Change kar sakte ho

Tuple
fruits = ("apple", "banana")
❌ Change nahi kar sakte

!!! Tuple ka symbol:----


List:
[]

Tuple:
()

1. Tuple Basics:---
Tuple multiple values store karta hai.

Example:
data = ("Sonu", 25, True, 50000)

print(data)

Output:
('Sonu', 25, True, 50000)

!! Different data types allowed


employee = (
"Sonu",
25,
50000.50,
True
)
print(employee)

!!! Single item tuple


Important rule:

t = (10,)

Comma compulsory hai.

❌ Wrong
t = (10)
Ye tuple nahi integer ban jayega.

2. Immutable Concept (Very Important)


Immutable matlab:
Change nahi kar sakte

Example:
fruits = (
"apple",
"banana",
"mango"
)
fruits[0] = "orange"

!!! Output:
Error
Kyuki tuple immutable hai.

!! List me possible tha:---


fruits = [
"apple",
"banana"
]

fruits[0] = "orange"

print(fruits)

Output:

['orange', 'banana']

!!! Easy Trick:---


List = Editable

Tuple = Fixed / Non-editable

3. Indexing:----
Tuple me bhi indexing hoti hai.

Example:
fruits = (
"apple",
"banana",
"mango"
)

Index:
apple → 0
banana → 1
mango → 2
First item
print(fruits[0])

Output:
apple
Second item
print(fruits[1])

Output:
banana
Negative Indexing

Last se start.
apple → -3
banana → -2
mango → -1

Example:

print(fruits[-1])

Output:

mango

4. Slicing:---
Tuple ka part nikalna.

Syntax:
tuple[start:end]

Example:
numbers = (
10, 20, 30, 40, 50
)
print(numbers[1:4])

Output:
(20, 30, 40)

!! Example
print(numbers[:3])

Output:
(10, 20, 30)

!! End se
print(numbers[2:])

Output:
(30, 40, 50)

5. Packing / Unpacking:-
Packing
Multiple values ek tuple me rakhna.

Example:
employee = (
"Sonu",
25,
"Delhi"
)
Ye packing hai.

!!! Unpacking:---
Tuple values ko alag variables me rakhna.

Example:
employee = (
"Sonu",
25,
"Delhi"
)
name, age, city = employee

print(name)
print(age)
print(city)

Output:
Sonu
25
Delhi

!! Samjho:
Tuple

Different variables

6. Tuple Methods:---
Tuple me sirf 2 methods hote hain.

count():--
Count karta hai item kitni baar aaya.

Example:
numbers = (
10, 20, 10, 30
)
print([Link](10))

Output:
2

index()
Position batata hai.

Example:
numbers = (
10, 20, 30
)
print([Link](20))

Output:
1

!! Real Example
employee = (
"Sonu",
25,
"Delhi"
)

print(employee[0])
name, age, city = employee

print(name)
print([Link]("Sonu"))

Output:
Sonu
Sonu
1

!! Easy Summary
Tuple

Multiple values

()

Tuple symbol

Immutable

Cannot change

Indexing

Position

Slicing

Part of tuple

Packing

Store values

Unpacking

Separate variables

Methods

count()
index()
Practice Task
student = (
"Rahul",
22,
"Noida",
95
)

!! Do:
Print first item
Print last item
Slice first 2 values
Unpack tuple
Find index of Noida
Count 95
!! Expected idea:
Rahul
95
('Rahul', 22)
Noida index
95 count

***********************************************************************************
*************
# MODULE 7 — Set
Set basics
Unique values
add()
remove()
union()
intersection()
difference()
frozenset basics:-----------------------------------

MODULE 7 — Set (Simple Way)


Set Kya Hota Hai?
Set = Unique values store karta hai

Simple meaning:
Duplicate values automatically remove ho jati hain.

Example:
numbers = {10, 20, 30, 10, 20}
print(numbers)

Output:
{10, 20, 30}

Dekho:
10 aur 20 duplicate the
Automatically remove ho gaye

!!!Set Basics:---

Set ko:
{}
me likhte hain.

Example:---
fruits = {"apple", "banana", "mango"}
print(fruits)

Output:
{'apple', 'banana', 'mango'}
Important Rules

1. Duplicate allow nahi

Example:
data = {1, 2, 3, 1, 2}
print(data)

Output:
{1, 2, 3}

2. Indexing nahi hoti

❌ Wrong:

numbers = {10, 20, 30}


print(numbers[0])
Error aayega.

Kyuki:
Set unordered hota hai

3. Change kar sakte hain


Set mutable hota hai.

Matlab:
Add/remove kar sakte ho

1. Unique Values
Set ka biggest use:
Duplicate remove karna

Example:
employees = {
"Sonu",
"Rahul",
"Sonu",
"Amit"
}
print(employees)

Output:
{'Sonu', 'Rahul', 'Amit'}
Real Life Example

Duplicate mobile numbers remove karna.

numbers = {
987,
123,
987,
555
}
print(numbers)

Output:
{987, 123, 555}

2. add():--------------
Use:
New value add karna

Example:
fruits = {
"apple",
"banana"
}
[Link]("mango")
print(fruits)

Output:
{'apple', 'banana', 'mango'}

Duplicate add karoge?


[Link]("apple")

Nothing happens.

Kyuki duplicate allowed nahi.

3. remove():---------------
Use:
Item delete karna

Example:
fruits = {
"apple",
"banana",
"mango"
}
[Link]("banana")
print(fruits)

Output:
{'apple', 'mango'}

Important:-----------
Agar value exist nahi karti:
[Link]("grapes")
Error aayega.

4. union():------------
Use:
2 set ko combine karna

Example:
set1 = {1, 2, 3}
set2 = {3, 4, 5}
print([Link](set2))

Output:
{1, 2, 3, 4, 5}
Duplicate remove ho gaya.

Easy meaning::----
Union

Sabko jodo

5. intersection():----
Use:
Common values nikalna

Example:
set1 = {1, 2, 3}
set2 = {2, 3, 4}
print([Link](set2))

Output:
{2, 3}

Kyuki:
Dono me common values
Easy meaning:
Intersection

Same/common values

6. difference():------
Use:
Jo dusre set me nahi hai

Example:
set1 = {1, 2, 3}
set2 = {2, 3, 4}
print([Link](set2))
Output:
{1}

Kyuki:
1 sirf set1 me hai
Example 2
print([Link](set1))

Output:

{4}
Easy meaning:
Difference

Unique item

7. frozenset Basics:---------------

frozenset =
Fixed set (change nahi kar sakte)

Simple meaning:
Tuple of Set

Example:
numbers = frozenset(
[10, 20, 30]
)
print(numbers)

Output:
frozenset({10,20,30})

!!! Change nahi kar sakte:---

❌ Wrong:
[Link](40)
Error aayega.

Kyuki:
frozenset immutable hota hai

!!!!!! Set vs List vs Tuple:---


Type Duplicate Change
List ✅ ✅
Tuple ✅ ❌
Set ❌ ✅
!!!!! Real Example:-----
employees = {
"Sonu",
"Rahul",
"Amit"
}

[Link]("Ravi")
[Link]("Rahul")
print(employees)

Output:
{'Sonu', 'Amit', 'Ravi'}

!!! Easy Summary:---


Set

Unique values

add()

Add item

remove()

Delete item

union()

Combine all

intersection()

Common values

difference()

Different value

frozenset

Fixed set
Practice Task
A = {10,20,30,40}
B = {30,40,50,60}

!!! Do:
Add 70 in A
Remove 20 from A
Find union
Find intersection
Find difference
Create frozenset

!!! Expected idea:


Union → all numbers
Intersection → 30,40
Difference → unique values

***********************************************************************************
*************
***********************************************************************************
*************
# MODULE 8 — Dictionary (Most Important)
Dictionary basics
Key-value pair
Accessing data
add/update/delete
keys()
values()
items()
Nested dictionary
Loop dictionary
Dictionary methods:----------------------

----------------------------------------------------------------------------------
PART:1=== Dictionary (Most Important)
Dictionary basics
Key-value pair
Accessing data
add/update/delete
keys():------------------

MODULE 8 — Dictionary (Most Important) (Simple Way)


Dictionary Kya Hoti Hai?
Dictionary =
Data ko key-value pair me store karta hai.

Simple meaning:
Key → Value

Real life example:


Name → Sonu
Age → 25
City → Delhi

Ye dictionary jaisa hai.


Dictionary Basics
Dictionary ko:
{}
me likhte hain.

Example:
student = {
"name": "Sonu",
"age": 25,
"city": "Delhi"
}
print(student)

Output:
{
'name': 'Sonu',
'age': 25,
'city': 'Delhi'
}

!!! Important Rule

Dictionary me:
Key : Value
format hota hai.

Example:
"name" : "Sonu"

Yaha:
Key = name
Value = Sonu

1. Key-Value Pair (Very Important)


Example:
employee = {
"name": "Sonu",
"salary": 50000,
"company": "HCL"
}

Samjho:
name → Sonu
salary → 50000
company → HCL
Different data types allowed
data = {
"name": "Sonu",
"age": 25,
"salary": 50000.50,
"working": True
}
print(data)

2. Accessing Data
Data access karne ke liye:
dictionary[key]
Use karte hain.

Example
student = {
"name": "Sonu",
"age": 25,
"city": "Delhi"
}
print(student["name"])

Output:
Sonu
Age access
print(student["age"])

Output:
25
City access
print(student["city"])

Output:
Delhi
get() Method (Safe way)

Example:
print([Link]("name"))

Output:
Sonu

!!!! Why get() important?


Agar key exist nahi karti:

❌ Error method:
print(student["phone"])
Error aayega.

✅ Safe way:
print([Link]("phone"))

Output:
None
3. Add / Update / Delete
Add Data
New key add karna.

Example:
student = {
"name": "Sonu",
"age": 25
}
student["city"] = "Delhi"
print(student)

Output:
{
'name': 'Sonu',
'age': 25,
'city': 'Delhi'
}

!!! Update Data:---------


Existing value change karna.

Example:
student = {
"name": "Sonu",
"age": 25
}
student["age"] = 26
print(student)

Output:
26
Delete Data
del keyword

Example:
student = {
"name": "Sonu",
"age": 25
}
del student["age"]

print(student)

Output:
{'name': 'Sonu'}
pop()

Example:
student = {
"name": "Sonu",
"age": 25
}

[Link]("age")
print(student)

Output:
{'name': 'Sonu'}

4. keys()
Use:
Sirf keys nikalna

Example:
student = {
"name": "Sonu",
"age": 25,
"city": "Delhi"
}
print([Link]())

Output:
dict_keys(
['name', 'age', 'city']
)
Convert to list
print(list([Link]()))

Output:
['name', 'age', 'city']
Real Example
employee = {
"name": "Sonu",
"company": "HCL",
"salary": 50000
}

print(employee["name"])
employee["city"] = "Noida"
employee["salary"] = 60000

print([Link]())
print(employee)

Output:
Sonu
dict_keys(
['name','company',
'salary','city']
)

{
'name':'Sonu',
'company':'HCL',
'salary':60000,
'city':'Noida'
}

!!!!! Easy Summary:----------


Dictionary

Key : Value

Access

dict[key]

get()

Safe access

Add

new key

Update

change value

Delete

del / pop()

keys()

show all keys

!!!! Practice Task:-----------


employee = {
"name": "Rahul",
"salary": 40000,
"city": "Noida"
}

!!!!! Do:---------
Print name
Add company = HCL
Update salary = 50000
Delete city
Print all keys

!!! Expected idea:


Rahul
name, salary, company:--

-------------------------------------------------
PART:-2
values()
items()
Nested dictionary
Loop dictionary
Dictionary methods:----------------------

1. values()
values() kya karta hai?
Dictionary ki sirf values dikhata hai

Example:
student = {
"name": "Sonu",
"age": 25,
"city": "Delhi"
}
print([Link]())

Output:
dict_values(
['Sonu', 25, 'Delhi']
)
List me convert karna
print(list([Link]()))

Output:
['Sonu', 25, 'Delhi']
Easy meaning:
values()

Sirf values show

2. items():---
items() kya karta hai?
Key + Value dono show karta hai

Example:
student = {
"name": "Sonu",
"age": 25
}
print([Link]())
Output:
dict_items(
[
('name', 'Sonu'),
('age', 25)
]
)
Samjho
name → Sonu
age → 25
Dono ek saath milte hain.

List me convert:-
print(list([Link]()))

Output:
[
('name', 'Sonu'),
('age', 25)
]
Easy meaning
items()

Key + value together

3. Nested Dictionary:-----------------
Nested dictionary kya hoti hai?
Dictionary ke andar dictionary

Example:
employees = {
"emp1": {
"name": "Sonu",
"salary": 50000
},

"emp2": {
"name": "Rahul",
"salary": 60000
}
}

print(employees)
Access nested data
print(
employees["emp1"]["name"]
)

Output:
Sonu
Salary access
print(
employees["emp2"]["salary"]
)

Output:
60000
Easy understanding
Big dictionary

Small dictionaries inside

4. Loop Dictionary:---
Only keys

Example:
student = {
"name": "Sonu",
"age": 25,
"city": "Delhi"
}
for key in student:
print(key)

Output:
name
age
city
Only values

Example:
for value in [Link]():
print(value)

Output:
Sonu
25
Delhi
Key + Value together

Using:
items()

Example:
for key, value in [Link]():
print(key, value)

Output:
name Sonu
age 25
city Delhi
Easy meaning:
Loop

Ek ek item print

5. Dictionary Methods:--------------
len()
Count keys.

Example:
print(len(student))

Output:
3 clear()

Sab delete.

Example:
[Link]()
print(student)

Output:
{}
copy()

Copy dictionary.

Example:
student1 = {
"name": "Sonu"
}
student2 = [Link]()
print(student2)

Output:
{'name': 'Sonu'}
update()
New data add/update.

Example:
student = {
"name": "Sonu"
}

[Link]({
"age": 25
})
print(student)
Output:
{
'name': 'Sonu',
'age': 25
}
Real Example Program
employee = {
"name": "Sonu",
"salary": 50000,
"city": "Noida"
}

print([Link]())
print([Link]())
for key, value in [Link]():
print(key, value)

Output:
dict_values(
['Sonu',50000,'Noida']
)

dict_items(
[
('name','Sonu'),
('salary',50000),
('city','Noida')
]
)

name Sonu
salary 50000
city Noida

!!!!!Easy Summary:---
values()

Only values

items()

Key + value

Nested dictionary

Dictionary inside dictionary

Loop

Print data

!!! Methods:--

len()
clear()
copy()
update()
Practice Task
student = {
"name": "Rahul",
"age": 22,
"city": "Noida"
}

!!!!Do:--
Print values
Print items
Loop all keys + values
Add marks = 95 using update()
Copy dictionary
Find total keys

!!!!Expected idea:--
Rahul
22
Noida
name Rahul
age 22
city Noida

***********************************************************************************
*************
***********************************************************************************
*************
# MODULE 9 — Conditional Statements
if
if else
elif
Nested if
Multiple conditions
Logical conditions:---

MODULE 9 — Conditional Statements (Simple Way)


Conditional Statement Kya Hota Hai?
Conditional statement =
Condition check karna

!!!Simple meaning:-
Agar ye true hai
to ye kaam karo
warna dusra kaam karo

Real life:
Agar age 18+ hai
→ vote kar sakta hai

warna
→ vote nahi kar sakta

Python me:
if
if else
elif
nested if
multiple conditions
logical conditions

1. if Statement:-----------------------
if kya hota hai?
Agar condition True hai to code chalega.

Syntax:
if condition:
code

Example:
age = 20

if age >= 18:


print("Adult")

Output:
Adult

Kyuki:
20 >= 18
True
False case
age = 15

if age >= 18:


print("Adult")

Output:
Nothing print
Kyuki condition false.

2. if else
if else kya hota hai?
True hua to if chalega
False hua to else chalega

Syntax:
if condition:
code

else:
code

Example:
age = 16

if age >= 18:


print("Adult")
else:
print("Minor")

Output:
Minor
Example 2
number = 10

if number > 0:
print("Positive")
else:
print("Negative")

Output:
Positive

3. elif:-------------
elif kya hota hai?
Multiple conditions check karna

!!! Meaning:
Agar ye nahi
to ye check karo

!!! Syntax:
if condition:
code

elif condition:
code

else:
code
!!! Example:--

Marks grading:
marks = 75

if marks >= 90:


print("A Grade")

elif marks >= 70:


print("B Grade")

else:
print("C Grade")

Output:
B Grade
Real Life Example
temperature = 35

if temperature > 40:


print("Very Hot")

elif temperature > 25:


print("Normal")

else:
print("Cold")

Output:
Normal

4. Nested if
Nested if kya hota hai?
if ke andar if

Example:
age = 20
citizen = True
if age >= 18:

if citizen:
print("Can Vote")

Output:
Can Vote
Samjho

First check:
age >= 18
True hua
Phir second check:
citizen = True
Then output.

!!!! Another Example:--------------


salary = 60000

if salary > 50000:

if salary > 100000:


print("High Salary")

else:
print("Good Salary")

Output:
Good Salary

5. Multiple Conditions:------------
Ek se zyada condition.

!!! Use:
and
or
AND condition

Rule:
Dono True honi chahiye

Example:
age = 20
citizen = True

if age >= 18 and citizen:


print("Eligible")

Output:
Eligible
OR condition

!!!Rule:
Ek bhi True ho

Example:
day = "Sunday"
if day == "Sunday" or day == "Saturday":
print("Holiday")

Output:
Holiday

6. Logical Conditions:---------------------
Logical operators:
and
or
not
and
print(10 > 5 and 20 > 10)

Output:
True
or
print(10 > 50 or 20 > 10)

Output:
True
Ek true tha.

not
Opposite kar deta hai.

Example:
is_login = True
print(not is_login)

Output:
False

!!!! Real Example Program:---


age = int(input("Enter age: "))

if age >= 18:


print("Eligible for vote")

else:
print("Not eligible")

Input:
20

Output:
Eligible for vote

!!!! Easy Summary:--


if

Only true

if else

True / False

elif

Multiple conditions

Nested if

if inside if

and

Both true

or

One true

not

Opposite

!!!!!!Practice Task:--

!!! Create program:


Marks grading

!!! Rules:
90+ → A
70+ → B
50+ → C
else → Fail

!!! Use:
if
elif
else

======================================================================
# MODULE 10 — Loops (Super Important)
for loop
while loop
nested loop
break
continue
pass
range()
enumerate()--------------------------------------
MODULE 10 — Loops (Super Important) (Simple Way)
Loop Kya Hota Hai?
Loop =
Ek kaam ko baar-baar repeat karna
!!!!!Real life::--------------------

Agar tumhe:

Hello
10 baar print karna hai
To 10 baar code nahi likhenge ❌
Loop use karenge ✅

1. for loop
for loop kya hota hai?
Jab number of repeat pata ho.

Syntax:
for variable in sequence:
code

Example:
for i in range(5):
print("Hello")

Output:
Hello
Hello
Hello
Hello
Hello

Number print
for i in range(5):
print(i)

Output:
0
1
2
3
4
List loop
fruits = [
"apple",
"banana",
"mango"
]
for item in fruits:
print(item)

Output:
apple
banana
mango

2. while loop
while loop kya hota hai?
Jab tak condition True ho

Syntax:
while condition:
code

Example:
i = 1

while i <= 5:
print(i)

i += 1

Output:
1
2
3
4
5
Samjho:
Condition true?

Yes → run

Again check

⚠ Important:
i += 1
zaroor lagana
warna infinite loop ho jayega 😨

3. Nested Loop
Nested loop kya hota hai?
Loop ke andar loop

Example:
for i in range(3):
for j in range(2):
print(i, j)
Output:
0 0
0 1
1 0
1 1
2 0
2 1

Real understanding:
Outer loop:
3 times

Inner loop:
Har baar 2 times

4. break:--------------------------
break kya karta hai?
Loop ko turant stop kar deta hai

Example:
for i in range(10):
if i == 5:
break

print(i)

Output:
0
1
2
3
4
Samjho

Jaise hi:
i = 5
Loop stop.

5. continue:---------
continue kya karta hai?
Ek step skip kar deta hai

Example:
for i in range(5):

if i == 2:
continue

print(i)
Output:
0
1
3
4
Samjho
2 skip ho gaya

6. pass:------------
pass kya hota hai?
Empty code ke liye placeholder

Example:
for i in range(5):
if i == 2:
pass
print(i)

Output:
0
1
2
3
4
Meaning:
Abhi kuch nahi karna
later code likhenge

7. range() (Very Important):-------------------


range() =
Number generate karta hai

range(5)
for i in range(5):
print(i)

Output:
0
1
2
3
4
range(start, end)

Example:
for i in range(1, 6):
print(i)

Output:
1
2
3
4
5
range(start, end, step)

Example:
for i in range(1, 10, 2):
print(i)

Output:
1
3
5
7
9

Meaning
start
end
jump/step

8. enumerate():----------------------
enumerate() kya karta hai?
Index + value dono deta hai

Example:
fruits = [
"apple",
"banana",
"mango"
]
for index, item in enumerate(fruits):
print(index, item)

Output:
0 apple
1 banana
2 mango

!!!!Without enumerate
Sirf item milega.

!!!With enumerate
Index + item

!!! Real Example Program:---


students = [
"Sonu",
"Rahul",
"Amit"
]
for index, name in enumerate(students):
print(
f"{index} - {name}"
)

Output:
0 - Sonu
1 - Rahul
2 - Amit

!!!!Easy Summary:------------
for

Known repeat

while

Condition based

nested loop

loop inside loop

break

stop loop

continue

skip step

pass

do nothing

range()

numbers

enumerate()

index + value
Practice Task

Print:
1 to 10

Then:
Skip 5
Stop at 9

!!! Use:
for
continue
break
range()

!!! Expected idea:


1
2
3
4
6
7
8

===================================================================================
=======

# MODULE 11 — Functions
Function basics
Parameters
Arguments
Return statement
Default arguments
Keyword arguments
Lambda function
Recursive function
Scope (local/global):-----------------------------

MODULE 11 — Functions (Super Important) (Simple Way)


Function Kya Hota Hai?

Function =
Ek reusable code block

Simple meaning:
Ek baar banao
baar-baar use karo

**Real life:
Jaise calculator me:
Addition button
Har baar same logic nahi likhte.
Function bana dete hain.
1. Function Basics:--------
Function banane ke liye:

def
use hota hai.

Syntax:
def function_name():
code

Example:
def hello():
print("Hello Sonu")
Function ban gaya.

But abhi run nahi hua ❌

Call karna padega.


hello()

Output:
Hello Sonu
Another Example
def welcome():
print("Welcome to Python")
welcome()

Output:
Welcome to Python

2. Parameters:---------
Parameter =
Function banate time value receive karne ka variable

Example:
def greet(name):
print("Hello", name)

Yaha:

name = parameter

3. Arguments:----
Argument =
Function call karte time actual value dena

Example:
greet("Sonu")

Output:
Hello Sonu
Samjho
Parameter → placeholder

*****Argument → real value:-


Multiple parameters

Example:
def add(a, b):
print(a + b)

add(10, 20)

Output:
30

4. Return Statement (Very Important):---------------

Return =
Value wapas bhejna

Example:
def add(a, b):
return a + b

Call:
result = add(10, 20)
print(result)

Output:
30

Difference
Without return:

def add(a, b):


print(a + b)
Sirf print karega.

With return:
Value wapas milegi

5. Default Arguments:-------------

Default value dena.

Example:
def greet(name="Guest"):
print("Hello", name)
greet()
Output:
Hello Guest

Value pass karoge


greet("Sonu")

Output:
Hello Sonu

6. Keyword Arguments:--------
Direct parameter name use karna.

Example:
def student(name, age):
print(name, age)

student(
age=25,
name="Sonu"
)

Output:
Sonu 25

!!!Benefit:--
Order matter nahi karta.

7. Lambda Function:---------
Lambda =
Small one-line function

Syntax:
lambda arguments : expression

Example:
square = lambda x: x * x
print(square(5))

Output:
25

Normal vs Lambda

Normal:
def square(x):
return x*x

Lambda:
lambda x: x*x
Add example
add = lambda a, b: a+b
print(add(10,20))

Output:
30

8. Recursive Function:---------------

Recursion =
Function khud ko call kare

Example:
def countdown(n):

if n == 0:
return

print(n)
countdown(n-1)
countdown(5)

Output:
5
4
3
2
1
Samjho
5

4

3

2

1

Khud ko call kar raha hai.

9. Scope (Local / Global)


Scope =
Variable kaha use ho sakta hai

****Local Variable:-------

Sirf function ke andar.


Example:
def test():

x = 10

print(x)
test()

Output:
10

Outside use?
print(x)

❌ Error

Kyuki:
Local variable

*****Global Variable:------
Function ke bahar.

!!!Example::-
x = 100

def test():
print(x)
test()

Output:
100

!!! Simple Rule:----


Local

Inside function

Global

Everywhere

!!!! Real Example Program:----


def employee(name, salary=50000):

return f"{name} earns {salary}"

result = employee("Sonu")
print(result)

Output:
Sonu earns 50000

******Easy Summary:--------------
Function

Reusable code

Parameter

Input variable

Argument

Real value

return

send back value

default argument

default value

keyword argument

name=value

lambda

one-line function

recursion

function calls itself

scope

local/global

*****Practice Task

Create:
Function calculator

Make:
add(a,b)
multiply(a,b)

!!!Use:
return
parameter
argument

!!Expected:
10 + 20 = 30
10 × 20 = 200

===================================================================================
=======
===================================================================================
=======
# MODULE 12 — Exception Handling
try
except
finally
else
Custom exception
Error debugging:-------------

MODULE 12 — Exception Handling (Simple Way)


Exception Handling Kya Hota Hai?

Exception Handling =
Program me error aane par usko handle karna

Simple meaning::--------
Error aaye
Program band na ho

Example:
Agar user:
10 / 0
kar de

Normally:

❌ Error aayega aur program stop.


But exception handling se:

✅ Error handle hoga.

1. try
try kya hota hai?
Jis code me error aa sakta hai usko try me likhte hain

Syntax:
try:
code

Example:
try:
print(10 / 2)

Output:
5.0

!!!!Error Example:---------
try:
print(10 / 0)

Error aa sakta hai.

Isliye:
except
use karte hain.

2. except:-----------
except kya hota hai?
Error ko handle karta hai

Example:
try:
print(10 / 0)

except:
print("Error Found")

Output:
Error Found
Program band nahi hua ✅

***Specific Error

Example:
try:
number = int("abc")

except ValueError:
print("Invalid number")

Output:
Invalid number
Divide error
try:
print(10 / 0)

except ZeroDivisionError:
print("Cannot divide by zero")

Output:
Cannot divide by zero

3. finally:-------------------
finally kya hota hai?

Error aaye ya na aaye


Hamesha chalega

Example:
try:
print(10 / 2)

except:
print("Error")

finally:
print("Program End")

Output:
5.0
Program End
Error case
try:
print(10 / 0)

except:
print("Error")

finally:
print("Program End")

Output:
Error
Program End
Easy meaning:
finally

Always run

4. else
else kya hota hai?
Jab error nahi aaye tab chale

Example:
try:
print(10 / 2)

except:
print("Error")
else:
print("Success")

Output:
5.0

Success
Error case
try:
print(10 / 0)

except:
print("Error")

else:
print("Success")

Output:
Error
Else nahi chala.

Simple rule:
No error

else runs

5. Custom Exception:---------------
Custom exception kya hota hai?
Apna khud ka error banana

Using:
raise

Example:
age = 15
if age < 18:
raise Exception(
"Not eligible"
)

Output:
Error:
Not eligible

!!!Real Example:--
salary = 5000

if salary < 10000:


raise Exception(
"Salary too low"
)
Easy meaning
Custom Exception

Own error message

6. Error Debugging:-----------------
Debugging =
Error ko find aur fix karna

Example 1

Wrong:
print(number)

Output:
NameError

Fix:
number = 10

print(number)
Example 2

Wrong:
print(10 / 0)

Output:
ZeroDivisionError

Fix:
print(10 / 2)
Example 3

Wrong:
age = int("abc")

Output:
ValueError

Fix:

age = int("25")
Real Example Program
try:
number = int(
input("Enter number: ")
)

print(100 / number)
except ZeroDivisionError:
print("Cannot divide by zero")

except ValueError:
print("Enter valid number")

finally:
print("Program Finished")

Input:
0

Output:
Cannot divide by zero
Program Finished

!!!!Easy Summary:---------------------
try

Risky code

except

Handle error

finally

Always run

else

No error case

custom exception

Own error

debugging

Find & fix error

!!!!Practice Task:------------
Create program:

Rules:
Take number input
100 divide karo

!!! If:
0 → show message
wrong input → show message

!! Use:
try
except
finally

===================================================================================
===================================================================================
==============
# MODULE 13 — File Handling
Read file
Write file
Append file
CSV handling
JSON file handling
Context manager:-----------------------

MODULE 13 — File Handling (Simple Way)


File Handling Kya Hota Hai?
File Handling =
File ko read (padhna), write (likhna), aur update karna

Real life:
[Link]
[Link]
[Link]

Python in files ke data ko handle karta hai.


File Modes
Python me file open karne ke modes:
r → read
w → write
a → append

1. Read File
Read kya hota hai?
File ka data padhna

Syntax:
file = open("[Link]", "r")
print([Link]())
[Link]()

Example:

Suppose file:
[Link]
contains:
Hello Sonu
Welcome to Python

Code:
file = open("[Link]", "r")
print([Link]())
[Link]()

Output:
Hello Sonu
Welcome to Python
readlines()
Line by line data.

Example:
file = open("[Link]", "r")
print([Link]())
[Link]()

Output:
[
'Hello Sonu\n',
'Welcome to Python'
]
readline()
Sirf ek line read.

Example:
file = open("[Link]", "r")

print([Link]())
[Link]()

Output:
Hello Sonu
Easy meaning:
read()

Full file

readline()

One line

readlines()

All lines
2. Write File
Write kya hota hai?
File me new data likhna

Mode:
w

⚠ Important:
Purana data delete ho jata hai

Example:
file = open("[Link]", "w")
[Link]("Hello Sonu")
[Link]()

File content:

Hello Sonu
Another Example
file = open("[Link]", "w")
[Link]("Name: Sonu")
[Link]()

3. Append File
Append kya hota hai?
Purane data ke niche new data add

Mode:
a

Example:
File before:
Hello Sonu

Code:
file = open("[Link]", "a")
[Link]("\nWelcome Python")
[Link]()

Output file:
Hello Sonu
Welcome Python
Difference
w

Overwrite

a

Add data
4. CSV Handling:-----

CSV =
Comma separated values

Example file:
[Link]

Data:
name,age,city
Sonu,25,Noida
Rahul,22,Delhi
Read CSV

Example:
import csv
file = open("[Link]", "r")
reader = [Link](file)

for row in reader:


print(row)

[Link]()

Output:

['name', 'age', 'city']


['Sonu', '25', 'Noida']
['Rahul', '22', 'Delhi']
Write CSV

Example:
import csv

file = open(
"[Link]",
"w",
newline=""
)

writer = [Link](file)

[Link](
["name", "age"]
)

[Link](
["Sonu", 25]
)
[Link]()
Easy meaning:
CSV

Excel type data

5. JSON File Handling:---


JSON =
Data dictionary format me store hota hai

Example:

{
"name": "Sonu",
"age": 25
}
Read JSON
Example:

import json

file = open(
"[Link]",
"r"
)

data = [Link](file)
print(data)

[Link]()

Output:
{
'name': 'Sonu',
'age': 25
}
Write JSON

Example:
import json
data = {
"name": "Sonu",
"age": 25
}

file = open(
"[Link]",
"w"
)
[Link](data, file)

[Link]()
Easy meaning
JSON

Dictionary style data

6. Context Manager (Very Important)

Context manager =
File automatically close kar deta hai

Using:

with
Without with
file = open(
"[Link]",
"r"
)

print([Link]())
[Link]()

Manual close karna padta hai.

With Context Manager ✅


with open(
"[Link]",
"r"
) as file:

print([Link]())

No need:
[Link]()
Automatic close.

!!!! Best Practice:---

Always use:

with
Real Example Program
with open(
"[Link]",
"w"
) as file:
[Link](
"Name: Sonu"
)

with open(
"[Link]",
"r"
) as file:

print([Link]())

Output:
Name: Sonu

!!!! Easy Summary:----


File handling

Read/write files

r

read

w

write

a

append

CSV

table/excel data

JSON

dictionary data

with

auto close file

!!! Practice Task:----


Create file:
[Link]

!!! Do:
Write your name
Append city name
Read file
Create JSON data
Read JSON file
Use with method only

!! Expected idea:
Name: Sonu
City: Noida

===================================================================================
=============================
====================================================================

# MODULE 14 — OOPs (Object Oriented Programming)


Class
Object
Constructor
Inheritance
Polymorphism
Encapsulation
Abstraction
Method overriding:---

***********************************************************************************
********
PART 1:OOPs (Object Oriented Programming)
Class
Object
Constructor
Inheritance:---

MODULE 14 — OOPs (Object Oriented Programming) (Simple Way)


OOPs Kya Hota Hai?
OOPs =
Real world cheezo ko code me banana

!!!! Simple meaning---


Class = Design / Blueprint
Object = Real item

Real life example:


Car blueprint

Many real cars

!!!! Same way Python me:

Class

Object banta hai

1. Class
Class kya hoti hai?
Template / Design

Simple meaning:
Ek structure
jiske base par object banta hai

Example:
class Student:

name = "Sonu"

age = 25

Yaha:
Student

Class
Class Example
class Car:

brand = "BMW"
color = "Black"
print([Link])

Output:
BMW
Easy meaning
Class

Blueprint / design

2. Object
Object kya hota hai?
Class ka real copy

Syntax:
object_name = ClassName()

Example:
class Student:

name = "Sonu"

student1 = Student()
print([Link])
Output:
Sonu
Multiple Objects
class Employee:

company = "HCL"

emp1 = Employee()
emp2 = Employee()

print([Link])
print([Link])

Output:
HCL
HCL
Easy meaning
Object

Real thing

3. Constructor
Constructor kya hota hai?
Object create hote hi automatically run hota hai

Use:
__init__()
Example
class Student:

def __init__(self):

print(
"Constructor called"
)

student1 = Student()

Output:
Constructor called
Automatically run hua.
Constructor with values

Example:
class Student:

def __init__(
self,
name,
age
):

[Link] = name
[Link] = age

student1 = Student(
"Sonu",
25
)

print([Link])
print([Link])

Output:
Sonu
25

self kya hota hai?


Simple meaning:
Current object
Real Example
class Employee:

def __init__(
self,
name,
salary
):

[Link] = name
[Link] = salary

emp1 = Employee(
"Sonu",
50000
)
print([Link])
Output:
Sonu

4. Inheritance
Inheritance kya hota hai?
Ek class dusri class ke features use kare

Simple meaning:

Parent class

Child class
!! Example
class Animal:
def sound(self):
print("Animal Sound")
class Dog(Animal):
pass

dog1 = Dog()
[Link]()

Output:
Animal Sound
Samjho
Dog

Animal ki power use kar raha

!!! Another Example:----


class Person:

def show(self):

print("I am person")

class Student(Person):

pass

s1 = Student()
[Link]()

Output:
I am person
Inheritance Benefit
Same code repeat nahi karna padta

Reuse hota hai.

!!!!! Real Example Program:-----


class Employee:

def __init__(
self,
name,
company
):

[Link] = name
[Link] = company
def details(self):

print(
[Link],
[Link]
)

emp1 = Employee(
"Sonu",
"HCL"
)
[Link]()

Output:
Sonu HCL

!!!! Easy Summary:---


OOPs

Real world coding

Class

Blueprint

Object

Real copy

Constructor

Auto run (__init__)

self

Current object

Inheritance

Reuse parent class

!!!! Practice Task:----

Create:
Class = Mobile

Add:
brand
price
Create object.

Then:
Constructor use karo

!!! After that:


Create parent class Vehicle
Child class Car
Use inheritance.

*****************************************************
PART 2:----Polymorphism
Encapsulation
Abstraction
Method overriding:---

MODULE 14 Continue — OOPs (Simple Way)


Ab hum OOPs ke next important concepts samjhenge 😄

1. Polymorphism
2. Encapsulation
3. Abstraction
4. Method Overriding

1. Polymorphism
Polymorphism kya hota hai?
Simple meaning:
Ek cheez ke multiple forms

!!! Real life:


Same person
Office → Employee
Home → Father
Market → Customer
Same person, different role.

Python me:
Same method
Different behavior
Example
class Dog:
def sound(self):
print("Bark")

class Cat:
def sound(self):
print("Meow")

d = Dog()
c = Cat()

[Link]()
[Link]()

Output:
Bark
Meow

Dekho:
Method name same

sound()
But output different.
Ye hi polymorphism hai.

Easy meaning:--
Same method
Different work

2. Encapsulation:----------------------------
Encapsulation kya hota hai?
Data ko safe/protect karna

Simple meaning:
Data hide karna

Using
Private variable

!!!! Example:
class Employee:

def __init__(self):
self.__salary = 50000
emp = Employee()
print(emp.__salary)

Output:
Error

Kyuki:
__salary

private hai.
Access using method

Example:

class Employee:
def __init__(self):
self.__salary = 50000

def show_salary(self):
print(
self.__salary
)

emp = Employee()
emp.show_salary()

Output:
50000

Easy meaning
Encapsulation

Hide & protect data

3. Abstraction:---
Abstraction kya hota hai?
Sirf important cheez dikhana

!!! Real life:

Car:
Drive karna aata hai
But engine ka internal logic
nahi pata

Ye abstraction hai.

Example

Using:
ABC

Example:
from abc import ABC, abstractmethod

class Animal(ABC):
@abstractmethod
def sound(self):
pass

class Dog(Animal):
def sound(self):
print("Bark")

d = Dog()
[Link]()

Output:
Bark
Samjho
Animal

Only rule define

Dog

Real implementation

!!!! Easy meaning:---


Abstraction

Hide complexity

4. Method Overriding:-----------------
Method overriding kya hota hai?
Child class parent method ko change kar de

Example:
class Animal:
def sound(self):
print("Animal Sound")
class Dog(Animal):

def sound(self):
print("Dog Bark")

d = Dog()
[Link]()

Output:
Dog Bark
Samjho

Parent:
Animal Sound

Child ne:
Override kar diya
New output.

!!!Another Example:---
class Person:

def job(self):
print("Working")
class Engineer(Person):

def job(self):
print("Software Engineer")
e = Engineer()
[Link]()

Output:
Software Engineer

!!!Easy meaning:--
Overriding

Parent method change

!!!! Real Example Program:--


class Vehicle:

def speed(self):
print("Normal Speed")

class Car(Vehicle):

def speed(self):
print("Fast Speed")

c = Car()
[Link]()

Output:
Fast Speed

!!!! Easy Summary:-------


Polymorphism

Same method
different work

Encapsulation

Hide data

Abstraction

Hide complexity

Method overriding

Change parent method
!!!! Practice Task:--

Create:
Parent class Animal
method → sound()

!!! Child classes:


Dog → Bark
Cat → Meow

Then:
Create private variable
__salary

Then:
Override method in child class

-----------------------------------------------------------------------------------
-------------------------------
-----------------------------------------------------------------------------------
------------------------------
# MODULE 15 — Modules & Packages
Import module
Custom module
math module
random module
datetime
os module
sys module:---------------------------------------------

MODULE 15 — Modules & Packages (Simple Way)


Module Kya Hota Hai?
Module =
Ready-made Python file jisme functions/code hote hain

Simple meaning:
Dusre ka ready code use karna

Example:
Math calculation
Random number
Date & time
Ye sab ready modules me milta hai.

Package Kya Hota Hai?


Package =
Multiple modules ka group
Simple meaning:

Folder

Many modules inside

1. Import Module:---------------
Module use karne ke liye:

import
use hota hai.

Syntax:
import module_name

Example:
import math
print([Link](25))

Output:
5.0

Specific function import

Example:
from math import sqrt
print(sqrt(16))

Output:
4.0

!!!! Easy meaning:---


import

Module ko use karna

2. Custom Module:----
Apna module banana
Suppose file:
[Link]

Inside:
def add(a, b):
return a + b
Dusri file me use
import calculator
print(
[Link](10, 20)
)
Output:
30

!!!! Easy meaning:----


Apna reusable file

3. math Module:-------------------------
Math calculation ke liye.

Example:
import math

sqrt()
Square root
import math
print([Link](36))

Output:
6.0

pow()
Power
print([Link](2, 3))

Output:
8.0

ceil()
Upper round
print([Link](4.2))

Output:
5

floor()
Lower round
print([Link](4.9))

Output:
4

!!!!! Easy summary:-----


sqrt()

root

pow()

power
ceil()

upper round

floor()

lower round

4. random Module:----
Random value generate karta hai.

Import:
import random
randint()
Random number
import random

print(
[Link](1, 10)
)

Output:
Random number
between 1 to 10
choice()
Random item

Example:
fruits = [
"apple",
"banana",
"mango"
]

print(
[Link](fruits)
)

Output:
Any random fruit
Easy meaning
random

Random selection

5. datetime Module:-----------------
Date & time ke liye.

Example:
import datetime
Current date/time
import datetime

today =
[Link]()
print(today)

Output:
Current date & time
Only date
print(
[Link]()
)

Easy meaning:---
datetime

Date + time

6. os Module:-------------------
OS operations ke liye.

Example:
import os
Current folder
print([Link]())

Output:
Current path
Folder list
print([Link]())

Output:
All files list
Easy meaning
os

Computer folder/files

7. sys Module:---------------------
System related work.

Example:
import sys
Python version
print([Link])

Output:
Python version
Command line argument
print([Link])

!!! Easy meaning:--


sys

System information

!!! Real Example Program:--


import math
import random
import datetime

print(
[Link](25)
)

print(
[Link](1,10)
)

print(
[Link]()
)

Output:
5.0
Random number
Today's date

!!!! Easy Summary:---


Module

Ready code

Package

Group of modules

math

Calculation

random

Random values

datetime

Date/time
os

Files/folders

sys

System info

****Practice Task:---

!!! Do:
Find square root of 81
Generate random number
Show today date
Show current folder path

!!! Use:
math
random
datetime
os
-----------------------------------------------------------------------------------
------------------------------
-----------------------------------------------------------------------------------
------------------------------
#### MODULE 16 — Advanced Python (Simple Way)
Ye topics thode advanced hain, but simple way me samjhenge 😄

1. List comprehension
2. Dictionary comprehension
3. Generator
4. Iterator
5. Decorator
6. Regex
7. zip()
8. map()
9. filter()
10. reduce():--------------------------------

1. List Comprehension:----------------
Kya hota hai?
Short way me list banana

Normal way:
numbers = []
for i in range(5):
[Link](i)

print(numbers)
Output:
[0, 1, 2, 3, 4]
List Comprehension Way
numbers = [
i for i in range(5)
]

print(numbers)

Output:
[0, 1, 2, 3, 4]
Even number example
even = [
i for i in range(10)
if i % 2 == 0
]
print(even)

Output:
[0, 2, 4, 6, 8]
Easy meaning
List comprehension

Short loop for list

2. Dictionary Comprehension:-------------------------
Kya hota hai?
Short way me dictionary banana

Example:
square = {
x: x*x
for x in range(5)
}
print(square)

Output:
{
0:0,
1:1,
2:4,
3:9,
4:16
}

!!!! Easy meaning:--


Dictionary comprehension

Short dictionary creation
3. Generator:------------------------
Generator kya hota hai?
Ek-ek value deta hai

Use:
yield

Example:
def numbers():

yield 1
yield 2
yield 3

x = numbers()

print(next(x))
print(next(x))

Output:
1
2
Samjho
List

Sab memory me

Generator

Ek-ek value
Memory save karta hai.

4. Iterator:------------------
Iterator kya hota hai?
Ek-ek item access karna

Example:
numbers = [10,20,30]

x = iter(numbers)
print(next(x))
print(next(x))

Output:
10
20
Meaning
iter()

iterator banao
next()

next value

5. Decorator:--------------------------
Decorator kya hota hai?
Function ko modify karna

Example:
def message(func):

def inner():
print("Welcome")
func()

return inner

@message
def hello():
print("Sonu")

hello()

Output:
Welcome
Sonu
Meaning
Decorator

Extra power add

6. Regex (Regular Expression):----------------------


Regex kya hota hai?
Text search/check karna

Import:
import re

!!! Search example:---


import re

text = "Hello Sonu"

x = [Link](
"Sonu",
text
)
print(x)
Output:
Match found
Find numbers
import re

text = "My age is 25"

x = [Link](
"\d+",
text
)

print(x)

Output:
['25']
Easy meaning
Regex

Find/search text

7. zip():----------------------------
zip() kya hota hai?
2 lists ko combine karna
Example:
name = [
"Sonu",
"Rahul"
]

age = [25,22]
result = zip(name, age)
print(list(result))

Output:
[
('Sonu',25),
('Rahul',22)
]
Meaning
zip()

Combine data

8. map():--------------
map() kya hota hai?

Sab values par function lagana

Example:
numbers = [1,2,3]

result = map(
lambda x: x*2,
numbers
)

print(
list(result)
)

Output:
[2,4,6]

Meaning
map()

Apply function

9. filter():----------------------------
filter() kya hota hai?
Condition ke hisab se data filter

Example:
numbers = [1,2,3,4,5]

result = filter(
lambda x: x%2==0,
numbers
)

print(
list(result)
)

Output:
[2,4]

Meaning
filter()

Keep matching values

10. reduce():-----------------------
reduce() kya hota hai?
Sab values combine karta hai

Import:
from functools import reduce
Example:
from functools import reduce
numbers = [1,2,3,4]

result = reduce(
lambda x,y:x+y,
numbers
)

print(result)

Output:
10

Meaning
reduce()

Combine all values

!!!!Real Example Program:-------------------


from functools import reduce

numbers = [1,2,3,4,5]

even = list(
filter(
lambda x:x%2==0,
numbers
)
)

double = list(
map(
lambda x:x*2,
numbers
)
)

total = reduce(
lambda x,y:x+y,
numbers
)

print(even)
print(double)
print(total)

Output:
[2,4]
[2,4,6,8,10]
15

!!!!Easy Summary:------------------
List comprehension

Short list

Dictionary comprehension

Short dictionary

Generator

One by one value

Iterator

Next item

Decorator

Modify function

Regex

Search text

zip()

Combine lists

map()

Apply function

filter()

Filter data

reduce()

Combine values

!!!!Practice Task:--------------

Do:
1 to 10 even numbers
Square of numbers
Add all numbers
Combine names + age

Use:
list comprehension
map()
reduce()
zip()

-----------------------------------------------------------------------------------
------------------------------
-----------------------------------------------------------------------------------
------------------------------

# MODULE 17 — NumPy
Arrays
Operations
Shape
Indexing
Broadcasting:------

MODULE 17 — NumPy (Simple Way)


NumPy Kya Hota Hai?
NumPy =
Python library for fast calculations & arrays

Simple meaning:
Big data
Fast calculation
Math operations

Use hota hai:


AI
Machine Learning
Data Science
Gen AI
Install NumPy

!!!! Install command:


pip install numpy

Import:
import numpy as np

Yaha:
np

Short name
1. Arrays::::--------------
Array kya hota hai?
List jaisa hota hai but faster

Python List:
numbers = [1,2,3]

NumPy Array:
import numpy as np

arr = [Link]([1,2,3])
print(arr)

Output:
[1 2 3]

Multiple values::::
arr = [Link](
[10,20,30,40]
)
print(arr)

Output:
[10 20 30 40]

2D Array::::
Array inside array.

Example:

arr = [Link]([
[1,2],
[3,4]
])
print(arr)

Output:
[
[1 2]
[3 4]
]

Easy meaning:----
Array

Fast list

2. Operations:------
NumPy me math easy hota hai.
Addition:::
Example:
arr = [Link](
[1,2,3]
)
print(arr + 10)

Output:
[11 12 13]

Multiply:::::
print(arr * 2)

Output:
[2 4 6]

Add two arrays


a = [Link]([1,2,3])
b = [Link]([4,5,6])

print(a + b)

Output:
[5 7 9]

Sum
print([Link]())

Output:
6

!!!Easy meaning:---
Operations

Fast math

3. Shape:-----
Shape kya hota hai?
Rows & columns batata hai

Example:
arr = [Link]([
[1,2],
[3,4]
])
print([Link])

Output:
(2,2)
Meaning:
2 rows
2 columns

!!Another Example:--
arr = [Link]([
[1,2,3],
[4,5,6]
])
print([Link])

Output:
(2,3)

Meaning:
2 rows
3 columns

!! Easy meaning:-
shape

Rows + columns

4. Indexing:---------------------------
Indexing kya hota hai?
Specific value access karna

Example:
arr = [Link](
[10,20,30]
)

print(arr[0])

Output:
10

2D indexing:------------------------

Example:
arr = [Link]([
[1,2],
[3,4]
])
print(arr[0,1])

Output:
2
Meaning:
row 0
column 1
Negative indexing
print(arr[-1])

Output:
[3 4]

Easy meaning:---
Indexing

Get value

5. Broadcasting:--------------------
Broadcasting kya hota hai?
Ek value sab par apply ho jaye

Example:
arr = [Link](
[1,2,3]
)

print(arr + 5)

Output:
[6 7 8]

Yaha:
5

sab values me add ho gaya.

Multiply
print(arr * 10)

Output:
[10 20 30]

Another Example:--
a = [Link]([
[1,2],
[3,4]
])

print(a + 2)

Output:
[
[3 4]
[5 6]
]

!!! Easy meaning


Broadcasting

One value
applies everywhere

!!!Real Example Program:----


import numpy as np

arr = [Link](
[10,20,30]
)

print(arr)
print(arr + 5)
print(arr * 2)
print([Link]())

Output:
[10 20 30]
[15 25 35]
[20 40 60]
60

!!!! Easy Summary:-----


NumPy

Fast calculations

Array

Fast list

Operations

Math work

Shape

Rows/columns

Indexing

Get value

Broadcasting

Apply one value to all

!!! Practice Task:----


Create:
Array = [10,20,30,40]

!!!! Do:
Add 5
Multiply by 2
Print first value
Find sum
Check shape

!!! Use:
array
indexing
broadcasting
sum()
shape

-----------------------------------------------------------------------------------
------------------------------
-----------------------------------------------------------------------------------
------------------------------

# MODULE 18 — Pandas
DataFrame
Series
Read CSV
Filtering
Groupby
Merge
Cleaning:------

MODULE 18 — Pandas (Simple Way)


Pandas Kya Hota Hai?
Pandas =
Python library for data handling & analysis

Simple meaning:
Excel jaisa data
handle karna

Use hota hai:


Excel data
CSV files
Data analysis
AI / Gen AI
Install Pandas
Install:
pip install pandas

Import:
import pandas as pd

Yaha:
pd

Short name

1. DataFrame:--------------------
DataFrame kya hota hai?
Table format data
Excel table jaisa.

Example:
import pandas as pd
data = {
"Name": [
"Sonu",
"Rahul",
"Amit"
],

"Age": [
25,
22,
30
]
}

df = [Link](data)
print(df)

Output:
Name Age
0 Sonu 25
1 Rahul 22
2 Amit 30
Easy meaning
DataFrame

Excel table

2. Series:-------------------------
Series kya hota hai?
Single column data

Example:
import pandas as pd

s = [Link](
[10,20,30,40]
)

print(s)

Output:
0 10
1 20
2 30
3 40
Example 2
name = [Link](
["Sonu", "Rahul"]
)

print(name)

Output:
0 Sonu
1 Rahul

!!!!Easy meaning:---------
Series

Single column

3. Read CSV:------------------
CSV kya hota hai?
Excel jaisa file.
Example file:
[Link]

Data:
Name,Age
Sonu,25
Rahul,22
Read CSV file

Example:
import pandas as pd

df = pd.read_csv(
"[Link]"
)
print(df)

Output:
Name Age
0 Sonu 25
1 Rahul 22
Head function

Top rows show.


print([Link]())
Easy meaning
read_csv()

CSV file open

4. Filtering:-------------------------
Filtering kya hota hai?
Condition ke hisab se data show

Example:
data = {
"Name": [
"Sonu",
"Rahul",
"Amit"
],

"Age": [
25,
20,
30
]
}

df = [Link](data)

print(
df[df["Age"] > 22]
)

Output:
Name Age
Sonu 25
Amit 30
Meaning
Only matching data

5. Groupby:----------------------------
groupby kya hota hai?
Same category ka data group karna

Example:
data = {
"Department":
[
"IT",
"HR",
"IT"
],

"Salary":
[
50000,
30000,
60000
]
}

df = [Link](data)
print(
[Link](
"Department"
).sum()
)

Output:
Department Salary

HR 30000
IT 110000
Easy meaning
groupby()

Group data

6. Merge:--------------------------
Merge kya hota hai?

2 tables ko join karna

Example:
df1 = [Link]({
"ID": [1,2],
"Name":
["Sonu","Rahul"]
})

df2 = [Link]({
"ID":[1,2],
"Salary":
[50000,60000]
})
result = [Link](
df1,
df2,
on="ID"
)

print(result)

Output:
ID Name Salary

1 Sonu 50000
2 Rahul 60000
Easy meaning
merge()

Join tables

7. Cleaning:-----------
Cleaning kya hota hai?
Wrong / empty data fix karna
Check missing data

Example:
print([Link]())
Remove missing data
df = [Link]()
Fill missing data
df = [Link](0)
Remove duplicate data
df = df.drop_duplicates()

!!! Easy meaning:------


Cleaning

Fix bad data
Real Example Program
import pandas as pd

data = {
"Name":
[
"Sonu",
"Rahul",
"Amit"
],

"Salary":
[
50000,
30000,
60000
]
}
df = [Link](data)

print(df)

print(
df[df["Salary"] > 40000]
)

Output:
Name Salary

Sonu 50000
Rahul 30000
Amit 60000

Sonu 50000
Amit 60000

!!!! Easy Summary:-----------------


Pandas

Excel data

DataFrame

Table

Series

Single column

read_csv()

Open CSV

Filtering

Condition data

groupby()

Group data

merge()

Join tables

Cleaning

Fix data

!!!!Practice Task:-----------

Create:
Employee table

Columns:
Name
Department
Salary

!!!Do::---
Show salary > 40000
Group department
Add missing value handling
Merge another table with ID

-----------------------------------------------------------------------------------
------------------------------
-----------------------------------------------------------------------------------
------------------------------
# MODULE 19 — SQL + Python Integration
Database connection
CRUD operations
Insert data
Fetch data
API to SQL
SQL automation:----------------------

MODULE 19 — SQL + Python Integration (Simple Way)


SQL + Python Integration Kya Hota Hai?

Simple meaning:
Python ko Database (SQL) ke saath connect karna

Taaki hum:
Data insert kar sake
Data fetch kar sake
Update/delete kar sake
Automation kar sake
API data database me save kar sake

Real life:
Website form

Python

SQL database me save

Example:
Name = Sonu
Salary = 50000
Database me store ho jayega.

1. Database Connection
Database kya hota hai?
Data store karne ki jagah

Example:
Employee data
Student data
Company data
Python SQL se connect hota hai.

Hum simple example use karenge:

SQLite
Kyuki ye Python me built-in hota hai.
No install needed ✅

Connect Database

Example:
import sqlite3

conn = [Link](
"[Link]"
)
print("Connected")

Output:
Connected

Yaha:
[Link]

Database file

*****Cursor kya hota hai?


Cursor =
SQL command chalane ke liye use hota hai

Example:
cursor = [Link]()
2. CRUD Operations
CRUD meaning:

C → Create
R → Read
U → Update
D → Delete

Ye SQL ka basic kaam hai.

!!! Create Table:------------

Example:
import sqlite3

conn = [Link](
"[Link]"
)

cursor = [Link]()

[Link]("""
CREATE TABLE employee(
id INTEGER,
name TEXT,
salary INTEGER
)
""")

[Link]()
print("Table Created")

Output:
Table Created

3. Insert Data
Data add karna

Example:
[Link]("""
INSERT INTO employee
VALUES
(1,'Sonu',50000)
""")

[Link]()
print("Data Inserted")

Output:
Data Inserted
Another Insert
[Link]("""
INSERT INTO employee
VALUES
(2,'Rahul',60000)
""")

[Link]()

!!!!!Easy meaning:::::::::::
Insert

New data add

4. Fetch Data:-------------------------------------
Data read karna

Using:
SELECT

Example:
[Link](
"SELECT * FROM employee"
)
data = [Link]()
print(data)

Output:
[
(1,'Sonu',50000),
(2,'Rahul',60000)
]
Single row
[Link](
"SELECT * FROM employee"
)
print([Link]())

Output:
(1,'Sonu',50000)

!!! Easy meaning:-----------


Fetch

Get data
Update Data

Example:
[Link]("""
UPDATE employee
SET salary = 70000
WHERE id = 1
""")

[Link]()

Meaning:
Sonu salary updated
Delete Data

Example:
[Link]("""
DELETE FROM employee
WHERE id = 2
""")
[Link]()

Meaning:
Rahul deleted

5. API to SQL:--------------------------------------
API data database me save

Simple flow:
API

Python

SQL Database

Example:
API se data aaya:

{
"name":"Sonu",
"salary":50000
}
Python usko SQL me insert karega.

Example:
data = {
"name":"Sonu",
"salary":50000
}

[Link]("""
INSERT INTO employee
VALUES (?,?)
""",
(
data["name"],
data["salary"]
))

[Link]()

!!! Real life use:---------------------------


Weather API
Employee API
Finance API
Chatbot data

6. SQL Automation
Automation kya hota hai?
Automatically database ka kaam karna

Example:
Har employee automatically insert.

employees = [
("Sonu",50000),
("Rahul",60000),
("Amit",70000)
]

[Link](
"""
INSERT INTO employee
(name,salary)
VALUES (?,?)
""",
employees
)
[Link]()

Output:
All data inserted

Real life
Excel to SQL

!!!!API to SQL:--------------------------
Daily report automation
Attendance automation
Real Example Program
import sqlite3

conn = [Link](
"[Link]"
)
cursor = [Link]()

[Link]("""
CREATE TABLE IF NOT EXISTS employee(
id INTEGER,
name TEXT,
salary INTEGER
)
""")

[Link]("""
INSERT INTO employee
VALUES
(1,'Sonu',50000)
""")
[Link]()

[Link](
"SELECT * FROM employee"
)

print(
[Link]()
)
[Link]()

Output:
[(1,'Sonu',50000)]

!!!! Easy Summary:-----------------------


SQL + Python

Database connection

CRUD

Create
Read
Update
Delete

Insert

Add data

Fetch

Get data
API to SQL

Save API data

Automation

Auto database work
Practice Task

Create:
Database = [Link]

Table:
employee

Columns:
id
name
salary

Do:
Insert 3 employees
Fetch all data
Update salary
Delete one employee

Use:
sqlite3
cursor
execute()
commit()

-----------------------------------------------------------------------------------
------------------------------
-----------------------------------------------------------------------------------
------------------------------
# MODULE 20 — API Integration (Very Important)
API basics
GET request
POST request
JSON response
Headers
API key
Authentication
Error handling
REST API:-----------------------

MODULE 20 — API Integration (Very Important) (Simple Way)


API Kya Hota Hai?
API =
Ek system ko dusre system se connect karna

Simple meaning:
Data lena
ya bhejna

!!!!Real life example::---

Weather App

Weather API

Data show

Jaise:
Temperature
Rain
Humidity
API se aata hai.

Real Flow
Python

API Request

Server

Response

Python

Install Library

Python me API ke liye mostly use hota hai:


requests

Install:
pip install requests

Import:
import requests

1. API Basics
API full form:
Application Programming Interface

Simple meaning:
Data exchange

Example:
Weather API
Stock API
Cricket API

AI API
(OpenAI, Gemini)

2. GET Request
GET kya hota hai?
API se data lena

Example:
import requests
url = "[Link]
response = [Link](url)
print([Link])

Meaning:
API se data fetch
JSON data

Example:
import requests
url = "[Link]
response = [Link](url)
print([Link]())

Output:
Dictionary format data

!!!Easy meaning:--
GET

Take data

3. POST Request
POST kya hota hai?
Data bhejna

Example:
import requests

url = "[Link]
data = {
"name": "Sonu",
"salary": 50000
}

response = [Link](
url,
json=data
)
print(response.status_code)

Meaning:
Data sent to server
Easy meaning
POST

Send data

4. JSON Response
Most APIs return:

JSON
Example JSON:
{
"name":"Sonu",
"salary":50000
}

Python me convert:
data = [Link]()
print(data)

Access data:
print(data["name"])
Output:
Sonu

!!!Easy meaning:---------------
JSON

Dictionary jaisa data

5. Headers:----------------------------
Headers kya hote hain?
Extra information bhejna

Example:
headers = {
"Content-Type":
"application/json"
}

Request:
response = [Link](
url,
headers=headers
)
Real use
Security
API access
Data type

!!!! Easy meaning:-----------------


Headers

Extra info

6. API Key:-----------------------
API key kya hoti hai?
Secret password for API

Example:
OpenAI API key
Weather API key

Example:
api_key = "abcd123"

Use:

headers = {
"API-Key": api_key
}

⚠ Important:
API key public nahi share karna

!!!!!!!Easy meaning:-------------------
API key

Secret access password

7. Authentication:--------------------------
Authentication kya hota hai?
Verify karna ki user allowed hai

Example:
Login system

****Common types:
API key
Bearer token
Username/password
Bearer Token Example
headers = {
"Authorization":
"Bearer xyz123"
}

!!!! Easy meaning:----------------


Authentication

Identity check

8. Error Handling
Agar API fail ho jaye?

Use:
try except

Example:
import requests

try:
response = [Link](
"wrong_url"
)

print(
response.status_code
)
except Exception as e:

print(
"API Error"
)
Status Code
200 → Success
404 → Not found
500 → Server error
401 → Unauthorized

Example:
print(
response.status_code
)
Easy meaning
Error handling

Avoid crash

9. REST API:----------------------------------------
REST API kya hota hai?
Standard way to communicate with APIs

Most modern APIs are:


REST API
!!!!!!Methods::----------------
GET
↓ get data

POST
↓ send data

PUT
↓ update

DELETE
↓ remove

Example:
Employee API

GET:
Get employee data

POST:
Add employee

DELETE:
Delete employee

!!!!!!Real Example Program:--------------------


import requests
url = "[Link]
response = [Link](url)

print(
response.status_code
)

data = [Link]()
print(data)

Output:
200
API data

!!!!!!Easy Summary:-----------------------
API

Connect systems

GET

Take data
POST

Send data

JSON

Dictionary data

Headers

Extra info

API key

Secret access

Authentication

Verify user

Error handling

Handle API failure

REST API

Standard API system

!!!!Practice Task:-----------------
Create:
GET request

Do:
Call API
Print JSON data
Print status code
Add header
Handle error

Use:
requests
get()
json()
try-except
headers

-----------------------------------------------------------------------------------
------------------------------
-----------------------------------------------------------------------------------
------------------------------
# MODULE 21 — Automation with Python
Email automation
Excel automation
WhatsApp automation
File automation
Scheduling:---------------

MODULE 21 — Automation with Python (Simple Way)


Automation Kya Hota Hai?
Automation =
Kaam automatically karwana

Simple meaning:
Manual work

Automatic work

Real life:
Email auto send
Excel auto update
WhatsApp auto message
Files auto move
Python ye sab kar sakta hai ✅

1. Email Automation
Email automation kya hota hai?
Python se automatically email bhejna

Example:
Daily report email
Attendance email
Alert email

Python library:
smtplib
Example
import smtplib

server = [Link](
"[Link]",
587
)
[Link]()

[Link](
"your_email@[Link]",
"password"
)
message = "Hello Sonu"
[Link](
"your_email@[Link]",
"friend@[Link]",
message
)
print("Email Sent")

Output:
Email Sent
Easy meaning
Email automation

Auto email send

2. Excel Automation:-------------------------
Excel automation kya hota hai?
Excel file automatically handle karna

Library:
openpyxl

Install:
pip install openpyxl
Write Excel Data

Example:
from openpyxl import Workbook

wb = Workbook()
sheet = [Link]
sheet["A1"] = "Name"
sheet["B1"] = "Salary"

sheet["A2"] = "Sonu"
sheet["B2"] = 50000
[Link]("[Link]")
print("Excel Saved")

Output:
Excel Saved
Read Excel
from openpyxl import load_workbook

wb = load_workbook(
"[Link]"
)

sheet = [Link]
print(sheet["A2"].value)
Output:
Sonu
Easy meaning
Excel automation

Excel auto work

3. WhatsApp Automation:----
WhatsApp automation kya hota hai?

Auto WhatsApp message bhejna

Library:
pywhatkit

Install:
pip install pywhatkit
Send Message

Example:
import pywhatkit

[Link](
"+911234567890",
"Hello Sonu",
10,
30
)

Meaning:
10:30 par
message send hoga

⚠ Important:
WhatsApp Web open hota hai
Easy meaning
WhatsApp automation

Auto message

4. File Automation:---------------
File automation kya hota hai?
Files automatically handle karna

Example:
File rename
Move file
Delete file
Create folder
Library:
os
shutil
Create folder
import os
[Link]("PythonFiles")

Output:
Folder created
Rename file
import os

[Link](
"[Link]",
"[Link]"
)
Delete file
[Link]("[Link]")

Easy meaning
File automation

Auto file work

5. Scheduling:------------
Scheduling kya hota hai?
Automatic time par code run karna

Example:
Daily report
Auto backup
Auto message

Library:
schedule

Install:
pip install schedule

Example
import schedule
import time
def work():

print(
"Task Running"
)

[Link](
5
).[Link](work)

while True:
schedule.run_pending()
[Link](1)

Output:
Every 5 second
task run

!!!!Real Example Program:---------------


import schedule
import time

def message():
print(
"Daily Report Sent"
)

[Link](
10
).[Link](message)

while True:
schedule.run_pending()
[Link](1)

Output:
Daily Report Sent

!!!!Real Life Use:----------


HR attendance email
Excel salary update
WhatsApp reminder
Auto report generation
API + SQL automation

!!!!Easy Summary:------------
Automation

Automatic work

Email automation

Auto email

Excel automation

Excel work

WhatsApp automation

Auto message

File automation

Auto file handling

Scheduling

Run task on time

!!!!Practice Task:------

Do:
Create excel file
Add employee data
Create folder
Rename file
Run auto message every 5 seconds

Use:
openpyxl
os
schedule

-----------------------------------------------------------------------------------
------------------------------
-----------------------------------------------------------------------------------
------------------------------
# MODULE 22 — Data Visualization
Matplotlib
Charts
Bar graph
Line graph
Pie chart:---------------------

MODULE 22 — Data Visualization (Simple Way)


Data Visualization Kya Hota Hai?
Data Visualization =
Data ko charts/graphs me convert karna

Simple meaning:
Numbers

Graphs / Charts
Real life:
Sales report → graph
Marks → chart
Profit → line graph
Library: Matplotlib

Matplotlib kya hai?


Python ki library jo graphs banati hai

Install:
pip install matplotlib

Import:
import [Link] as plt

1. Line Graph
Line graph kya hota hai?
Data ko line me show karna

Example:
import [Link] as plt
x = [1,2,3,4]
y = [10,20,30,40]

[Link](x,y)
[Link]("Line Graph")
[Link]()

Output:
Line graph show hoga

Meaning
Line graph

Trend show karta hai

Example:
Time vs Sales

2. Bar Graph
Bar graph kya hota hai?
Data ko bars (blocks) me dikhana

Example:
import [Link] as plt

x = ["A","B","C"]
y = [10,30,20]
[Link](x,y)
[Link]("Bar Graph")
[Link]()

Output:
Bars show honge

Meaning
Bar graph

Comparison

Example:
Students marks compare

3. Pie Chart
Pie chart kya hota hai?
Data ko circle me percentage ke form me dikhana

Example:
import [Link] as plt
labels = ["Python","Java","C++"]
sizes = [50,30,20]

[Link](
sizes,
labels=labels,
autopct="%1.1f%%"
)
[Link]("Pie Chart")
[Link]()

Output:
Circle chart with % values

Meaning
Pie chart

Percentage share

Example:
Market share

4. Customization (Simple):--------------
Title add karna
[Link]("My Graph")

Labels
[Link]("X Axis")
[Link]("Y Axis")
Show graph
[Link]()
!!!!!Real Example Program:------------
import [Link] as plt
days = [1,2,3,4,5]
sales = [100,200,150,300,250]

[Link](days, sales)
[Link]("Daily Sales")
[Link]("Days")
[Link]("Sales")
[Link]()

Output:
Line graph of sales

!!!!Easy Summary:----------------------
Data Visualization

Data → Graph

Matplotlib

Graph library

Line graph

Trend

Bar graph

Comparison

Pie chart

Percentage

!!!!Practice Task:----------
Create graphs for:
Students marks
Company profit
Mobile app users

Use:
line graph
bar graph
pie chart

-----------------------------------------------------------------------------------
------------------------------
-----------------------------------------------------------------------------------
------------------------------
# MODULE 23 — Web Scraping
HTML basics
BeautifulSoup
Requests
Data extraction:--------

MODULE 23 — Web Scraping (Simple Way)


Web Scraping Kya Hota Hai?
Web Scraping =
Website se data automatically extract karna

Simple meaning:
Website

Python se data lena

Real life:
Price comparison
News extraction
Job data
Product details

Tools Used::::
requests → website data lana
BeautifulSoup → data extract karna

Install:
pip install requests beautifulsoup4

1. HTML Basics
HTML kya hota hai?
Website ka structure

Example:

<h1>Title</h1>
<p>This is paragraph</p>

***Important Tags:-
<h1> → Heading
<p> → Paragraph
<a> → Link
<div> → Section

Easy meaning
HTML

Website ka skeleton
2. Requests (Website data lana)
Requests kya karta hai?
Website ka raw data fetch karta hai

Example:
import requests
url = "[Link]
response = [Link](url)
print([Link])

Output:
HTML code

Easy meaning
requests

Website ka data lana

3. BeautifulSoup
BeautifulSoup kya hai?
HTML ko readable form me convert karta hai

Example:
from bs4 import BeautifulSoup
import requests
url = "[Link]
response = [Link](url)

soup = BeautifulSoup(
[Link],
"[Link]"
)
print(soup)

!!!Easy meaning:---
BeautifulSoup

HTML ko clean data me convert

4. Data Extraction
Data kaise nikalte hain?
Example: Title extract
from bs4 import BeautifulSoup
import requests

url = "[Link]
response = [Link](url)
soup = BeautifulSoup(
[Link],
"[Link]"
)

print(
[Link]
)

Output:
Website title
Paragraph extract
print(
[Link]("p").text
)
All links extract
links = soup.find_all("a")

for link in links:


print([Link]("href"))

!!!Easy meaning:--------------
find()

single data

find_all()

multiple data

!!!!Real Example Program:--------------


import requests
from bs4 import BeautifulSoup
url = "[Link]
response = [Link](url)
soup = BeautifulSoup(
[Link],
"[Link]"
)

print("Title:")
print([Link])

print("Paragraph:")
print([Link]("p").text)

Output:
Website title
First paragraph

!!!!Real Use Cases:---


Amazon price tracking
News websites
Job portals
Stock data
Sports data

****Important Notes:---
✔ Website rules follow karo
✔ [Link] check karo
✔ Over scraping avoid karo

!!!Easy Summary:-----------
Web Scraping

Website data extract

requests

Website fetch

BeautifulSoup

HTML parse

HTML

Website structure

Data extraction

Useful info nikalna

!!!!Practice Task:-----------

Try:
1. Website title extract karo
2. Paragraph extract karo
3. All links extract karo
4. Try any news website

Use:
requests
BeautifulSoup
find()
find_all()

-----------------------------------------------------------------------------------
------------------------------
-----------------------------------------------------------------------------------
------------------------------
# MODULE 24 — Gen AI Python
LLM basics
OpenAI API
Prompt engineering
RAG basics
Embeddings
Vector DB
AI agents
LangChain basics:---------------------

MODULE 24 — Gen AI Python (Simple Way)


Gen AI Kya Hota Hai?
Gen AI =
Aisa AI jo text, code, images, answers generate karta hai

Simple meaning:
User input

AI response

Example:
ChatGPT
Gemini
Claude

1. LLM Basics:------------
LLM kya hota hai?
LLM = Large Language Model
Bahut bada AI model jo text samajhta aur generate karta hai

Example:
Question → Answer
Prompt → Response

Easy meaning
LLM

Smart chatbot brain

2. OpenAI API
API kya karta hai?
Python se AI ko connect karna

Example:
Python → OpenAI → Answer
Simple Example
from openai import OpenAI

client = OpenAI(
api_key="YOUR_KEY"
)
response = [Link](
model="gpt-4o-mini",
messages=[
{"role": "user",
"content": "Hello AI"}
]
)

print(
[Link][0].[Link]
)
Easy meaning
OpenAI API

AI se chat karna

3. Prompt Engineering
Prompt kya hota hai?
AI ko diya gaya instruction

Example:
Bad prompt:
Tell me Python

Good prompt:
Explain Python in simple Hindi with example

Types of prompts
1. Simple prompt
2. Detailed prompt
3. Role-based prompt

Role prompt example


You are a teacher.
Explain SQL simply.

Easy meaning
Prompt engineering

AI ko sahi instruction dena

4. RAG Basics
RAG kya hota hai?
RAG = Retrieval Augmented Generation
AI + external data

Simple flow:
Question

Search data

AI answer
Example
User: Company policy kya hai?
AI → database se info laata hai

Easy meaning
RAG

AI + database knowledge

5. Embeddings:-----------------
Embeddings kya hota hai?
Text ko numbers (vectors) me convert karna

Example:
"Apple"

[0.12, 0.88, 0.45]

Why?
AI similarity find karta hai

Example:
Apple ↔ Mango (fruit similarity)

Easy meaning:------------
Embeddings

Text → numbers

6. Vector DB:------------
Vector Database kya hota hai?
Embeddings store karne ka database

Examples:
Pinecone
FAISS
Weaviate

!!!!Use case:-------------
Search similar documents
Easy meaning
Vector DB

AI memory store

7. AI Agents:-----------
AI Agent kya hota hai?
AI jo khud decision leta hai + tools use karta hai
Example:
User → Task
AI → steps decide
AI → complete task
Example
Weather agent:
- API call
- Data fetch
- Answer give

Easy meaning
AI Agent

Smart worker AI

8. LangChain Basics:----------
LangChain kya hai?
AI apps banane ka framework

Simple meaning::--------------
LLM + Tools + Memory + Chain
Example structure
User input

LangChain

LLM + tools

Final answer

Features:--
1. Memory
2. Tools
3. Agents
4. Chains

Easy meaning:-
LangChain

AI app builder

!!!!!Real Example Flow:-------------


User question

Prompt

LLM (OpenAI)

Embeddings (optional)

Vector DB (RAG)

Agent decides tools

Final answer

!!!!!!Easy Summary:-------------
Gen AI

AI content generator

LLM

AI brain

OpenAI API

AI connect

Prompt engineering

Better instructions

RAG

AI + data

Embeddings

Text → numbers

Vector DB

AI memory

Agents

AI worker

LangChain

AI app framework

!!!!Practice Task:----

Try:
1. Simple OpenAI API call
2. Good prompt vs bad prompt
3. Understand embeddings concept
4. Think RAG example
5. Imagine AI agent for "study planner"

-----------------------------------------------------------------------------------
------------------------------
-----------------------------------------------------------------------------------
------------------------------
# MODULE 25 — Projects (Mandatory)
Beginner
Calculator
ATM
Student management
Intermediate
Expense tracker
Employee management
API dashboard
Advanced
AI chatbot
Finance automation
SQL + API project
Gen AI assistant:---------------------------------------

***********************************************************************************
*********
PART 1:- Projects (Mandatory)
Beginner
Calculator
ATM:--------------

PROJECTS (Beginner) — Python (Simple Step-by-Step)


1. Calculator Project (Very Simple)
What we will build?
Simple calculator jo +, -, ×, ÷ kare

Step 1: Take input


num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
Step 2: Choose operation
print("Choose operation:")
print("1. Add")
print("2. Subtract")
print("3. Multiply")
print("4. Divide")

choice = input("Enter choice (1-4): ")


Step 3: Conditions (Logic)
if choice == "1":
print("Result:", num1 + num2)

elif choice == "2":


print("Result:", num1 - num2)

elif choice == "3":


print("Result:", num1 * num2)

elif choice == "4":


if num2 != 0:
print("Result:", num1 / num2)
else:
print("Cannot divide by zero")

else:
print("Invalid choice")

********************FINAL FULL CODE (Calculator):-------------


num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))

print("Choose operation:")
print("1. Add")
print("2. Subtract")
print("3. Multiply")
print("4. Divide")

choice = input("Enter choice (1-4): ")

if choice == "1":
print("Result:", num1 + num2)

elif choice == "2":


print("Result:", num1 - num2)

elif choice == "3":


print("Result:", num1 * num2)

elif choice == "4":


if num2 != 0:
print("Result:", num1 / num2)
else:
print("Cannot divide by zero")

else:
print("Invalid choice")

!!!!!Easy Summary:--------------------------------------
Input → Choose → Condition → Output

2. ATM Project (Very Simple)


What we will build?
ATM system: balance check, deposit, withdraw

Step 1: Set initial balance


balance = 10000
Step 2: Menu
print("ATM MENU")
print("1. Check Balance")
print("2. Deposit")
print("3. Withdraw")
print("4. Exit")

choice = input("Enter choice: ")

Step 3: Logic
1. Check Balance
if choice == "1":
print("Balance:", balance)

2. Deposit
elif choice == "2":
amount = float(input("Enter amount to deposit: "))
balance += amount
print("New Balance:", balance)

3. Withdraw
elif choice == "3":
amount = float(input("Enter amount to withdraw: "))

if amount <= balance:


balance -= amount
print("Withdraw successful")
print("Remaining Balance:", balance)
else:
print("Insufficient balance")

4. Exit
elif choice == "4":
print("Thank you for using ATM")
Invalid choice
else:
print("Invalid choice")

/*********FINAL FULL CODE (ATM):------------------------


balance = 10000
print("ATM MENU")
print("1. Check Balance")
print("2. Deposit")
print("3. Withdraw")
print("4. Exit")
choice = input("Enter choice: ")

if choice == "1":
print("Balance:", balance)

elif choice == "2":


amount = float(input("Enter deposit amount: "))
balance += amount
print("New Balance:", balance)

elif choice == "3":


amount = float(input("Enter withdraw amount: "))

if amount <= balance:


balance -= amount
print("Withdraw successful")
print("Remaining Balance:", balance)
else:
print("Insufficient balance")

elif choice == "4":


print("Thank you for using ATM")

else:
print("Invalid choice")

!!!!Easy Summary:---------------
Balance → Start money
Deposit → Add money
Withdraw → Remove money
Check → Show money

!!!!FINAL SIMPLE UNDERSTANDING:---------


Calculator

Math operations

ATM

Money system simulation

***********************************************************************************
*********
PART 2:-
Expense tracker
API dashboard:------------------------------
PROJECTS (Beginner → Intermediate)

1. Expense Tracker (Simple Step-by-Step)


What we will build?
Daily expenses track karne wala system

Example:
Food = 200
Travel = 100
Total = 300

STEP 1: Store expenses


expenses = []

STEP 2: Add expenses


n = int(input("How many expenses? "))
for i in range(n):
amount = float(input("Enter expense: "))
[Link](amount)

STEP 3: Show all expenses


print("All Expenses:")
print(expenses)

STEP 4: Total calculation


total = sum(expenses)
print("Total Expense:", total)

STEP 5: Highest & Lowest expense


print("Highest Expense:", max(expenses))
print("Lowest Expense:", min(expenses))

!!!!! FINAL FULL CODE (Expense Tracker):-------------


expenses = []

n = int(input("How many expenses? "))

for i in range(n):
amount = float(input("Enter expense: "))
[Link](amount)

print("\nAll Expenses:", expenses)

total = sum(expenses)
print("Total Expense:", total)

print("Highest Expense:", max(expenses))


print("Lowest Expense:", min(expenses))

****Easy Summary:-------------
Input expenses

Store list

Calculate total

Find max/min

2. API Dashboard (Simple Step-by-Step)


What we will build?
API se data fetch karke simple dashboard banana

Example:
GitHub API → user data show
Weather API → weather show

STEP 1: Install request


pip install requests

STEP 2: Import library


import requests

STEP 3: API URL


Example (GitHub API):
url = "[Link]

STEP 4: Get data from API


response = [Link](url)
data = [Link]()

STEP 5: Show data (Dashboard style)


print("---- API DASHBOARD ----")
print("Name:", data["login"])
print("ID:", data["id"])
print("Node ID:", data["node_id"])

!!!!!!FINAL FULL CODE (API Dashboard):---------------


import requests
url = "[Link]

response = [Link](url)
data = [Link]()

print("---- API DASHBOARD ----")

print("Username:", data["login"])
print("User ID:", data["id"])
print("Type:", data["type"])
print("Profile URL:", data["html_url"])

***********Easy Summary:----
API request

Get JSON data

Extract fields

Show dashboard

!!!!REAL USE CASE:-----------


Expense Tracker uses:
Personal finance apps
Budget apps

!!!!!API Dashboard uses:


Weather app
Crypto tracker
GitHub analytics
Stock dashboard

!!!!FINAL SIMPLE UNDERSTANDING:------------------------


Expense Tracker

Money tracking system

API Dashboard

Live data display system

You might also like