Online Computer Courses Classes and Training Program

Python Complete Course

Python Complete Course


बिल्कुल। मैं Python को एक Expert Teacher की तरह पढ़ाऊँगा—Beginner → Advanced तक, छोटे-छोटे भागों में, आसान भाषा में, Real-Life Examples, Analogies और Practical Applications के साथ।

लेकिन पूरा Beginner से Advanced Python एक ही उत्तर में पढ़ाना संभव नहीं है, क्योंकि यह सैकड़ों पेज का कोर्स बन जाएगा।

इसलिए हम इसे Step-by-Step Complete Course के रूप में करेंगे।


Python Complete Course

Part 1 – Introduction to Python


Section 1 – What is Python?

Simple Definition

Python एक High-Level Programming Language है जिससे हम Computer को Instructions देते हैं कि उसे क्या काम करना है।

सरल भाषा में...

Python = Computer से बात करने की भाषा

जिस तरह हम इंसानों से हिंदी या अंग्रेजी में बात करते हैं...

वैसे ही Computer से Python में बात करते हैं।


Real Life Example

मान लीजिए...

आप किसी होटल में जाते हैं।

आप बोलते हैं

"मुझे एक चाय दीजिए"

अब होटल वाला आपकी बात समझ जाता है।

ठीक वैसे ही...

यदि हम Computer को लिखते हैं

print("Hello")

Computer समझ जाता है कि Screen पर Hello लिखना है।


Analogy

Imagine करो...

Computer एक नया बच्चा है।

उसे कुछ नहीं पता।

जब तक आप उसे Instructions नहीं देंगे,

वह कुछ नहीं करेगा।

Python वही Instructions देने का तरीका है।


Section 2 – Programming Language क्या होती है?

Programming Language वह भाषा होती है जिससे हम Software बनाते हैं।

उदाहरण

  • Calculator

  • WhatsApp

  • Instagram

  • YouTube

  • Google

  • Games

  • AI

  • Robot

इन सभी में Programming Languages का उपयोग होता है।


Popular Languages

  • Python

  • Java

  • C

  • C++

  • JavaScript

  • Go

  • Kotlin

  • Swift


Python सबसे ज्यादा क्यों Popular है?

क्योंकि

✅ सीखना आसान

✅ पढ़ना आसान

✅ लिखना आसान

✅ Powerful

✅ Free

✅ Open Source


Section 3 – Python का उपयोग कहाँ होता है?

Python लगभग हर Industry में उपयोग होती है।


1. Artificial Intelligence

जैसे

  • ChatGPT

  • Gemini

  • Claude


2. Machine Learning

Netflix

Amazon

YouTube Recommendation


3. Data Science

Company लाखों Data का Analysis करती हैं।

Python सबसे ज्यादा उपयोग होती है।


4. Web Development

Website बनाने के लिए

जैसे

Instagram

Spotify

Pinterest


5. Automation

मान लीजिए

आपको रोज़

500 Emails भेजने हैं।

Python खुद भेज सकती है।


6. Cyber Security

Hackers और Ethical Hackers दोनों Python उपयोग करते हैं।


7. Game Development

Games बनाने में


8. Robotics

Robot Control


9. Desktop Applications

Calculator

Billing Software

ERP


10. Mobile Apps

कुछ Frameworks Python को Mobile तक ले जाते हैं।


Section 4 – Python किसने बनाई?

Python को

Guido van Rossum

ने बनाया।

Year

1991


Section 5 – Python नाम Python क्यों?

बहुत लोग सोचते हैं

Snake की वजह से।

लेकिन ऐसा नहीं है।

Python का नाम

Monty Python's Flying Circus

नाम के Comedy Show से लिया गया था।


Section 6 – Python की विशेषताएँ

1. Easy

print("Hello")

बस इतना लिखकर Program बन जाता है।


2. Simple Syntax

कम Code

ज्यादा काम।


3. Cross Platform

एक ही Program

Windows

Linux

Mac

तीनों पर चल सकता है।


4. Open Source

Free


5. Huge Community

Internet पर लाखों Tutorials हैं।


6. Thousands of Libraries

Example

NumPy

Pandas

TensorFlow

OpenCV

Django

Flask


Section 7 – Python कैसे काम करती है?

जब आप Code लिखते हैं

Python उसे पढ़ती है

Machine Language में बदलती है

Computer उसे Execute करता है।


Flow

You

Python Code

Interpreter

Machine Code

Output


Section 8 – Interpreter क्या होता है?

Interpreter

Code को

Line by Line

चलाता है।


Example

print("A")

print("B")

print("C")

पहले A

फिर B

फिर C


Compiler vs Interpreter

Compiler

पूरा Program पहले Compile करता है।

Interpreter

एक-एक Line चलाता है।

Python

Interpreter Based Language है।


Section 9 – First Python Program

print("Hello World")

Output

Hello World

Explanation

print()

का काम है

Screen पर कुछ दिखाना।


Real World Example

ATM Receipt

आप Button दबाते हैं

Machine Receipt Print करती है

वैसे ही

print()

Screen पर Information दिखाती है।


Section 10 – Why Hello World?

Programming सीखने की शुरुआत

लगभग हर Language में

Hello World से होती है।

यह Tradition बन चुका है।


Practical Applications

आज आपने जो सीखा, उससे आप:

  • Screen पर Output दिखा सकते हैं।

  • समझ सकते हैं कि Programming Language क्या है।

  • Python के उपयोग पहचान सकते हैं।

  • Interpreter का Concept समझ सकते हैं।

  • अपना पहला Python Program लिख सकते हैं।


Key Concepts Summary

  • Python एक High-Level Programming Language है।

  • Python को 1991 में Guido van Rossum ने बनाया।

  • Python सीखने और पढ़ने में आसान है।

  • Python Interpreter आधारित भाषा है।

  • print() का उपयोग Output दिखाने के लिए किया जाता है।

  • Python का उपयोग AI, Machine Learning, Data Science, Web Development, Automation, Cyber Security, Robotics आदि में होता है।


Important Definitions

Programming Language: ऐसी भाषा जिससे हम Computer को Instructions देते हैं।

Python: एक High-Level, Interpreted और General-Purpose Programming Language।

Interpreter: ऐसा Software जो Code को Line-by-Line Execute करता है।

Output: Program के चलने के बाद मिलने वाला परिणाम।

Syntax: Code लिखने के नियम।


Common Mistakes Students Make

  1. Python को Case Sensitive भूल जाना (Print की जगह print लिखना)।

  2. Quotes (" या ') बंद करना भूल जाना।

  3. Brackets () सही से न लगाना।

  4. print और print() में अंतर न समझना।

  5. Error आने पर पूरा Program हटाने की बजाय Error Message न पढ़ना।

  6. एक साथ बहुत कुछ सीखने की कोशिश करना, बिना Practice किए।


Practice Questions (With Answers)

1. Python क्या है?

Answer: एक High-Level Programming Language।

2. Python किसने बनाई?

Answer: Guido van Rossum।

3. Python किस वर्ष जारी हुई?

Answer: 1991।

4. Python Interpreter आधारित है या Compiler आधारित?

Answer: Interpreter आधारित।

5. print() का क्या काम है?

Answer: Screen पर Output दिखाना।

6. Python का उपयोग किन तीन क्षेत्रों में होता है?

Answer: AI, Web Development, Data Science (अन्य सही उदाहरण भी मान्य हैं)।

7. नीचे दिए गए Code का Output क्या होगा?

print("Python")

Answer:

Python

8. Python में Syntax का क्या अर्थ है?

Answer: Code लिखने के नियम।

9. क्या Python Free और Open Source है?

Answer: हाँ।

10. Python का नाम किससे प्रेरित है?

Answer: Monty Python's Flying Circus नाम के Comedy Show से।


यह Part 1 (Introduction to Python) पूरा हुआ।

अगला Part 2 में हम Python Installation, VS Code Setup, First Project, Comments, Variables और Input Function को उसी विस्तार और आसान शैली में सीखेंगे।

Python Complete Course

Part 2 – Python Installation, VS Code Setup, First Project, Comments, Variables & Input Function

Level: Beginner
Goal: इस Part के बाद आप Python Install करना, पहला Program बनाना, Variables का उपयोग करना और User से Input लेना सीख जाएंगे।


Section 1 – Python Install करना

Python सीखने के लिए सबसे पहले इसे अपने Computer में Install करना होगा।

Step 1

Python की Official Website पर जाएँ।

https://python.org

Step 2

अपने Operating System (Windows, Mac या Linux) के अनुसार Python Download करें।

Step 3

Installer को Run करें।

सबसे महत्वपूर्ण Step:

Add Python to PATH पर ✔️ जरूर करें।

फिर

Install Now पर Click करें।


Real Life Example

मान लीजिए आपने नया Mobile खरीदा।

उसमें WhatsApp चलाने के लिए पहले WhatsApp Install करना पड़ता है।

ठीक उसी तरह Python में Programming करने के लिए पहले Python Install करना पड़ता है।


Section 2 – VS Code Install करना

Python Code लिखने के लिए हमें एक Editor चाहिए।

सबसे लोकप्रिय Editor है

Visual Studio Code (VS Code)


Installation

  1. VS Code Download करें।

  2. Install करें।

  3. Open करें।

  4. Python Extension Install करें।


Python Extension क्यों?

VS Code को Python समझने के लिए Extension चाहिए।

इसके बिना Code Highlight नहीं होगा।

Auto Suggestion भी नहीं मिलेगी।


Real Life Example

VS Code एक खाली Notebook की तरह है।

Python Extension उस Notebook में Teacher की तरह है जो गलतियाँ बताता है।


Section 3 – पहला Python Project बनाना

अब हम अपना पहला Project बनाएँगे।

Folder बनाइए

Python Course

इसके अंदर File बनाइए

lecture1.py

अब लिखिए

print("Hello World")

Run कीजिए।

Output

Hello World

Practical Tip

File Name में Space न रखें।

✔ Good

student.py

❌ Bad

student file.py

Section 4 – Python File Extension (.py)

Python की प्रत्येक File का Extension होता है

.py

Example

hello.py

student.py

calculator.py

Real Life Example

जैसे Photo की Extension

.jpg

.png

Video की

.mp4

वैसे Python की

.py

Section 5 – Comments क्या होते हैं?

Comment वह Text होता है जिसे Python Ignore कर देती है।

Comments Programmer के लिए होते हैं।

Computer उन्हें Execute नहीं करता।


Single Line Comment

# This is comment

print("Hello")

Output

Hello

Multi Line Comment

Python में अक्सर Multi-line Notes के लिए Triple Quotes (""" ... """) का उपयोग किया जाता है।

"""
Student Management System

Version 1

Author Ajay
"""

print("Hello")

Real Life Example

School की Notebook में आप Notes लिखते हैं।

Exam में Teacher Notes नहीं पढ़ता।

उसी तरह Python Comments को Execute नहीं करती।


Section 6 – Variables क्या होते हैं?

यह Python का सबसे महत्वपूर्ण Topic है।

Definition

Variable एक Container होता है जिसमें Data Store किया जाता है।


Real Life Example

घर में पानी रखने के लिए Bottle होती है।

तेल रखने के लिए Bottle होती है।

चावल रखने के लिए डिब्बा होता है।

Container बदल सकता है।

अंदर का सामान भी बदल सकता है।

Variable भी बिल्कुल ऐसा ही है।


Example

name = "Ajay"

print(name)

Output

Ajay

यहाँ

name

Variable है।

Ajay

Value है।


Section 7 – Variable कैसे काम करता है?

city = "Patna"

print(city)

Output

Patna

अब Value बदल दी।

city = "Delhi"

print(city)

Output

Delhi

Variable की Value बदली जा सकती है।


Real Life Example

मान लीजिए

एक Glass है।

पहले उसमें पानी है।

फिर आपने पानी निकालकर Juice भर दिया।

Glass वही रहा।

अंदर की चीज बदल गई।

Variable भी ऐसा ही होता है।


Section 8 – Variable Naming Rules

सही नाम

student

student_name

student1

age

salary

total_marks

गलत नाम

1student

student-name

student name

class

Rules

✔ Name Number से शुरू नहीं होगा।

✔ Space नहीं होगा।

✔ Hyphen (-) नहीं होगा।

✔ Python Keywords का उपयोग नहीं करेंगे।


Section 9 – Keywords

Keywords वे शब्द हैं जिनका Python में पहले से Special Meaning होता है।

Example

if

else

while

for

class

return

import

इन्हें Variable नहीं बना सकते।


Section 10 – Data क्या होता है?

Python में मुख्यतः Data Types:

  • Integer (पूर्ण संख्या)

  • Float (दशमलव संख्या)

  • String (Text)

  • Boolean (True/False)

उदाहरण:

age = 20          # Integer
price = 99.99     # Float
name = "Ajay"     # String
is_student = True # Boolean

Section 11 – print() में Variable

name = "Ajay"

print(name)

Output

Ajay

Multiple Variables

name = "Ajay"

age = 20

print(name)

print(age)

Output

Ajay

20

Section 12 – User से Input लेना

Python में Input लेने के लिए

input()

Function का उपयोग करते हैं।


Example

name = input("Enter Your Name : ")

print(name)

यदि User लिखता है

Ajay

Output

Ajay

Real Life Example

Teacher पूछते हैं—

"तुम्हारा नाम क्या है?"

Student जवाब देता है—

"Ajay"

यही काम input() करता है।


Section 13 – Input के साथ Message

city = input("Enter City : ")

print(city)

User

Patna

Output

Patna

Section 14 – Program बनाते हैं

name = input("Enter Name : ")

age = input("Enter Age : ")

city = input("Enter City : ")

print("Name :", name)

print("Age :", age)

print("City :", city)

Output (उदाहरण)

Enter Name : Ajay
Enter Age : 20
Enter City : Patna

Name : Ajay
Age : 20
City : Patna

Practical Application

इस ज्ञान से आप बना सकते हैं:

  • Student Information System

  • Employee Form

  • Hospital Registration

  • School Admission Form

  • ATM User Information

  • Login Form (Basic)

  • Survey Form


Key Concepts Summary

  • Python और VS Code Install करना।

  • .py Extension वाली File बनाना।

  • print() से Output दिखाना।

  • # और """...""" का उपयोग करके Comments लिखना।

  • Variables में Data Store करना।

  • अच्छे Variable Names के Rules समझना।

  • input() से User से Data लेना।

  • Integer, Float, String और Boolean का परिचय।


Important Definitions

Variable: Data Store करने वाला नामित Container।

Comment: ऐसा Text जिसे Python Execute नहीं करती।

Keyword: Python का Reserved Word जिसे Variable Name नहीं बना सकते।

Input: User से Program में Data लेना।

Output: Program द्वारा दिखाया गया परिणाम।

String: Quotes (" " या ' ') के अंदर लिखा गया Text।


Common Mistakes Students Make

  1. = (Assignment) और == (Comparison) में भ्रम करना।

  2. Variable Name की शुरुआत Number से करना (1name)।

  3. Variable Name में Space देना (student name)।

  4. Quotes लगाना भूल जाना (name = Ajay)।

  5. print(name) की जगह print("name") लिख देना, जिससे Variable की Value की बजाय "name" Text छपता है।

  6. input() से मिली Value को हमेशा Text (String) समझे बिना सीधे गणना करने की कोशिश करना।

  7. File को .py की बजाय .txt में Save कर देना।


Practice Questions (With Answers)

1. Python File का Extension क्या होता है?

Answer: .py

2. Comment लिखने के लिए कौन-सा Symbol उपयोग किया जाता है?

Answer: #

3. Variable क्या है?

Answer: Data Store करने वाला नामित Container।

4. User से Input लेने के लिए कौन-सा Function उपयोग होता है?

Answer: input()

5. नीचे दिए गए Code का Output क्या होगा?

name = "Ajay"
print(name)

Answer:

Ajay

6. क्या student_name एक Valid Variable Name है?

Answer: हाँ।

7. क्या 1student एक Valid Variable Name है?

Answer: नहीं, क्योंकि Variable Name Number से शुरू नहीं हो सकता।

8. True और False किस Data Type के उदाहरण हैं?

Answer: Boolean।

9. input() से मिली Value का Default Data Type क्या होता है?

Answer: String (str)।

10. ऐसा एक Program लिखिए जो User का नाम लेकर उसे Print करे।

Answer:

name = input("Enter Your Name: ")
print("Hello,", name)

🎯 Homework (ज़रूर करें)

  1. ऐसा Program लिखें जो User से Name, Age, School और Mobile Number लेकर Screen पर दिखाए।

  2. पाँच अलग-अलग Variables बनाइए और उनकी Values Print कीजिए।

  3. कम से कम पाँच Single-line Comments और एक Multi-line Comment लिखकर Practice करें।


अगले Part 3 में हम Data Types (Integer, Float, String, Boolean), Type Conversion (int(), float(), str()), Operators (Arithmetic, Assignment, Comparison, Logical) और Expression Evaluation को बहुत आसान उदाहरणों और Practical Programs के साथ सीखेंगे।

🐍 Python Complete Course

Part 3 – Data Types, Type Conversion & Operators

Level: Beginner
Duration: 45–60 Minutes
Goal: इस Chapter के बाद आप Python में Data Types, Type Conversion और सभी Basic Operators आसानी से समझ जाएंगे।


📚 आज हम क्या सीखेंगे?

  • Data Types क्या होते हैं?

  • Integer

  • Float

  • String

  • Boolean

  • type() Function

  • Type Conversion

  • Arithmetic Operators

  • Assignment Operators

  • Comparison Operators

  • Logical Operators

  • Operator Precedence

  • Real World Programs


Section 1 – Data Type क्या होता है?

आसान भाषा में

Data Type यह बताता है कि Variable के अंदर किस प्रकार का Data रखा गया है।

उदाहरण

अगर आपके घर में चार अलग-अलग डिब्बे हैं—

🥛 दूध

🍚 चावल

💧 पानी

🍬 चीनी

हर डिब्बे में अलग चीज रखी जाती है।

ठीक उसी तरह Python भी अलग-अलग प्रकार का Data अलग-अलग Data Types में रखती है।


Real Life Analogy

मान लीजिए बैंक में चार प्रकार की जानकारी होती है।

नाम

Ajay Kumar

उम्र

22

बैंक बैलेंस

15000.75

Loan Approved

True

देखिए...

चारों Data अलग प्रकार के हैं।

इन्हीं को Python Data Types कहती है।


Section 2 – Integer (int)

Definition

जिस संख्या में Decimal नहीं होता उसे Integer कहते हैं।


Examples

age = 20

marks = 450

salary = 15000

Negative Integer

temperature = -5

Output

print(age)
20

Real Life Example

School में Roll Number

25

Bank Account में कुल Transaction

150

Mobile Contacts

500

सब Integer हैं।


Section 3 – Float

Definition

जिस संख्या में Decimal Point हो उसे Float कहते हैं।


Examples

price = 99.99

height = 5.8

weight = 65.4

Output

print(price)
99.99

Real Life Example

Petrol

2.5 Liter

Temperature

36.5°C

Bank Interest

7.25%

ये सभी Float हैं।


Section 4 – String (str)

Definition

Quotes के अंदर लिखा गया Text String कहलाता है।


Examples

name = "Ajay"

city = "Patna"

country = "India"

Output

print(name)
Ajay

Real Life Example

Student Name

Address

Email

Password

सब String होते हैं।


Section 5 – Boolean (bool)

Definition

Boolean केवल दो Values रखता है।

True

False

Example

is_student = True

is_married = False

Output

print(is_student)
True

Real Life Example

Door Open?

Yes

No

Python में

True

False

Section 6 – type() Function

किसी Variable का Data Type जानने के लिए

type()

का उपयोग करते हैं।


Example

age = 20

print(type(age))

Output

<class 'int'>

Example

price = 99.99

print(type(price))

Output

<class 'float'>

Example

name = "Ajay"

print(type(name))

Output

<class 'str'>

Example

student = True

print(type(student))

Output

<class 'bool'>

Section 7 – Type Conversion

कभी-कभी हमें एक Data Type को दूसरे Data Type में बदलना पड़ता है।

इसे कहते हैं

Type Conversion


String → Integer

age = "20"

age = int(age)

print(age)

Output

20

String → Float

price = "45.8"

price = float(price)

Integer → String

number = 100

number = str(number)

Float → Integer

marks = 95.75

marks = int(marks)

Output

95

ध्यान दें: int() दशमलव भाग हटा देता है, Round नहीं करता।


Real Life Example

मान लीजिए किसी Form में आपकी उम्र "20" (Text) के रूप में आई।

अगर हमें 5 साल जोड़ने हैं तो पहले उसे Number बनाना होगा।

age = int("20")

print(age + 5)

Output

25

Section 8 – Arithmetic Operators

इनका उपयोग गणितीय Calculation के लिए किया जाता है।

OperatorMeaningExample
+Addition5 + 3
-Subtraction5 - 3
*Multiplication5 * 3
/Division10 / 2
//Floor Division10 // 3
%Modulus10 % 3
**Power2 ** 3

Example

a = 10
b = 3

print(a + b)
print(a - b)
print(a * b)
print(a / b)
print(a // b)
print(a % b)
print(a ** b)

Output

13
7
30
3.333333333
3
1
1000

Real Life Example

अगर आपके पास ₹100 हैं और आपने ₹30 खर्च किए।

money = 100 - 30

Section 9 – Assignment Operators

x = 10

x += 5

print(x)

Output

15

अन्य Operators

+=

-=

*=

/=

%=

//=

**=

Section 10 – Comparison Operators

इनका Result हमेशा Boolean होता है।

OperatorMeaning
==Equal
!=Not Equal
>Greater
<Smaller
>=Greater Equal
<=Smaller Equal

Example

print(10 > 5)

print(10 == 5)

print(10 != 5)

Output

True

False

True

Real Life Example

Exam Pass?

Marks >= 33

अगर Marks 40 हैं

Output

True

Section 11 – Logical Operators

तीन Logical Operators होते हैं।

and

or

not

Example

print(True and False)

Output

False

Example

print(True or False)

Output

True

Example

print(not True)

Output

False

Real Life Example

College Admission

Condition

Age > 18

AND

12th Pass

दोनों सही होंगे तभी Admission मिलेगा।


Section 12 – Operator Precedence

Python भी BODMAS जैसा Rule Follow करता है।

क्रम:

  1. ()

  2. **

  3. * / // %

  4. + -

  5. Comparison Operators

  6. Logical Operators


Example

print(2 + 3 * 4)

Output

14

पहले

3 × 4

फिर

2 + 12

Section 13 – Practical Program

Student Percentage

math = 80
science = 90
english = 85

total = math + science + english

percentage = total / 3

print(total)
print(percentage)

Output

255
85.0

Practical Program 2

Area of Rectangle

length = float(input("Length : "))

width = float(input("Width : "))

area = length * width

print(area)

Practical Program 3

Simple Interest

Formula

SI = (P × R × T) / 100

Program

p = float(input("Principal: "))
r = float(input("Rate: "))
t = float(input("Time: "))

si = (p * r * t) / 100

print("Simple Interest =", si)

Key Concepts Summary

  • Data Types Data की प्रकृति बताते हैं।

  • int पूर्ण संख्या के लिए है।

  • float दशमलव संख्या के लिए है।

  • str Text के लिए है।

  • bool केवल True या False रखता है।

  • type() से Variable का Data Type पता चलता है।

  • int(), float(), str() से Type Conversion किया जाता है।

  • Arithmetic Operators गणना के लिए उपयोग होते हैं।

  • Comparison Operators True या False लौटाते हैं।

  • Logical Operators कई Conditions को जोड़ते हैं।

  • Operator Precedence के कारण कुछ Operations पहले Execute होते हैं।


Important Definitions

Data Type: Data की Category।

Type Conversion: एक Data Type को दूसरे Data Type में बदलना।

Operator: ऐसा Symbol जो Operation करता है।

Operand: जिस Value पर Operation होता है।

Boolean: ऐसा Data Type जिसमें केवल True और False होते हैं।


Common Mistakes Students Make

  1. = और == में भ्रम करना।

  2. "20" + 5 जैसा Code लिखना (String और Integer को सीधे जोड़ना)।

  3. int("20.5") लिखना, जिससे Error आता है।

  4. 10 / 3 और 10 // 3 में अंतर न समझना।

  5. % (Modulus) का अर्थ केवल Percentage समझ लेना, जबकि यह Remainder देता है।

  6. True और "True" (String) में अंतर न समझना।

  7. Operator Precedence भूल जाना और बिना Brackets के गलत Result की उम्मीद करना।


Practice Questions (With Answers)

1. Integer और Float में क्या अंतर है?

Answer: Integer में Decimal नहीं होता, Float में Decimal होता है।

2. "Hello" किस Data Type का उदाहरण है?

Answer: String (str)।

3. type(10.5) का Output क्या होगा?

Answer: <class 'float'>

4. "25" को Integer में कैसे बदलेंगे?

Answer:

int("25")

5. 10 % 3 का Output क्या होगा?

Answer: 1

6. 2 ** 4 का Output क्या होगा?

Answer: 16

7. 10 == 10 का Result क्या होगा?

Answer: True

8. True and False का Result क्या होगा?

Answer: False

9. not False का Result क्या होगा?

Answer: True

10. नीचे दिए गए Code का Output क्या होगा?

a = 5
b = 2

print(a * b + 3)

Answer:

13

🎯 Homework

  1. User से दो Numbers लेकर उनका Addition, Subtraction, Multiplication, Division, Floor Division, Modulus और Power निकालने वाला Program बनाइए।

  2. User से Length और Width लेकर Rectangle का Area और Perimeter निकालिए।

  3. User से Principal, Rate और Time लेकर Simple Interest निकालिए।

  4. पाँच अलग-अलग Variables बनाकर type() Function से उनका Data Type Print कीजिए।

  5. and, or और not का उपयोग करके तीन छोटे Programs बनाइए।


📌 अगले Part 4 में हम सीखेंगे:

  • Strings (Complete Mastery)

  • String Indexing

  • String Slicing

  • Negative Indexing

  • String Functions (len(), upper(), lower(), replace(), find(), count() आदि)

  • Escape Sequences

  • String Formatting (f-strings)

  • लगभग 20+ Practical Programs और 50+ Practice Questions

यह Python के सबसे महत्वपूर्ण Chapters में से एक होगा, खासकर यदि आगे चलकर आपको Data Science, Machine Learning या AI सीखनी है।


🐍 Python Complete Course

Part 4 – Strings (Complete Mastery)

Level: Beginner → Intermediate
Duration: 60–90 Minutes
Goal: इस Chapter के बाद आप Python में Strings को Professional Level तक समझ जाएंगे। यह Chapter Data Science, Machine Learning, AI और Web Development के लिए बहुत महत्वपूर्ण है।


📚 आज हम क्या सीखेंगे?

  • String क्या है?

  • String कैसे बनाते हैं?

  • Single, Double और Triple Quotes

  • String Indexing

  • Negative Indexing

  • String Slicing

  • Slice Step

  • Escape Sequence Characters

  • String Concatenation

  • String Repetition

  • len() Function

  • String Methods (upper(), lower(), title(), strip(), replace(), find(), count(), startswith(), endswith(), split(), join())

  • f-Strings

  • Practical Programs


Section 1 – String क्या है?

आसान भाषा में

String का मतलब है Characters (Letters, Numbers, Symbols और Spaces) का समूह

Python में String हमेशा Quotes (" " या ' ') के अंदर लिखी जाती है।


उदाहरण

name = "Ajay"

city = "Patna"

message = "Welcome to Python"

Real Life Example

मान लीजिए आपके मोबाइल में आपका नाम सेव है।

Ajay Kumar

यह Text है।

Python इसे String कहती है।


Section 2 – String कैसे बनाते हैं?

Single Quotes

name = 'Ajay'

Double Quotes

name = "Ajay"

Triple Quotes

message = """
Welcome

to

Python
"""

Triple Quotes का उपयोग Multi-line Text के लिए किया जाता है।


Section 3 – String Indexing

Python में हर Character का एक Position Number होता है।

Example

name = "Python"
CharacterPython
Index012345

पहला Character

print(name[0])

Output

P

तीसरा Character

print(name[2])

Output

t

Real Life Example

Train की Seats की तरह।

Seat Number 1

Seat Number 2

Seat Number 3

वैसे ही Characters की भी Position होती है।


Section 4 – Negative Indexing

Python पीछे से भी Characters निकाल सकता है।

Python
CharacterPython
Positive012345
Negative-6-5-4-3-2-1

Example

print(name[-1])

Output

n

print(name[-2])

Output

o

Section 5 – String Slicing

Slicing का मतलब है String का कुछ हिस्सा निकालना।

Syntax

string[start:end]

Example

name = "Python"

print(name[0:3])

Output

Pyt

Example

print(name[2:6])

Output

thon

अगर End नहीं देंगे

print(name[2:])

Output

thon

अगर Start नहीं देंगे

print(name[:4])

Output

Pyth

पूरी String

print(name[:])

Output

Python

Section 6 – Slice Step

Syntax

string[start:end:step]

Example

text = "PYTHON"

print(text[0:6:2])

Output

PTO

Reverse String

print(text[::-1])

Output

NOHTYP

Real Life Example

मान लीजिए Line में 10 लोग खड़े हैं।

आप हर दूसरे व्यक्ति को चुनते हैं।

यही Step कहलाता है।


Section 7 – Escape Sequence Characters

कुछ Special Characters को लिखने के लिए Escape Sequence का उपयोग होता है।


New Line

print("Hello\nWorld")

Output

Hello
World

Tab

print("Python\tCourse")

Output

Python    Course

Quotes

print("He said \"Hello\"")

Output

He said "Hello"

Backslash

print("C:\\Users\\Ajay")

Output

C:\Users\Ajay

Section 8 – String Concatenation

दो Strings को जोड़ना।

first = "Ajay"

last = "Kumar"

print(first + " " + last)

Output

Ajay Kumar

Real Life Example

First Name + Last Name = Full Name


Section 9 – String Repetition

print("Python " * 3)

Output

Python Python Python

Section 10 – len() Function

String की कुल Length बताता है।

name = "Python"

print(len(name))

Output

6

Section 11 – upper() और lower()

name = "python"

print(name.upper())

Output

PYTHON

name = "PYTHON"

print(name.lower())

Output

python

Section 12 – title()

text = "welcome to python"

print(text.title())

Output

Welcome To Python

Section 13 – strip()

Extra Spaces हटाता है।

text = "   Python   "

print(text.strip())

Output

Python

Section 14 – replace()

text = "I like Java"

print(text.replace("Java", "Python"))

Output

I like Python

Section 15 – find()

Character या Word की Position बताता है।

text = "Python"

print(text.find("h"))

Output

3

अगर Text नहीं मिला

-1

Section 16 – count()

कितनी बार आया?

text = "banana"

print(text.count("a"))

Output

3

Section 17 – startswith()

text = "Python"

print(text.startswith("Py"))

Output

True

Section 18 – endswith()

text = "notes.pdf"

print(text.endswith(".pdf"))

Output

True

Section 19 – split()

Sentence को List में बदल देता है।

text = "Python Java C"

print(text.split())

Output

['Python', 'Java', 'C']

Section 20 – join()

List को String में जोड़ता है।

words = ["I", "Love", "Python"]

print(" ".join(words))

Output

I Love Python

Section 21 – f-Strings (सबसे आधुनिक तरीका)

पुराना तरीका

name = "Ajay"

age = 22

print("My name is", name, "and age is", age)

Modern तरीका

name = "Ajay"

age = 22

print(f"My name is {name} and I am {age} years old.")

Output

My name is Ajay and I am 22 years old.

Real Life Example

School ID Card

Name: Ajay
Class: 10
Roll: 25

हर जगह Variable की Value अपने आप भर जाती है।


Practical Program 1 – Full Name

first = input("First Name: ")

last = input("Last Name: ")

print(f"Full Name: {first} {last}")

Practical Program 2 – Username Generator

name = input("Name: ")

year = input("Birth Year: ")

print(name.lower() + year)

Practical Program 3 – Email Checker

email = input("Enter Email: ")

print(email.endswith("@gmail.com"))

Practical Program 4 – Word Counter

sentence = input("Enter Sentence: ")

print("Characters:", len(sentence))

Key Concepts Summary

  • String Text Data को Store करती है।

  • Indexing 0 से शुरू होती है।

  • Negative Indexing पीछे से शुरू होती है।

  • Slicing से String का हिस्सा निकाला जाता है।

  • len() Length बताता है।

  • upper() बड़े अक्षरों में बदलता है।

  • lower() छोटे अक्षरों में बदलता है।

  • replace() Text बदलता है।

  • find() Position बताता है।

  • count() गिनती करता है।

  • split() String को List में बदलता है।

  • join() List को String में जोड़ता है।

  • f-string Variables को आसानी से Text में शामिल करने का आधुनिक तरीका है।


Important Definitions

String: Characters का समूह जो Quotes में लिखा जाता है।

Index: किसी Character की Position।

Slicing: String का एक भाग निकालना।

Escape Sequence: Special Characters (\n, \t, \", \\) लिखने का तरीका।

Concatenation: दो या अधिक Strings को जोड़ना।

f-String: f"..." का उपयोग करके Variables को सीधे String में जोड़ना।


Common Mistakes Students Make

  1. String Indexing में 1 से गिनती शुरू करना (Python में Index 0 से शुरू होता है)।

  2. name[6] जैसे Invalid Index का उपयोग करना, जिससे IndexError आता है।

  3. find() और index() (आगे सीखेंगे) में अंतर न समझना।

  4. replace() Original String को नहीं बदलता, बल्कि नई String लौटाता है।

  5. strip() केवल शुरुआत और अंत की Spaces हटाता है, बीच की नहीं।

  6. split() का Result List होता है, String नहीं।

  7. Quotes बंद करना भूल जाना।


Practice Questions (With Answers)

1. String क्या है?

Answer: Characters का समूह जो Quotes में लिखा जाता है।

2. "Python" में h का Index क्या है?

Answer: 3

3. "Python"[-1] का Output क्या होगा?

Answer: n

4. len("Python") का Output क्या होगा?

Answer: 6

5. "python".upper() का Output क्या होगा?

Answer: PYTHON

6. "HELLO".lower() का Output क्या होगा?

Answer: hello

7. "banana".count("a") का Output क्या होगा?

Answer: 3

8. "Python".startswith("Py") का Output क्या होगा?

Answer: True

9. "notes.pdf".endswith(".pdf") का Output क्या होगा?

Answer: True

10. नीचे दिए गए Code का Output क्या होगा?

text = "Python"
print(text[::-1])

Answer:

nohtyP

ध्यान दें: Python में "Python" का Reverse "nohtyP" होता है। पहला अक्षर अंत में जाता है और उसका मूल Case (Upper/Lower) वही रहता है।


🎯 Homework

  1. User से नाम लेकर उसे UPPERCASE, lowercase और Title Case में Print करें।

  2. User से एक Sentence लेकर उसमें Characters की संख्या (len) और Words की संख्या (split) निकालें।

  3. ऐसा Program लिखें जो Email .com या .in से समाप्त होती है या नहीं, यह बताए।

  4. किसी String को Reverse करके Print करें।

  5. User से Full Name लेकर उसे firstname.lastname@gmail.com जैसे Format में बदलें (Basic Username Generator)।


📌 अगले Part 5 में हम सीखेंगे:

  • Input Handling (Advanced)

  • Type Casting in User Input

  • If–Else Statements

  • Nested If

  • elif

  • Short-hand If

  • Ternary Operator

  • 25+ Real World Decision Making Programs (Voting Eligibility, ATM, Grade System, Discount Calculator, Login System आदि)

यह Chapter Programming Logic की असली शुरुआत है और आगे Loops तथा Projects के लिए बहुत महत्वपूर्ण होगा।


🐍 Python Complete Course

Part 5 – User Input, Type Casting, if-else, Nested if, elif & Decision Making

Level: Beginner → Intermediate
Duration: 90–120 Minutes
Goal: इस Chapter के बाद आप ऐसे Programs बना पाएंगे जो User के Input के अनुसार अलग-अलग निर्णय (Decision) लें। यही Programming की असली शुरुआत है।


📚 आज हम क्या सीखेंगे?

  • User Input (Revision)

  • Type Casting

  • Why Type Casting is Important?

  • if Statement

  • if-else

  • elif

  • Nested if

  • Multiple Conditions

  • Ternary Operator

  • Real World Programs


Section 1 – Decision Making क्या है?

आसान भाषा में

Decision Making का मतलब है Condition के आधार पर अलग-अलग काम करना।

Real Life Example

अगर बारिश हो रही है

➡️ छाता लेकर जाओ

अगर बारिश नहीं हो रही

➡️ छाता मत ले जाओ

यही Logic Computer में if-else कहलाता है।


Section 2 – User Input (Revision)

name = input("Enter Your Name: ")

print(name)

यदि User लिखता है

Ajay

Output

Ajay

Section 3 – Type Casting क्यों जरूरी है?

मान लीजिए User ने Age लिखी

20

लेकिन input() हमेशा String देता है।

age = input("Age: ")

print(type(age))

Output

<class 'str'>

अगर हम लिखें

age = input("Age: ")

print(age + 5)

तो Error आएगा।


सही तरीका

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

print(age + 5)

Output

25

Real Life Example

अगर किसी Form में आपकी उम्र Text के रूप में आई है, लेकिन Calculation करनी है, तो पहले उसे Number बनाना होगा।


Section 4 – if Statement

Definition

यदि Condition True है, तो Code चलेगा।


Syntax

if condition:
    code

Example

age = 20

if age >= 18:
    print("You Can Vote")

Output

You Can Vote

Flow Diagram

Condition

↓

True

↓

Code Run

↓

End

Section 5 – Indentation

Python में Space बहुत महत्वपूर्ण है।

if True:
    print("Hello")

यहाँ चार Space हैं।


❌ गलत

if True:
print("Hello")

Error आएगा।


Real Life Example

जैसे Paragraph में लाइन सही जगह से शुरू होती है।

वैसे Python में Code भी सही जगह से शुरू होना चाहिए।


Section 6 – if-else

अगर Condition False हो जाए तो?

तब else चलता है।


Syntax

if condition:
    code
else:
    code

Example

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

if age >= 18:
    print("Eligible")
else:
    print("Not Eligible")

Output 1

Age: 22

Eligible

Output 2

Age: 15

Not Eligible

Real Life Example

ATM में

अगर PIN सही है

➡️ Login

नहीं तो

➡️ Wrong PIN


Section 7 – elif

जब दो से ज्यादा Conditions हों।


Syntax

if condition:
    code

elif condition:
    code

else:
    code

Example

marks = int(input("Marks: "))

if marks >= 90:
    print("Grade A")

elif marks >= 75:
    print("Grade B")

elif marks >= 60:
    print("Grade C")

else:
    print("Fail")

Output

Marks: 82

Grade B

Section 8 – Nested if

एक if के अंदर दूसरा if।


Example

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

citizen = input("Citizen (yes/no): ")

if age >= 18:

    if citizen == "yes":
        print("Eligible")

    else:
        print("Citizen Required")

else:
    print("Age Less Than 18")

Real Life Example

Job Interview

पहले Graduation Check

अगर Graduation है

फिर Experience Check

अगर Experience है

तो Selection


Section 9 – Multiple Conditions

AND

दोनों सही होने चाहिए।

age = 20

license = True

if age >= 18 and license:
    print("Can Drive")

OR

कोई एक सही होना चाहिए।

rain = True

holiday = False

if rain or holiday:
    print("Stay Home")

NOT

True को False बना देता है।

logged_in = False

if not logged_in:
    print("Please Login")

Section 10 – Ternary Operator

एक लाइन में if-else।


Normal

if age >= 18:
    print("Adult")
else:
    print("Minor")

Ternary

print("Adult" if age >= 18 else "Minor")

Practical Program 1 – Even or Odd

number = int(input("Enter Number: "))

if number % 2 == 0:
    print("Even")
else:
    print("Odd")

Practical Program 2 – Positive, Negative or Zero

number = int(input("Enter Number: "))

if number > 0:
    print("Positive")

elif number < 0:
    print("Negative")

else:
    print("Zero")

Practical Program 3 – Largest Number

a = int(input("A: "))
b = int(input("B: "))

if a > b:
    print("A is Largest")
else:
    print("B is Largest")

Practical Program 4 – Pass or Fail

marks = int(input("Marks: "))

if marks >= 33:
    print("Pass")
else:
    print("Fail")

Practical Program 5 – Grade System

marks = int(input("Marks: "))

if marks >= 90:
    print("A+")

elif marks >= 80:
    print("A")

elif marks >= 70:
    print("B")

elif marks >= 60:
    print("C")

elif marks >= 33:
    print("D")

else:
    print("Fail")

Practical Program 6 – Login System

username = input("Username: ")
password = input("Password: ")

if username == "admin" and password == "1234":
    print("Login Successful")
else:
    print("Invalid Username or Password")

Practical Program 7 – ATM Withdrawal

balance = 10000

amount = int(input("Enter Amount: "))

if amount <= balance:
    balance = balance - amount
    print("Remaining Balance:", balance)
else:
    print("Insufficient Balance")

Practical Program 8 – Discount Calculator

amount = float(input("Shopping Amount: "))

if amount >= 5000:
    discount = amount * 0.20

elif amount >= 3000:
    discount = amount * 0.10

else:
    discount = 0

print("Discount:", discount)
print("Final Amount:", amount - discount)

Practical Program 9 – Voting Eligibility

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

if age >= 18:
    print("Eligible for Voting")
else:
    print("Not Eligible")

Practical Program 10 – Leap Year Checker

year = int(input("Enter Year: "))

if (year % 400 == 0) or (year % 4 == 0 and year % 100 != 0):
    print("Leap Year")
else:
    print("Not a Leap Year")

🎯 Mini Project – Student Result System

name = input("Student Name: ")
marks = int(input("Marks: "))

if marks >= 90:
    grade = "A+"

elif marks >= 80:
    grade = "A"

elif marks >= 70:
    grade = "B"

elif marks >= 60:
    grade = "C"

elif marks >= 33:
    grade = "D"

else:
    grade = "Fail"

print("----------------------")
print("Student:", name)
print("Marks:", marks)
print("Grade:", grade)

Key Concepts Summary

  • input() से User का Data लिया जाता है।

  • int(), float() आदि से Type Casting की जाती है।

  • if केवल Condition True होने पर चलता है।

  • if-else में True और False दोनों स्थितियों को Handle किया जाता है।

  • elif कई Conditions के लिए उपयोग होता है।

  • Nested if में एक if के अंदर दूसरा if होता है।

  • and, or, not से Multiple Conditions बनाई जाती हैं।

  • Ternary Operator एक लाइन में Decision लेने का तरीका है।


Important Definitions

Condition: ऐसा Expression जिसका Result True या False होता है।

if Statement: Condition True होने पर Code Execute करता है।

else: Condition False होने पर Code Execute करता है।

elif: कई Conditions को क्रम से Check करने के लिए उपयोग होता है।

Nested if: एक if के अंदर दूसरा if

Indentation: Python में Code Block को दिखाने के लिए Space का उपयोग।


Common Mistakes Students Make

  1. = की जगह == का उपयोग भूल जाना।

  2. input() से मिली Value को int() में Convert किए बिना गणना करना।

  3. if के बाद : (Colon) लगाना भूल जाना।

  4. Indentation (Spaces) गलत करना।

  5. elif की जगह बार-बार अलग if लिख देना, जिससे Logic बदल जाता है।

  6. and और or में अंतर न समझना।

  7. Comparison Operators (>, <, >=, <=, ==, !=) का गलत उपयोग करना।


Practice Questions (With Answers)

1. if Statement का उपयोग कब किया जाता है?

Answer: जब Condition True होने पर Code चलाना हो।

2. else कब चलता है?

Answer: जब if की Condition False हो।

3. elif का उपयोग क्यों किया जाता है?

Answer: दो से अधिक Conditions Check करने के लिए।

4. and Operator कब True देता है?

Answer: जब दोनों Conditions True हों।

5. or Operator कब True देता है?

Answer: जब कम से कम एक Condition True हो।

6. not True का Result क्या होगा?

Answer: False

7. 18 >= 18 का Result क्या होगा?

Answer: True

8. नीचे दिए गए Code का Output क्या होगा?

age = 16

if age >= 18:
    print("Adult")
else:
    print("Minor")

Answer:

Minor

9. Ternary Operator का उपयोग किसलिए होता है?

Answer: एक लाइन में if-else लिखने के लिए।

10. Leap Year Check करने के लिए कौन-कौन से Operators उपयोग किए गए?

Answer: %, ==, !=, and, or


🎯 Homework

  1. User से तीन Numbers लेकर सबसे बड़ा Number निकालिए।

  2. User से Username और Password लेकर Login System बनाइए।

  3. Electricity Bill Calculator बनाइए (अपनी Rate तय करें)।

  4. BMI Calculator बनाकर बताइए कि व्यक्ति Underweight, Normal, Overweight या Obese है।

  5. ऐसा Program बनाइए जो User की Age और Gender के आधार पर किसी योजना के लिए Eligibility बताए।


📌 अगले Part 6 में हम सीखेंगे:

  • Loops (for Loop और while Loop)

  • range() Function

  • Nested Loops

  • break, continue, pass

  • Pattern Printing (⭐, Number, Alphabet Patterns)

  • Prime Number

  • Factorial

  • Fibonacci Series

  • Multiplication Table

  • 30+ Real World Programs और 100+ Practice Questions

यह Chapter Programming का सबसे महत्वपूर्ण हिस्सा है, क्योंकि यहीं से आप Repeat होने वाले कामों को Automation के साथ करना सीखेंगे।


🐍 Python Complete Course

Part 6 – Loops (for Loop, while Loop, range(), Nested Loops, break, continue, pass)

Level: Beginner → Intermediate
Duration: 2–3 Hours
Goal: इस Chapter के बाद आप ऐसे Programs बना पाएंगे जो एक ही काम को बार-बार अपने आप करें। Loops हर Programming Language का सबसे महत्वपूर्ण Concept है।


📚 आज हम क्या सीखेंगे?

  • Loop क्या होता है?

  • for Loop

  • while Loop

  • range() Function

  • Nested Loops

  • break Statement

  • continue Statement

  • pass Statement

  • Infinite Loop

  • Real World Examples

  • Practical Programs


Section 1 – Loop क्या होता है?

आसान भाषा में

Loop का मतलब है किसी काम को बार-बार दोहराना (Repeat करना)

अगर आपको Screen पर 100 बार "Hello" लिखना हो, तो क्या आप 100 बार print() लिखेंगे?

❌ नहीं।

हम Loop का उपयोग करेंगे।


बिना Loop के

print("Hello")
print("Hello")
print("Hello")
print("Hello")
print("Hello")

Loop के साथ

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

Output

Hello
Hello
Hello
Hello
Hello

Real Life Example

मान लीजिए एक School में 500 Students हैं।

आपको सभी की Attendance लेनी है।

क्या हर Student के लिए अलग Program लिखेंगे?

❌ नहीं।

Loop अपने आप 500 Students पर वही Process दोहराएगा।


Section 2 – for Loop

Definition

जब हमें पहले से पता हो कि कोई काम कितनी बार करना है, तब for Loop का उपयोग करते हैं।


Syntax

for variable in sequence:
    code

Example

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

Output

0
1
2
3
4

समझिए

range(5) का अर्थ है

0
1
2
3
4

Python हमेशा 0 से Counting शुरू करता है।


Section 3 – range() Function

range() Numbers की एक Sequence बनाता है।


Example 1

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

Output

0
1
2
3
4

Example 2

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

Output

1
2
3
4
5

Example 3

for i in range(2,11,2):
    print(i)

Output

2
4
6
8
10

Syntax

range(start, stop, step)
  • start → कहाँ से शुरू करें

  • stop → कहाँ तक जाएँ (यह शामिल नहीं होता)

  • step → कितने-कितने से बढ़ें


Real Life Example

मान लीजिए सीढ़ियाँ हैं।

आप पहली सीढ़ी से शुरू करते हैं।

हर बार एक सीढ़ी या दो सीढ़ी चढ़ते हैं।

यही step है।


Section 4 – for Loop with String

name = "Python"

for ch in name:
    print(ch)

Output

P
y
t
h
o
n

Real Life Example

किसी Word के हर अक्षर को एक-एक करके पढ़ना।


Section 5 – while Loop

Definition

जब हमें पहले से नहीं पता कि Loop कितनी बार चलेगा, तब while Loop का उपयोग करते हैं।


Syntax

while condition:
    code

Example

i = 1

while i <= 5:
    print(i)
    i += 1

Output

1
2
3
4
5

Real Life Example

ATM तब तक PIN पूछता है जब तक सही PIN नहीं डालते।

यह while Loop जैसा है।


Section 6 – Infinite Loop

अगर Condition कभी False नहीं होगी, तो Loop हमेशा चलता रहेगा।

while True:
    print("Hello")

⚠️ यह Program कभी नहीं रुकेगा (जब तक आप उसे रोकें नहीं)।


Section 7 – break Statement

break Loop को तुरंत रोक देता है।


Example

for i in range(10):

    if i == 5:
        break

    print(i)

Output

0
1
2
3
4

Real Life Example

आप Book पढ़ रहे हैं।

Page 50 पर ज़रूरी जानकारी मिल गई।

अब आगे पढ़ने की ज़रूरत नहीं।

यही break है।


Section 8 – continue Statement

continue वर्तमान Iteration को छोड़कर अगले Iteration पर चला जाता है।


Example

for i in range(6):

    if i == 3:
        continue

    print(i)

Output

0
1
2
4
5

Real Life Example

Class में Roll Number 25 वाला Student आज अनुपस्थित है।

बाकी सभी की Attendance ले ली जाती है।


Section 9 – pass Statement

pass का अर्थ है "अभी कुछ मत करो।"


Example

for i in range(5):

    if i == 3:
        pass

    print(i)

Output

0
1
2
3
4

pass Placeholder की तरह काम करता है।


Section 10 – Nested Loop

एक Loop के अंदर दूसरा Loop।


Example

for i in range(3):

    for j in range(3):

        print(i, j)

Output

0 0
0 1
0 2
1 0
1 1
1 2
2 0
2 1
2 2

Real Life Example

School

Class 1

→ Student 1

→ Student 2

Class 2

→ Student 1

→ Student 2


Practical Program 1 – Table of a Number

num = int(input("Enter Number: "))

for i in range(1,11):

    print(num * i)

Practical Program 2 – Sum of First N Numbers

n = int(input("Enter Number: "))

total = 0

for i in range(1,n+1):

    total += i

print(total)

Practical Program 3 – Factorial

n = int(input("Enter Number: "))

fact = 1

for i in range(1,n+1):

    fact *= i

print(fact)

Formula

5! = 5 × 4 × 3 × 2 × 1

Practical Program 4 – Countdown

for i in range(10,0,-1):

    print(i)

print("Happy New Year!")

Practical Program 5 – Password Checker

password = ""

while password != "python123":

    password = input("Enter Password: ")

print("Login Successful")

Practical Program 6 – Guessing Game

secret = 7

while True:

    guess = int(input("Guess Number: "))

    if guess == secret:

        print("Correct")

        break

    else:

        print("Try Again")

Practical Program 7 – Even Numbers

for i in range(2,21,2):

    print(i)

Practical Program 8 – Odd Numbers

for i in range(1,20,2):

    print(i)

Practical Program 9 – Reverse Counting

for i in range(10,0,-1):

    print(i)

Practical Program 10 – Multiples of 5

for i in range(5,51,5):

    print(i)

Key Concepts Summary

  • Loop का उपयोग Repetitive Tasks के लिए होता है।

  • for Loop तब उपयोग करें जब Iterations की संख्या पता हो।

  • while Loop तब उपयोग करें जब Condition के आधार पर Loop चलाना हो।

  • range() Number Sequence बनाता है।

  • break Loop को रोक देता है।

  • continue Current Iteration को छोड़ देता है।

  • pass Placeholder है।

  • Nested Loop का उपयोग Grid, Table, Matrix और Pattern Printing में होता है।


Important Definitions

Loop: बार-बार चलने वाला Code Block।

Iteration: Loop का एक चक्कर।

for Loop: निश्चित (Known) Iterations के लिए Loop।

while Loop: Condition आधारित Loop।

Infinite Loop: ऐसा Loop जो कभी समाप्त नहीं होता।

Nested Loop: एक Loop के अंदर दूसरा Loop।


Common Mistakes Students Make

  1. range(5) को 1–5 समझ लेना (यह 0–4 देता है)।

  2. while Loop में Counter (i += 1) बढ़ाना भूल जाना, जिससे Infinite Loop बन जाता है।

  3. break और continue का अंतर न समझना।

  4. range(start, stop) में stop Value को शामिल मान लेना।

  5. Nested Loop में Indentation गलत करना।

  6. while True लिखकर बाहर निकलने के लिए break न देना।

  7. Loop Variable (i, j) को अनजाने में बदल देना।


Practice Questions (With Answers)

1. Loop का उपयोग क्यों किया जाता है?

Answer: Repetitive Tasks को बार-बार करने के लिए।

2. for Loop और while Loop में मुख्य अंतर क्या है?

Answer: for Loop तब उपयोग होता है जब Iterations की संख्या पता हो, जबकि while Loop Condition के आधार पर चलता है।

3. range(5) कौन-कौन से Numbers देता है?

Answer: 0, 1, 2, 3, 4

4. range(2, 8) का Output क्या होगा?

Answer: 2, 3, 4, 5, 6, 7

5. range(1, 10, 3) का Output क्या होगा?

Answer: 1, 4, 7

6. break का क्या काम है?

Answer: Loop को तुरंत समाप्त कर देता है।

7. continue का क्या काम है?

Answer: Current Iteration को छोड़कर अगले Iteration पर चला जाता है।

8. pass का क्या उपयोग है?

Answer: Placeholder के रूप में, जहाँ अभी कोई Code नहीं लिखना हो।

9. नीचे दिए गए Code का Output क्या होगा?

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

Answer:

0
1
2

10. Factorial of 4 क्या होगा?

Answer:

4 × 3 × 2 × 1 = 24

🎯 Homework

  1. User से Number लेकर उसका Multiplication Table बनाइए।

  2. 1 से 100 तक सभी Even और Odd Numbers अलग-अलग Print कीजिए।

  3. User से Number लेकर उसका Factorial निकालिए।

  4. ऐसा Program लिखिए जो Password सही होने तक User से Password माँगे।

  5. 1 से 100 तक सभी Numbers का Sum निकालिए।


📌 अगले Part 7 में हम सीखेंगे (Python का सबसे महत्वपूर्ण Chapter):

⭐ Pattern Printing + Prime Number + Fibonacci Series + Advanced Loop Problems

इस Chapter में हम सीखेंगे:

  • Star Patterns (*)

  • Number Patterns

  • Alphabet Patterns

  • Pyramid Pattern

  • Inverted Pyramid

  • Right Triangle

  • Left Triangle

  • Diamond Pattern

  • Prime Number Checker

  • Prime Numbers in Range

  • Fibonacci Series

  • Armstrong Number

  • Palindrome Number

  • Perfect Number

  • Strong Number

  • 50+ Interview Programs

  • 150+ Practice Questions

यही Chapter Coding Interviews, College Exams, Hackathons और Placement की तैयारी का आधार माना जाता है।


🐍 Python Complete Course

Part 7 – Pattern Printing, Prime Number, Fibonacci Series & Advanced Loop Problems

Level: Beginner → Advanced
Duration: 3–4 Hours
Goal: इस Chapter के बाद आप Python में Loops का Professional उपयोग सीख जाएंगे। यही Topic Coding Interviews, College Exams और Placement में सबसे अधिक पूछा जाता है।


📚 आज हम क्या सीखेंगे?

Section A – Pattern Printing

  • Pattern क्या है?

  • Star (*) Patterns

  • Number Patterns

  • Alphabet Patterns

  • Pyramid

  • Inverted Pyramid

  • Diamond Pattern

  • Floyd's Triangle

Section B – Number Programs

  • Prime Number

  • Prime Numbers in Range

  • Fibonacci Series

  • Factorial

  • Reverse Number

  • Palindrome Number

  • Armstrong Number

  • Perfect Number

  • Strong Number

Section C – Advanced Loop Problems

  • Sum of Digits

  • Count Digits

  • Reverse Digits

  • GCD & LCM

  • Decimal to Binary

  • Binary to Decimal


⭐ Section A – Pattern Printing

Pattern Printing क्या है?

Pattern Printing का मतलब है Loops की मदद से किसी विशेष आकृति (Pattern) को Print करना।

यह Programming Logic को मजबूत करने का सबसे अच्छा तरीका है।


Real Life Example

मान लीजिए आप ईंटों से घर बना रहे हैं।

हर ईंट सही जगह रखनी होगी।

वैसे ही Pattern Printing में हर * या Number सही Position पर Print करना होता है।


Pattern 1 – Square Pattern

rows = 5

for i in range(rows):
    for j in range(rows):
        print("*", end=" ")
    print()

Output

* * * * *
* * * * *
* * * * *
* * * * *
* * * * *

समझिए

Outer Loop = Rows

Inner Loop = Columns


Pattern 2 – Right Triangle

rows = 5

for i in range(1, rows + 1):
    for j in range(i):
        print("*", end=" ")
    print()

Output

*
* *
* * *
* * * *
* * * * *

Pattern 3 – Inverted Triangle

rows = 5

for i in range(rows, 0, -1):
    for j in range(i):
        print("*", end=" ")
    print()

Output

* * * * *
* * * *
* * *
* *
*

Pattern 4 – Number Triangle

rows = 5

for i in range(1, rows + 1):
    for j in range(1, i + 1):
        print(j, end=" ")
    print()

Output

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

Pattern 5 – Same Number Pattern

rows = 5

for i in range(1, rows + 1):
    for j in range(i):
        print(i, end=" ")
    print()

Output

1
2 2
3 3 3
4 4 4 4
5 5 5 5 5

Pattern 6 – Alphabet Pattern

rows = 5

for i in range(rows):
    for j in range(i + 1):
        print(chr(65 + j), end=" ")
    print()

Output

A
A B
A B C
A B C D
A B C D E

Pattern 7 – Pyramid

rows = 5

for i in range(rows):
    print(" " * (rows - i - 1), end="")
    print("* " * (i + 1))

Output

    *
   * *
  * * *
 * * * *
* * * * *

Pattern 8 – Inverted Pyramid

rows = 5

for i in range(rows):
    print(" " * i, end="")
    print("* " * (rows - i))

Output

* * * * *
 * * * *
  * * *
   * *
    *

Pattern 9 – Diamond Pattern

rows = 5

# Upper Part
for i in range(rows):
    print(" " * (rows - i - 1), end="")
    print("* " * (i + 1))

# Lower Part
for i in range(rows - 2, -1, -1):
    print(" " * (rows - i - 1), end="")
    print("* " * (i + 1))

Section B – Prime Number

Prime Number क्या है?

ऐसी संख्या जो केवल

  • 1

  • स्वयं (Self)

से Divide होती है।


Examples

Prime

2
3
5
7
11
13
17
19

Not Prime

4
6
8
9
10
12

Prime Number Program

number = int(input("Enter Number: "))

count = 0

for i in range(1, number + 1):

    if number % i == 0:
        count += 1

if count == 2:
    print("Prime")
else:
    print("Not Prime")

Better (Efficient) Prime Program

number = int(input("Enter Number: "))

is_prime = True

if number < 2:
    is_prime = False
else:
    for i in range(2, int(number ** 0.5) + 1):
        if number % i == 0:
            is_prime = False
            break

if is_prime:
    print("Prime")
else:
    print("Not Prime")

Prime Numbers Between 1–100

for num in range(2, 101):

    is_prime = True

    for i in range(2, int(num ** 0.5) + 1):

        if num % i == 0:
            is_prime = False
            break

    if is_prime:
        print(num, end=" ")

Section C – Fibonacci Series

Fibonacci क्या है?

हर अगली संख्या पिछले दो Numbers के योग के बराबर होती है।

Sequence

0 1 1 2 3 5 8 13 21 34 ...

Program

n = int(input("How many terms: "))

a = 0
b = 1

for i in range(n):

    print(a, end=" ")

    a, b = b, a + b

Real Life Example

Rabbit Population Model

एक Rabbit Pair से Population बढ़ने का प्रसिद्ध Mathematical Model Fibonacci पर आधारित है।


Armstrong Number

153

क्यों?

1³ + 5³ + 3³

=

1 + 125 + 27

=

153

Armstrong Program

number = int(input("Enter Number: "))

temp = number
total = 0

while temp > 0:

    digit = temp % 10
    total += digit ** 3
    temp //= 10

if total == number:
    print("Armstrong")
else:
    print("Not Armstrong")

नोट: यह Program 3-अंकों वाले Armstrong Numbers के लिए है। सभी अंकों की संख्या के लिए बाद में General Version सीखेंगे।


Palindrome Number

121

उल्टा

121

Same

इसलिए Palindrome।


Program

number = int(input("Enter Number: "))

original = number
reverse = 0

while number > 0:

    digit = number % 10

    reverse = reverse * 10 + digit

    number //= 10

if original == reverse:
    print("Palindrome")
else:
    print("Not Palindrome")

Perfect Number

Example

6

Factors

1
2
3

Sum

1+2+3=6

इसलिए Perfect Number।


Strong Number

Example

145
1! + 4! + 5!

=

1 + 24 + 120

=

145

Key Concepts Summary

  • Pattern Printing में Outer Loop Rows और Inner Loop Columns को नियंत्रित करता है।

  • Prime Number के केवल दो Factors होते हैं: 1 और स्वयं।

  • Efficient Prime Check के लिए √n तक Check करना पर्याप्त होता है।

  • Fibonacci Series में हर अगली संख्या पिछले दो Numbers का योग होती है।

  • Armstrong Number में प्रत्येक अंक की Power का योग मूल संख्या के बराबर होता है।

  • Palindrome Number आगे और पीछे से समान पढ़ा जाता है।

  • Perfect Number अपने Proper Factors के Sum के बराबर होता है।

  • Strong Number अपने अंकों के Factorials के Sum के बराबर होता है।


Important Definitions

Pattern Printing: Loops का उपयोग करके आकृतियाँ Print करना।

Prime Number: ऐसी संख्या जिसके केवल दो Positive Factors हों।

Fibonacci Series: ऐसी Series जिसमें हर संख्या पिछले दो का योग होती है।

Armstrong Number: अंकों की Power के योग के बराबर संख्या।

Palindrome Number: आगे और पीछे से समान दिखाई देने वाली संख्या।

Perfect Number: अपने Proper Factors के Sum के बराबर संख्या।

Strong Number: अंकों के Factorials के Sum के बराबर संख्या।


Common Mistakes Students Make

  1. Nested Loops में Outer और Inner Loop की भूमिका भूल जाना।

  2. Pattern में print() और print(..., end=" ") का अंतर न समझना।

  3. Prime Number Check में 1 को Prime मान लेना (जबकि 1 Prime नहीं है)।

  4. Prime Check में break न लगाना, जिससे Program अनावश्यक रूप से अधिक चलता है।

  5. Fibonacci में Variables (a और b) को गलत क्रम में Update करना।

  6. Number Programs में % और // Operators का गलत उपयोग करना।

  7. Armstrong Program को सभी Digit Length पर लागू मान लेना, जबकि ऊपर वाला Version केवल 3-Digit Numbers के लिए है।


Practice Questions (With Answers)

1. Pattern Printing में Outer Loop क्या नियंत्रित करता है?

Answer: Rows।

2. Pattern Printing में Inner Loop क्या नियंत्रित करता है?

Answer: Columns।

3. क्या 29 Prime Number है?

Answer: हाँ।

4. क्या 21 Prime Number है?

Answer: नहीं।

5. Fibonacci Series के पहले 6 Terms लिखिए।

Answer: 0 1 1 2 3 5

6. क्या 121 Palindrome Number है?

Answer: हाँ।

7. क्या 153 Armstrong Number है?

Answer: हाँ।

8. पहला Perfect Number कौन-सा है?

Answer: 6

9. क्या 145 Strong Number है?

Answer: हाँ।

10. Prime Check में √n तक Check करने का क्या लाभ है?

Answer: Program तेज़ (Efficient) चलता है क्योंकि कम Iterations लगती हैं।


🎯 Homework

  1. 10 अलग-अलग Star Patterns बनाइए।

  2. 1 से 500 तक सभी Prime Numbers Print कीजिए।

  3. User से Range लेकर उस Range के सभी Armstrong Numbers निकालिए।

  4. User से Number लेकर उसे Palindrome, Prime और Armstrong तीनों के लिए Check कीजिए।

  5. Fibonacci Series के पहले 20 Terms Print कीजिए।


📌 अगले Part 8 में हम सीखेंगे:

🧩 Functions (User Defined Functions)

  • Function क्या है?

  • Function क्यों उपयोग करते हैं?

  • Function बनाना

  • Parameters और Arguments

  • Return Statement

  • Local vs Global Variables

  • Default Arguments

  • Keyword Arguments

  • Variable-Length Arguments (*args, **kwargs)

  • Lambda Functions

  • Recursion

  • Scope

  • 30+ Practical Programs

  • 100+ Practice Questions

Functions सीखने के बाद आपका Code Professional, Reusable और Clean बन जाएगा।


🐍 Python Complete Course

Part 8 – Functions (Complete Mastery)

Level: Beginner → Advanced
Duration: 3–4 Hours
Goal: इस Chapter के बाद आप Professional तरीके से Functions लिखना, Reusable Code बनाना और बड़े Projects को छोटे-छोटे Modules में बाँटना सीख जाएंगे।


📚 आज हम क्या सीखेंगे?

  • Function क्या है?

  • Function क्यों उपयोग करते हैं?

  • Function कैसे बनाते हैं?

  • Function Calling

  • Parameters और Arguments

  • Positional Arguments

  • Keyword Arguments

  • Default Arguments

  • Variable Length Arguments (*args, **kwargs)

  • Return Statement

  • Local Variables

  • Global Variables

  • Scope

  • Lambda Function

  • Recursion

  • Practical Programs


Section 1 – Function क्या है?

आसान भाषा में

Function Code का एक ऐसा Block होता है जिसे एक बार लिखकर कई बार उपयोग किया जा सकता है।


Real Life Example

मान लीजिए आपके घर में Washing Machine है।

जब भी कपड़े धोने हों, आप Machine का Start Button दबाते हैं।

आपको हर बार Machine के अंदर का पूरा Process नहीं करना पड़ता।

Function भी बिल्कुल ऐसा ही है।

आप Function बनाते हैं।

जब ज़रूरत हो, उसे Call कर देते हैं।


बिना Function

print("Welcome")
print("Welcome")
print("Welcome")
print("Welcome")

Function के साथ

def welcome():
    print("Welcome")

welcome()
welcome()
welcome()
welcome()

Output

Welcome
Welcome
Welcome
Welcome

Section 2 – Function क्यों उपयोग करते हैं?

यदि 100 जगह एक जैसा Code लिखना पड़े...

तो?

❌ Code बहुत बड़ा हो जाएगा।

अगर बाद में बदलाव करना हो...

तो 100 जगह बदलना पड़ेगा।

Function में केवल एक जगह बदलाव करना होता है।


Advantages

✅ Code Reuse

✅ Time Saving

✅ Easy Maintenance

✅ Easy Debugging

✅ Professional Coding


Section 3 – Function Syntax

def function_name():
    code

Example

def hello():
    print("Hello Python")

Function Call

hello()

Output

Hello Python

Real Life Example

TV Remote

Button दबाया

TV ON

वैसे ही

Function Call

Code Execute


Section 4 – Function with Parameters

कभी-कभी Function को Data भी देना पड़ता है।


Example

def greet(name):

    print("Hello", name)

greet("Ajay")

Output

Hello Ajay

एक और Example

def square(number):

    print(number * number)

square(5)

Output

25

Real Life Example

Pizza Order

Pizza Shop पूछता है—

कौन-सा Pizza चाहिए?

आप बोलते हैं—

Veg Pizza

यानी Function को Input दिया।


Section 5 – Multiple Parameters

def student(name, age):

    print(name)

    print(age)

student("Ajay",22)

Output

Ajay
22

Section 6 – Positional Arguments

Arguments उसी क्रम में जाने चाहिए।

def info(name, city):

    print(name)

    print(city)

info("Ajay","Patna")

अगर Order बदल देंगे

info("Patna","Ajay")

Output

Patna
Ajay

गलत Result मिलेगा।


Section 7 – Keyword Arguments

Order बदल सकते हैं।

def info(name, city):

    print(name)

    print(city)

info(city="Patna",name="Ajay")

Output

Ajay
Patna

Section 8 – Default Arguments

अगर User Value नहीं देता

तो Default Value उपयोग होगी।

def country(name,country="India"):

    print(name)

    print(country)

country("Ajay")

Output

Ajay
India

अगर Value देंगे

country("Ajay","Nepal")

Output

Ajay
Nepal

Section 9 – Return Statement

अब तक Function केवल Print कर रहा था।

लेकिन Professional Programs में Function अक्सर Value Return करता है।


Example

def add(a,b):

    return a+b

result = add(10,20)

print(result)

Output

30

Print vs Return

Print

def add(a,b):

    print(a+b)

केवल Screen पर दिखाता है।


Return

def add(a,b):

    return a+b

Value वापस भेजता है।


Real Life Example

ATM

Balance पूछते हैं।

ATM Balance वापस देता है।

यही Return है।


Section 10 – Local Variable

def test():

    x = 10

    print(x)

test()

Output

10

लेकिन

print(x)

Error देगा।

क्यों?

क्योंकि

x केवल Function के अंदर था।


Section 11 – Global Variable

name = "Ajay"

def show():

    print(name)

show()

Output

Ajay

Global Variable Function के बाहर बनता है।


Section 12 – Variable Scope

VariableScope
Localकेवल Function के अंदर
Globalपूरे Program में

Section 13 – *args

अगर Parameters कितने आएँगे यह पहले से नहीं पता।

def total(*numbers):

    print(sum(numbers))

total(10,20)

total(10,20,30)

total(10,20,30,40)

Output

30
60
100

Real Life Example

किसी Shopping Cart में 2 Items भी हो सकती हैं, 20 Items भी।


Section 14 – **kwargs

Keyword Arguments की संख्या निश्चित न हो।

def profile(**data):

    print(data)

profile(name="Ajay",age=22,city="Patna")

Output

{'name': 'Ajay', 'age': 22, 'city': 'Patna'}

Section 15 – Lambda Function

छोटा Function

एक लाइन में।


Normal Function

def square(x):

    return x*x

Lambda

square = lambda x:x*x

print(square(5))

Output

25

Section 16 – Recursion

Function खुद को Call करे।


Example

def countdown(n):

    if n==0:

        print("Done")

    else:

        print(n)

        countdown(n-1)

countdown(5)

Output

5
4
3
2
1
Done

Real Life Example

सीढ़ियों से नीचे उतरना।

हर Step पर वही Process दोहराना।


Practical Program 1 – Area of Circle

def area(radius):

    return 3.14*radius*radius

print(area(5))

Practical Program 2 – Calculator

def add(a,b):

    return a+b

def sub(a,b):

    return a-b

def mul(a,b):

    return a*b

print(add(10,5))

print(sub(10,5))

print(mul(10,5))

Practical Program 3 – Even Odd

def even(number):

    return number%2==0

print(even(8))

Output

True

Practical Program 4 – Prime Function

def is_prime(n):

    if n<2:
        return False

    for i in range(2,int(n**0.5)+1):

        if n%i==0:
            return False

    return True

print(is_prime(29))

Output

True

Practical Program 5 – Factorial Function

def factorial(n):

    fact=1

    for i in range(1,n+1):

        fact*=i

    return fact

print(factorial(5))

Output

120

Key Concepts Summary

  • Function Reusable Code Block है।

  • def से Function बनाया जाता है।

  • Function को Call करके Execute किया जाता है।

  • Parameters Input लेने के लिए होते हैं।

  • Arguments Function Call के समय दिए जाते हैं।

  • return Value वापस भेजता है।

  • Local Variable केवल Function के अंदर उपलब्ध होता है।

  • Global Variable पूरे Program में उपलब्ध होता है।

  • *args से कई Positional Arguments लिए जा सकते हैं।

  • **kwargs से कई Keyword Arguments लिए जा सकते हैं।

  • Lambda छोटे Functions के लिए उपयोगी है।

  • Recursion में Function खुद को Call करता है।


Important Definitions

Function: Reusable Code Block।

Parameter: Function की Definition में लिखा गया Variable।

Argument: Function Call करते समय भेजी गई Value।

Return: Function द्वारा वापस भेजी गई Value।

Scope: Variable कहाँ-कहाँ उपयोग किया जा सकता है।

Lambda Function: एक लाइन में लिखा गया Anonymous Function।

Recursion: Function का खुद को Call करना।


Common Mistakes Students Make

  1. Function को Define करके Call करना भूल जाना।

  2. print() और return में अंतर न समझना।

  3. Parameters और Arguments को एक ही चीज समझ लेना।

  4. Local Variable को Function के बाहर उपयोग करना।

  5. return के बाद भी Code चलेगा ऐसा मान लेना (असल में return के बाद Function समाप्त हो जाता है)।

  6. *args और **kwargs का अंतर न समझना।

  7. Recursion में Base Condition (if n == 0 जैसी) न देना, जिससे RecursionError आ सकता है।


Practice Questions (With Answers)

1. Function क्या है?

Answer: Reusable Code Block।

2. Function बनाने के लिए कौन-सा Keyword उपयोग होता है?

Answer: def

3. return का क्या काम है?

Answer: Function से Value वापस भेजना।

4. Parameter और Argument में क्या अंतर है?

Answer: Parameter Function Definition में होता है, जबकि Argument Function Call के समय दी गई Value होती है।

5. Local Variable कहाँ उपयोग किया जा सकता है?

Answer: केवल उसी Function के अंदर जहाँ वह बनाया गया हो।

6. *args का उपयोग कब करते हैं?

Answer: जब Positional Arguments की संख्या पहले से निश्चित न हो।

7. **kwargs का उपयोग कब करते हैं?

Answer: जब Keyword Arguments की संख्या पहले से निश्चित न हो।

8. Lambda Function किसलिए उपयोगी है?

Answer: छोटे, एक-पंक्ति वाले Functions बनाने के लिए।

9. Recursion क्या है?

Answer: जब Function खुद को Call करता है।

10. नीचे दिए गए Code का Output क्या होगा?

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

print(add(7, 8))

Answer:

15

🎯 Homework

  1. दो Numbers का Average निकालने वाला Function बनाइए।

  2. User से Number लेकर Prime Check करने वाला Function लिखिए।

  3. तीन Numbers में सबसे बड़ा Number Return करने वाला Function बनाइए।

  4. ऐसा Function बनाइए जो किसी String को Reverse करके Return करे।

  5. Calculator Program को अलग-अलग Functions (add(), sub(), mul(), div()) में बाँटिए।


📌 अगले Part 9 में हम सीखेंगे:

📦 Collections in Python

  • Lists

  • Tuples

  • Sets

  • Dictionaries

  • List Methods

  • Tuple Operations

  • Set Operations

  • Dictionary Methods

  • List Comprehension

  • Nested Collections

  • 40+ Practical Programs

  • 150+ Practice Questions

यह Chapter Data Science, Machine Learning, Web Development और Interview Preparation के लिए सबसे महत्वपूर्ण Chapters में से एक है।


🐍 Python Complete Course

Part 9 – Python Collections (Lists, Tuples, Sets & Dictionaries)

Level: Beginner → Advanced
Duration: 4–5 Hours
Goal: इस Chapter के बाद आप Python में Data को Store, Manage, Search, Update और Process करना सीख जाएंगे। Data Science, Machine Learning, Web Development और Automation में Collections का सबसे अधिक उपयोग होता है।


📚 आज हम क्या सीखेंगे?

Section A – Lists

  • List क्या है?

  • List बनाना

  • Indexing

  • Slicing

  • List Methods

  • Nested List

  • List Comprehension

Section B – Tuples

  • Tuple क्या है?

  • Tuple vs List

  • Tuple Methods

Section C – Sets

  • Set क्या है?

  • Set Operations

  • Union

  • Intersection

  • Difference

Section D – Dictionaries

  • Dictionary क्या है?

  • Keys और Values

  • Dictionary Methods

  • Nested Dictionary


🟢 Section A – Lists

Section 1 – List क्या है?

आसान भाषा में

List एक ऐसा Data Structure है जिसमें एक से अधिक Values Store की जा सकती हैं।


Real Life Example

मान लीजिए आपकी Shopping List है।

🛒 Shopping List

  • Rice

  • Sugar

  • Milk

  • Oil

  • Soap

यह एक List है।

Python में भी बिल्कुल ऐसा ही होता है।


List बनाना

fruits = ["Apple", "Banana", "Mango"]

print(fruits)

Output

['Apple', 'Banana', 'Mango']

Section 2 – List Indexing

fruits = ["Apple","Banana","Mango"]
IndexValue
0Apple
1Banana
2Mango

पहला Element

print(fruits[0])

Output

Apple

दूसरा

print(fruits[1])

Output

Banana

Negative Index

print(fruits[-1])

Output

Mango

Section 3 – List Slicing

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

Output

[20,30,40]

Section 4 – List Update

fruits = ["Apple","Banana","Mango"]

fruits[1] = "Orange"

print(fruits)

Output

['Apple','Orange','Mango']

Real Life Example

Shopping List में Banana हटाकर Orange लिख दिया।


Section 5 – List Methods


append()

नई Value अंत में जोड़ता है।

fruits = ["Apple"]

fruits.append("Banana")

print(fruits)

Output

['Apple','Banana']

insert()

fruits.insert(1,"Orange")

Output

['Apple','Orange','Banana']

extend()

दो Lists जोड़ना।

a=[1,2]

b=[3,4]

a.extend(b)

print(a)

Output

[1,2,3,4]

remove()

fruits.remove("Apple")

pop()

fruits.pop()

Last Element हटाता है।


clear()

पूरी List खाली।

fruits.clear()

sort()

numbers=[5,2,9,1]

numbers.sort()

print(numbers)

Output

[1,2,5,9]

reverse()

numbers.reverse()

count()

numbers=[1,2,2,3]

print(numbers.count(2))

Output

2

index()

fruits=["Apple","Banana","Mango"]

print(fruits.index("Banana"))

Output

1

Section 6 – Loop through List

fruits=["Apple","Banana","Mango"]

for fruit in fruits:

    print(fruit)

Section 7 – Nested List

marks = [

[80,90],

[75,88]

]

print(marks[1][0])

Output

75

Real Life Example

Classroom

Class A

Student 1

Student 2

Class B

Student 1

Student 2


Section 8 – List Comprehension

पुराना तरीका

square=[]

for i in range(5):

    square.append(i*i)

print(square)

Professional तरीका

square=[i*i for i in range(5)]

print(square)

Output

[0,1,4,9,16]

🔵 Section B – Tuple

Tuple क्या है?

Tuple भी List जैसा है।

लेकिन...

❌ इसे बदला नहीं जा सकता।


student=("Ajay",22,"Patna")

Difference

ListTuple
MutableImmutable
[]()

Access

print(student[0])

Output

Ajay

Tuple Methods

count()

index()

Real Life Example

Date of Birth

अगर DOB एक बार Record हो गई

तो बदलती नहीं।

Tuple उसी तरह होता है।


🟠 Section C – Set

Set क्या है?

Set में

Duplicate Values नहीं होतीं।


numbers={1,2,3,3,2,1}

print(numbers)

Output

{1,2,3}

Add

numbers.add(5)

Remove

numbers.remove(2)

Union

A={1,2,3}

B={3,4,5}

print(A|B)

Output

{1,2,3,4,5}

Intersection

print(A&B)

Output

{3}

Difference

print(A-B)

Output

{1,2}

Real Life Example

दो Schools की Student List

Union

सभी Students

Intersection

दोनों Schools में Common Students


🔴 Section D – Dictionary

Dictionary क्या है?

Dictionary

Key और Value का Collection है।


Real Life Example

Aadhar Card

Name → Ajay

Age → 22

Village → Haripur

हर जानकारी का एक Label है।


Dictionary बनाना

student={

"name":"Ajay",

"age":22,

"city":"Patna"

}

Value Access

print(student["name"])

Output

Ajay

Update

student["age"]=23

Add

student["course"]="Python"

Delete

del student["city"]

Dictionary Methods

keys()

print(student.keys())

values()

print(student.values())

items()

print(student.items())

get()

print(student.get("name"))

Loop

for key,value in student.items():

    print(key,value)

Nested Dictionary

students={

1:{

"name":"Ajay",

"age":22

},

2:{

"name":"Rahul",

"age":20

}

}

Practical Program 1

Largest Number in List

numbers=[10,45,20,99]

print(max(numbers))

Practical Program 2

Smallest Number

print(min(numbers))

Practical Program 3

Average

numbers=[10,20,30]

print(sum(numbers)/len(numbers))

Practical Program 4

Remove Duplicates

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

numbers=list(set(numbers))

print(numbers)

Practical Program 5

Student Record

student={

"name":"Ajay",

"marks":95

}

print(student)

Practical Program 6

Word Frequency Counter

text="python python java"

words=text.split()

count={}

for word in words:

    count[word]=count.get(word,0)+1

print(count)

Output

{'python':2,'java':1}

Key Concepts Summary

  • List Ordered और Mutable Collection है।

  • Tuple Ordered लेकिन Immutable Collection है।

  • Set Unordered Collection है जिसमें Duplicate Values नहीं होतीं।

  • Dictionary Key-Value Pair का Collection है।

  • List Comprehension कम Code में नई List बनाने का तरीका है।

  • Nested Collections के अंदर Collection के अंदर Collection हो सकता है।


Important Definitions

List: Mutable Ordered Collection।

Tuple: Immutable Ordered Collection।

Set: Unordered Collection of Unique Elements।

Dictionary: Key-Value Pair Collection।

Mutable: जिसे बदला जा सके।

Immutable: जिसे बदला न जा सके।

Key: Dictionary में किसी Value की पहचान।

Value: Key से जुड़ा Data।


Common Mistakes Students Make

  1. List और Tuple में अंतर भूल जाना।

  2. Tuple की Value बदलने की कोशिश करना (TypeError आएगा)।

  3. Set में Indexing करने की कोशिश करना (Set Index Support नहीं करता)।

  4. Dictionary में मौजूद न होने वाली Key को सीधे Access करना (KeyError आ सकता है; get() सुरक्षित विकल्प है)।

  5. append() और extend() में अंतर न समझना।

  6. remove() और pop() का गलत उपयोग करना।

  7. Duplicate हटाने के बाद यह भूल जाना कि Set Elements का Order निश्चित नहीं होता।


Practice Questions (With Answers)

1. List और Tuple में मुख्य अंतर क्या है?

Answer: List Mutable होती है, Tuple Immutable।

2. कौन-सा Collection Duplicate Values को अपने आप हटा देता है?

Answer: Set।

3. Dictionary में Data किस रूप में Store होता है?

Answer: Key-Value Pairs के रूप में।

4. List में नया Element अंत में जोड़ने के लिए कौन-सी Method है?

Answer: append()

5. ["A", "B", "C"][1] का Output क्या होगा?

Answer: "B"

6. {"name": "Ajay"}["name"] का Output क्या होगा?

Answer: "Ajay"

7. set([1, 2, 2, 3]) का Result क्या होगा?

Answer: {1, 2, 3}

8. List Comprehension का क्या लाभ है?

Answer: कम और साफ Code में नई List बनाना।

9. Dictionary की सभी Keys प्राप्त करने के लिए कौन-सी Method उपयोग होती है?

Answer: keys()

10. नीचे दिए गए Code का Output क्या होगा?

numbers = [5, 2, 8]
numbers.sort()
print(numbers)

Answer:

[2, 5, 8]

🎯 Homework

  1. User से 10 Numbers लेकर सबसे बड़ा और सबसे छोटा Number निकालिए।

  2. एक List में Duplicate Elements हटाइए।

  3. 5 Students का नाम और Marks Dictionary में Store करके Print कीजिए।

  4. User से एक Sentence लेकर प्रत्येक Word की Frequency निकालिए।

  5. Shopping Cart Program बनाइए जिसमें List का उपयोग करके Items Add, Remove और Display किए जा सकें।


📌 अगले Part 10 में हम सीखेंगे:

📂 Files & Exception Handling

  • File Handling (open, read, write, append)

  • File Modes (r, w, a, x)

  • with Statement

  • CSV Files

  • JSON Files (Introduction)

  • Exception Handling (try, except, else, finally)

  • Custom Exceptions

  • Mini Projects (Student Record File, Notes App, Login Logs)

यहीं से आप Real-World Applications बनाना शुरू करेंगे, क्योंकि Program का Data File में Save और Load करना सीखेंगे।

🐍 Python Complete Course

Part 10 – File Handling & Exception Handling (Complete Mastery)

Level: Intermediate → Advanced
Duration: 4–5 Hours
Goal: इस Chapter के बाद आप Files में Data Save करना, पढ़ना, Update करना, Errors को Handle करना और Professional Python Programs बनाना सीख जाएंगे।


📚 आज हम क्या सीखेंगे?

📂 Section A – File Handling

  • File क्या है?

  • File क्यों उपयोग करते हैं?

  • open() Function

  • File Modes (r, w, a, x)

  • read()

  • readline()

  • readlines()

  • write()

  • writelines()

  • seek()

  • tell()

  • close()

  • with Statement


⚠️ Section B – Exception Handling

  • Error क्या है?

  • Syntax Error

  • Runtime Error

  • Logical Error

  • try

  • except

  • else

  • finally

  • Multiple Exceptions

  • Raising Exceptions

  • Custom Exceptions


📄 Section C

  • CSV Files

  • JSON Files (Introduction)

  • Mini Projects


📂 Section A – File Handling

Section 1 – File क्या है?

आसान भाषा में

File वह जगह है जहाँ Data को स्थायी (Permanent) रूप से Store किया जाता है।

यदि Program बंद हो जाए...

तो Variables का Data मिट जाता है।

लेकिन File में Save किया गया Data सुरक्षित रहता है।


Real Life Example

मान लीजिए School में Student Register है।

अगर Teacher घर चले जाएँ...

फिर भी Register में सभी Students की जानकारी रहती है।

Python में यही काम File करती है।


Section 2 – File क्यों उपयोग करते हैं?

बिना File

Program बंद

↓

Data खत्म

File के साथ

Program बंद

↓

Data सुरक्षित

उदाहरण

  • Student Record

  • Bank Data

  • Hospital Data

  • Login System

  • Attendance

  • Bills

  • Reports


Section 3 – open() Function

File खोलने के लिए

open(filename, mode)

Example

file = open("student.txt", "r")

Section 4 – File Modes

ModeMeaning
rRead
wWrite
aAppend
xCreate New File

Read Mode (r)

file = open("student.txt", "r")

print(file.read())

file.close()

Write Mode (w)

नई File बनाएगा।

अगर File पहले से है तो उसका पुराना Data मिट जाएगा।

file = open("student.txt", "w")

file.write("Ajay Kumar")

file.close()

⚠️ ध्यान दें:

w Mode पुराना Data Delete कर देता है।


Append Mode (a)

पुराना Data नहीं मिटता।

नया Data अंत में जुड़ता है।

file = open("student.txt", "a")

file.write("\nPython Course")

file.close()

Create Mode (x)

file = open("newfile.txt", "x")

अगर File पहले से है

तो Error देगा।


Section 5 – read()

पूरी File पढ़ता है।

file = open("student.txt","r")

print(file.read())

file.close()

Section 6 – readline()

केवल एक Line पढ़ता है।

print(file.readline())

Section 7 – readlines()

सभी Lines को List के रूप में Return करता है।

lines = file.readlines()

print(lines)

Output

['Ajay\n','Rahul\n','Amit']

Section 8 – write()

file = open("data.txt","w")

file.write("Hello Python")

file.close()

Section 9 – writelines()

lines = [

"Python\n",

"Java\n",

"C++"

]

file = open("course.txt","w")

file.writelines(lines)

file.close()

Section 10 – close()

File का उपयोग पूरा होने के बाद हमेशा Close करें।

file.close()

Real Life Example

Book पढ़ने के बाद Book बंद कर देते हैं।

वैसे ही File भी बंद करनी चाहिए।


Section 11 – with Statement (Best Practice)

Professional Python Developers हमेशा with का उपयोग करते हैं।

with open("student.txt","r") as file:

    print(file.read())

फ़ायदा:

close() अपने आप हो जाता है।


Section 12 – tell()

Current Position बताता है।

with open("student.txt","r") as file:

    print(file.tell())

Output

0

Section 13 – seek()

Pointer को नई Position पर ले जाता है।

with open("student.txt","r") as file:

    file.seek(5)

    print(file.read())

Real Life Example

Book के Page Number 50 पर सीधे जाना।


⚠️ Section B – Exception Handling

Section 14 – Error क्या है?

जब Program सही से नहीं चलता।


तीन प्रकार

1. Syntax Error

if True

print("Hello")

Colon (:) नहीं है।


2. Runtime Error

print(10/0)

ZeroDivisionError


3. Logical Error

print(2+2)

# Expected 5

Program चलता है।

लेकिन Result गलत है।


Section 15 – try & except

try:

    number = int(input("Number: "))

    print(100/number)

except:

    print("Something Went Wrong")

Real Life Example

Car चलाते समय Seat Belt लगाते हैं।

Accident हो भी जाए

तो नुकसान कम होता है।

try-except भी Program को Crash होने से बचाता है।


Section 16 – Specific Exception

try:

    number = int(input())

    print(10/number)

except ZeroDivisionError:

    print("Cannot Divide by Zero")

except ValueError:

    print("Invalid Number")

Section 17 – else

अगर Error नहीं आया।

try:

    print(10/2)

except:

    print("Error")

else:

    print("Everything Fine")

Output

5.0

Everything Fine

Section 18 – finally

यह हमेशा चलता है।

try:

    print(10/0)

except:

    print("Error")

finally:

    print("Program Finished")

Output

Error

Program Finished

Real Life Example

Exam खत्म हो या Cancel हो जाए।

School Gate तो बंद होगा।

यही finally है।


Section 19 – raise

खुद Error बनाना।

age = -5

if age < 0:

    raise ValueError("Age Cannot Be Negative")

Section 20 – Custom Exception

class InvalidAgeError(Exception):

    pass

age = -2

if age < 0:

    raise InvalidAgeError("Invalid Age")

📄 Section C – CSV File

CSV

Comma Separated Values


Example

Name,Age,City

Ajay,22,Patna

Rahul,20,Gaya

Read CSV

import csv

with open("student.csv","r") as file:

    reader = csv.reader(file)

    for row in reader:

        print(row)

Write CSV

import csv

with open("student.csv","w",newline="") as file:

    writer = csv.writer(file)

    writer.writerow(["Name","Age"])

    writer.writerow(["Ajay",22])

JSON Introduction

JSON

JavaScript Object Notation


Example

{
"name":"Ajay",

"age":22,

"city":"Patna"
}

Read JSON

import json

with open("student.json","r") as file:

    data = json.load(file)

print(data)

Write JSON

import json

student={

"name":"Ajay",

"age":22

}

with open("student.json","w") as file:

    json.dump(student,file,indent=4)

Mini Project 1 – Notes App

note = input("Write Note: ")

with open("notes.txt","a") as file:

    file.write(note+"\n")

print("Saved")

Mini Project 2 – Student Record

name = input("Name: ")

marks = input("Marks: ")

with open("students.txt","a") as file:

    file.write(name+","+marks+"\n")

Mini Project 3 – Login Log

username = input("Username: ")

with open("log.txt","a") as file:

    file.write(username+"\n")

Key Concepts Summary

  • File Data को Permanent Store करने के लिए उपयोग होती है।

  • open() File खोलता है।

  • r Read Mode है।

  • w Write Mode है और पुराना Data मिटा देता है।

  • a Append Mode है जो नया Data जोड़ता है।

  • with Statement File को Automatic Close करता है।

  • try-except Program को Crash होने से बचाता है।

  • else तब चलता है जब Error नहीं आता।

  • finally हमेशा Execute होता है।

  • CSV Tabular Data के लिए उपयोगी है।

  • JSON Structured Data Store करने का लोकप्रिय Format है।


Important Definitions

File: Permanent Data Storage।

Mode: File खोलने का तरीका (r, w, a, x)।

Exception: Program के चलने के दौरान आने वाली Error।

try: Risk वाला Code Block।

except: Error आने पर चलने वाला Block।

finally: हमेशा चलने वाला Block।

CSV: Comma Separated Values File।

JSON: Key-Value आधारित Data Exchange Format।


Common Mistakes Students Make

  1. File खोलकर close() करना भूल जाना (इसलिए with का उपयोग बेहतर है)।

  2. w Mode का उपयोग करके गलती से पुराना Data मिटा देना।

  3. r Mode में ऐसी File खोलना जो मौजूद नहीं है (FileNotFoundError)।

  4. सभी Errors के लिए केवल except: लिख देना, जबकि Specific Exceptions बेहतर होती हैं।

  5. try Block में बहुत अधिक Code डाल देना, जिससे Error का Source ढूँढना कठिन हो जाता है।

  6. JSON File में Invalid Format लिख देना।

  7. CSV में newline="" देना भूल जाना (Windows पर Extra Blank Lines आ सकती हैं)।


Practice Questions (With Answers)

1. File खोलने के लिए कौन-सा Function उपयोग होता है?

Answer: open()

2. w Mode का क्या काम है?

Answer: File में नया Data लिखना; यदि File पहले से मौजूद है तो उसका पुराना Data मिटा देना।

3. a Mode का क्या उपयोग है?

Answer: File के अंत में नया Data जोड़ना।

4. with Statement का मुख्य लाभ क्या है?

Answer: File अपने आप Close हो जाती है।

5. try-except का उपयोग क्यों किया जाता है?

Answer: Program को Error आने पर Crash होने से बचाने के लिए।

6. finally कब Execute होता है?

Answer: हमेशा, चाहे Error आए या न आए।

7. CSV का पूरा नाम क्या है?

Answer: Comma Separated Values।

8. JSON का पूरा नाम क्या है?

Answer: JavaScript Object Notation।

9. नीचे दिए गए Code का Output क्या होगा?

try:
    print(10 / 2)
except:
    print("Error")
else:
    print("Done")

Answer:

5.0
Done

10. किस Mode में नई File तभी बनेगी जब वह पहले से मौजूद न हो?

Answer: x


🎯 Homework

  1. एक Diary App बनाइए जिसमें User की Notes diary.txt में Save हों।

  2. एक Student Result System बनाइए जो Student का Name और Marks CSV File में Store करे।

  3. एक Program लिखिए जो JSON File में Student की जानकारी Save और Read दोनों करे।

  4. ऐसा Program बनाइए जो User से Number लेकर Division करे और ZeroDivisionError तथा ValueError को अलग-अलग Handle करे।

  5. एक Mini Expense Tracker बनाइए जिसमें Date, Item और Amount File में Save हों।


📌 अगले Part 11 में हम सीखेंगे:

🚀 Object-Oriented Programming (OOP) in Python

  • Class और Object

  • Constructor (__init__)

  • Instance Variables

  • Instance Methods

  • Class Variables

  • Static Methods

  • Inheritance

  • Polymorphism

  • Encapsulation

  • Abstraction

  • Magic (Dunder) Methods

  • 20+ Real-World Projects (Bank System, Student Management, Library System, ATM, Employee Management)

OOP सीखने के बाद आप बड़े और Professional Software बनाना शुरू कर पाएंगे। यही Concept Django, Flask, Automation, Game Development और Enterprise Applications में सबसे अधिक उपयोग होता है।


🐍 Python Complete Course

Part 11 – Object-Oriented Programming (OOP) in Python (Complete Mastery)

Level: Intermediate → Advanced
Duration: 5–6 Hours
Goal: इस Chapter के बाद आप Professional तरीके से Classes और Objects का उपयोग करके बड़े Software Projects बनाना सीख जाएंगे। OOP Python, Django, Flask, Machine Learning, Automation और Enterprise Applications की सबसे महत्वपूर्ण Foundation है।


📚 आज हम क्या सीखेंगे?

🟢 Section A – OOP Basics

  • OOP क्या है?

  • Procedural Programming vs OOP

  • Class

  • Object

  • Class बनाना

  • Object बनाना


🔵 Section B – Constructor & Methods

  • __init__() Constructor

  • self Keyword

  • Instance Variables

  • Instance Methods

  • Class Variables

  • Class Methods

  • Static Methods


🟣 Section C – OOP Concepts

  • Inheritance

  • Method Overriding

  • Polymorphism

  • Encapsulation

  • Abstraction

  • Multiple Inheritance

  • Multilevel Inheritance

  • Hierarchical Inheritance


🔴 Section D – Advanced OOP

  • Magic (Dunder) Methods

  • Composition

  • Aggregation

  • super()

  • Property Decorator

  • @classmethod

  • @staticmethod


🟠 Section E – Real Projects

  • Student Management System

  • Bank Management System

  • ATM Simulation

  • Library Management

  • Employee Management


🟢 Section A – OOP Basics

Section 1 – OOP क्या है?

OOP (Object-Oriented Programming) एक Programming Style है जिसमें हम Real World Objects को Code के रूप में Represent करते हैं।


Real Life Example

मान लीजिए एक Car है।

Car की

Properties

  • Color

  • Brand

  • Model

  • Speed

Behaviors

  • Start

  • Stop

  • Brake

  • Accelerate

Python में भी यही Concept है।

Properties = Variables

Behaviors = Functions (Methods)


Section 2 – Procedural Programming vs OOP

ProceduralOOP
Functions पर आधारितObjects पर आधारित
छोटे Programsबड़े Projects
Data अलगData + Methods साथ
Maintain करना कठिनMaintain करना आसान

Real Life Example

एक School में

500 Students हैं।

Procedural में

सभी Students का Data अलग-अलग Variables में रखना पड़ेगा।

OOP में

Student Class बनाकर

500 Objects बनाए जा सकते हैं।


Section 3 – Class क्या है?

Class एक Blueprint (नक्शा) होती है।


Real Life Example

House Map

उस Map से

100 Houses बन सकते हैं।

Map = Class

House = Object


Syntax

class Student:
    pass

Section 4 – Object क्या है?

Object

Class का वास्तविक Instance होता है।


Example

class Student:
    pass

student1 = Student()
student2 = Student()

यहाँ

Student = Class

student1 = Object

student2 = Object


🔵 Section B – Constructor

Section 5 – Constructor (__init__())

जब Object बनता है

तो Constructor अपने आप Execute होता है।


Example

class Student:

    def __init__(self):
        print("Object Created")

student = Student()

Output

Object Created

Real Life Example

जब नया Mobile खरीदते हैं

तो Factory पहले से उसका Basic Setup कर देती है।

Constructor भी वही Initial Setup करता है।


Section 6 – self Keyword

self वर्तमान Object को Represent करता है।


Example

class Student:

    def __init__(self,name):

        self.name = name

student = Student("Ajay")

print(student.name)

Output

Ajay

Section 7 – Instance Variables

class Student:

    def __init__(self,name,age):

        self.name = name

        self.age = age

हर Object का अलग-अलग Data होगा।


Section 8 – Instance Method

class Student:

    def __init__(self,name):

        self.name = name

    def show(self):

        print(self.name)

student = Student("Ajay")

student.show()

Section 9 – Class Variable

class Student:

    school = "ABC School"

    def __init__(self,name):

        self.name = name

यह सभी Objects के लिए Common रहेगा।


Section 10 – Class Method

class Student:

    school = "ABC"

    @classmethod

    def change_school(cls,new_name):

        cls.school = new_name

Section 11 – Static Method

class Calculator:

    @staticmethod

    def add(a,b):

        return a+b

print(Calculator.add(10,20))

Output

30

🟣 Section C – Inheritance

Inheritance क्या है?

एक Class दूसरी Class की Properties और Methods प्राप्त कर ले।


Real Life Example

Father

Son

Son को

Family Name

Property

कुछ गुण

मिल जाते हैं।


Example

class Animal:

    def sound(self):

        print("Animal Sound")

class Dog(Animal):

    pass

dog = Dog()

dog.sound()

Output

Animal Sound

Method Overriding

class Animal:

    def sound(self):

        print("Animal")

class Dog(Animal):

    def sound(self):

        print("Bark")

dog = Dog()

dog.sound()

Output

Bark

Polymorphism

एक ही Method

अलग-अलग व्यवहार करे।


Example

class Bird:

    def sound(self):

        print("Bird")

class Crow(Bird):

    def sound(self):

        print("Caw")

class Parrot(Bird):

    def sound(self):

        print("Hello")

Encapsulation

Data को सुरक्षित रखना।


Example

class Bank:

    def __init__(self):

        self.__balance = 5000

Double Underscore (__) Private Variable बनाता है।


Abstraction

ज़रूरी चीजें दिखाना

जटिल Details छुपाना।


Real Life Example

Car चलाने के लिए Engine का पूरा Design जानना जरूरी नहीं।

बस Steering और Accelerator का उपयोग करना होता है।


Multiple Inheritance

class Father:

    pass

class Mother:

    pass

class Child(Father,Mother):

    pass

Multilevel Inheritance

class A:

    pass

class B(A):

    pass

class C(B):

    pass

Hierarchical Inheritance

class Animal:

    pass

class Dog(Animal):

    pass

class Cat(Animal):

    pass

🔴 Section D – super()

class Animal:

    def __init__(self):

        print("Animal")

class Dog(Animal):

    def __init__(self):

        super().__init__()

        print("Dog")

Dog()

Output

Animal

Dog

Magic (Dunder) Methods

कुछ विशेष Methods जिन्हें Python अपने आप Call करता है।

Examples

__init__()

__str__()

__len__()

__repr__()

__str__() Example

class Student:
    def __init__(self, name):
        self.name = name

    def __str__(self):
        return f"Student(Name={self.name})"

student = Student("Ajay")
print(student)

Output

Student(Name=Ajay)

Property Decorator

class Student:

    def __init__(self,name):

        self._name = name

    @property

    def name(self):

        return self._name

🟠 Section E – Mini Projects

Project 1 – Student Class

class Student:

    def __init__(self,name,marks):

        self.name = name

        self.marks = marks

    def display(self):

        print(self.name,self.marks)

student = Student("Ajay",95)

student.display()

Project 2 – Bank Account

class BankAccount:

    def __init__(self,balance):

        self.balance = balance

    def deposit(self,amount):

        self.balance += amount

    def withdraw(self,amount):

        if amount <= self.balance:
            self.balance -= amount
        else:
            print("Insufficient Balance")

    def show_balance(self):

        print("Balance:", self.balance)

account = BankAccount(5000)

account.deposit(1000)

account.withdraw(2000)

account.show_balance()

Project 3 – Employee

class Employee:

    def __init__(self,name,salary):

        self.name = name

        self.salary = salary

    def yearly_salary(self):

        return self.salary * 12

emp = Employee("Ajay",30000)

print(emp.yearly_salary())

Key Concepts Summary

  • Class एक Blueprint है।

  • Object Class का Instance होता है।

  • __init__() Constructor Object बनने पर अपने आप चलता है।

  • self वर्तमान Object को दर्शाता है।

  • Instance Variables हर Object के लिए अलग होती हैं।

  • Class Variables सभी Objects में साझा होती हैं।

  • Inheritance से Code Reuse होता है।

  • Polymorphism एक ही Interface के अलग-अलग व्यवहार की अनुमति देता है।

  • Encapsulation Data को सुरक्षित रखता है।

  • Abstraction जटिलता को छुपाकर सरल Interface देता है।

  • super() Parent Class के Methods को Call करने के लिए उपयोग होता है।


Important Definitions

Class: Object बनाने का Blueprint।

Object: Class का वास्तविक Instance।

Constructor: Object बनते समय चलने वाला विशेष Method।

Inheritance: Parent Class से गुण प्राप्त करना।

Polymorphism: एक ही Method का अलग-अलग व्यवहार।

Encapsulation: Data और Methods को एक साथ रखना तथा Data को सुरक्षित रखना।

Abstraction: केवल आवश्यक जानकारी दिखाना और Implementation Details छुपाना।

Magic Methods: Python द्वारा विशेष परिस्थितियों में अपने आप Call किए जाने वाले Methods।


Common Mistakes Students Make

  1. self Parameter लिखना भूल जाना।

  2. Constructor का नाम init() लिख देना, जबकि सही नाम __init__() है।

  3. Class Variable और Instance Variable में अंतर न समझना।

  4. Parent Constructor Call करने के लिए super() का उपयोग न करना।

  5. Private Variable (__balance) को सीधे Access करने की कोशिश करना।

  6. Inheritance और Composition को एक जैसा समझ लेना।

  7. Object बनाए बिना Instance Method Call करने की कोशिश करना।


Practice Questions (With Answers)

1. OOP का पूरा नाम क्या है?

Answer: Object-Oriented Programming।

2. Class क्या है?

Answer: Objects बनाने का Blueprint।

3. Object क्या है?

Answer: Class का Instance।

4. Constructor का नाम क्या होता है?

Answer: __init__()

5. self किसे Represent करता है?

Answer: वर्तमान Object (Current Instance) को।

6. Code Reuse के लिए कौन-सा OOP Concept सबसे अधिक उपयोगी है?

Answer: Inheritance।

7. Data को सुरक्षित रखने वाला Concept कौन-सा है?

Answer: Encapsulation।

8. super() का उपयोग क्यों किया जाता है?

Answer: Parent Class के Constructor या Methods को Call करने के लिए।

9. नीचे दिए गए Code का Output क्या होगा?

class Demo:
    def __init__(self):
        print("Hello")

Demo()

Answer:

Hello

10. Polymorphism का क्या अर्थ है?

Answer: एक ही Method या Interface का अलग-अलग Objects में अलग व्यवहार होना।


🎯 Homework

  1. Student Management System बनाइए जिसमें Student का Name, Roll Number और Marks Store हों।

  2. Bank Account Class बनाइए जिसमें Deposit, Withdraw और Balance Check Methods हों।

  3. Library Management System बनाइए जिसमें Book Issue और Return की सुविधा हो।

  4. Inheritance का उपयोग करके VehicleCarElectricCar Classes बनाइए।

  5. __str__() Method का उपयोग करके किसी Object को सुंदर Format में Print कीजिए।


📌 अगले Part 12 में हम सीखेंगे:

🚀 Python Modules, Packages & Standard Library

  • Modules क्या हैं?

  • import Statement

  • from ... import

  • Aliasing (as)

  • Built-in Modules (math, random, datetime, os, sys)

  • pip और Third-Party Packages

  • Virtual Environment (venv)

  • Package बनाना

  • Popular Libraries (NumPy, Pandas, Matplotlib का परिचय)

  • 25+ Practical Programs

  • Mini Projects

इस Chapter के बाद आप Python की शक्तिशाली Libraries का उपयोग करके Automation, Data Analysis, AI और Real-World Applications बनाना शुरू कर पाएंगे।


🐍 Python Complete Course

Part 12 – Python Modules, Packages & Standard Library (Complete Mastery)

Level: Intermediate → Advanced
Duration: 5–6 Hours
Goal: इस Chapter के बाद आप Python के Built-in Modules, Third-Party Libraries और Packages का उपयोग करके Professional Applications बनाना सीख जाएंगे। यही Concepts Automation, Data Science, Machine Learning, Web Development और AI की Foundation हैं।


📚 आज हम क्या सीखेंगे?

🟢 Section A – Python Modules

  • Module क्या है?

  • Module क्यों उपयोग करते हैं?

  • अपना Module बनाना

  • import

  • from ... import

  • as Keyword

  • dir()

  • help()


🔵 Section B – Python Packages

  • Package क्या है?

  • __init__.py

  • Package Import

  • Nested Packages


🟣 Section C – Standard Library

  • math

  • random

  • datetime

  • time

  • calendar

  • os

  • sys

  • platform

  • statistics


🔴 Section D – pip & Virtual Environment

  • pip

  • Install Packages

  • Upgrade Packages

  • Uninstall Packages

  • Virtual Environment (venv)


🟠 Section E – Popular Python Libraries

  • NumPy

  • Pandas

  • Matplotlib

  • Requests

  • BeautifulSoup

  • OpenCV (Introduction)


🟢 Section A – Python Modules

Section 1 – Module क्या है?

आसान भाषा में

Module एक Python File (.py) होती है जिसमें Functions, Variables और Classes लिखे होते हैं ताकि उन्हें दूसरे Programs में दोबारा उपयोग किया जा सके।


Real Life Example

मान लीजिए आपके घर में एक Tool Box है।

उसमें अलग-अलग Tools हैं—

  • Hammer

  • Screwdriver

  • Plier

जब ज़रूरत होती है, वही Tool निकालते हैं।

Python में Module भी ऐसा ही Tool Box है।


Section 2 – अपना Module बनाना

calculator.py

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

def sub(a, b):
    return a - b

def mul(a, b):
    return a * b

अब दूसरे Program में

import calculator

print(calculator.add(10, 20))

Output

30

Section 3 – import Statement

import math

print(math.sqrt(25))

Output

5.0

Section 4 – from ... import

from math import sqrt

print(sqrt(49))

Output

7.0

Section 5 – Alias (as)

import math as m

print(m.pi)

Output

3.141592653589793

फायदा

लंबा नाम छोटा हो जाता है।


Section 6 – dir()

Module के अंदर क्या-क्या है?

import math

print(dir(math))

Section 7 – help()

import math

help(math.sqrt)

Documentation दिखाता है।


🔵 Section B – Package

Package क्या है?

Package

Modules का Collection होता है।


Example

myproject/

|

|-- calculator.py

|-- student.py

|-- teacher.py

|-- __init__.py

Real Life Example

एक Library में

Books

Subject Wise

Shelf

वैसे ही

Package

Modules


__init__.py

Package को Python Package बनाता है।


Import

from myproject import calculator

print(calculator.add(5,5))

🟣 Section C – Standard Library

1. math Module

import math

print(math.pi)

print(math.sqrt(64))

print(math.factorial(5))

Output

3.141592653589793

8.0

120

2. random Module

Random Number

import random

print(random.randint(1,10))

Random Choice

names=["Ajay","Rahul","Amit"]

print(random.choice(names))

Real Life Example

Lottery Winner चुनना।


3. datetime Module

from datetime import datetime

now = datetime.now()

print(now)

Current Date

print(now.date())

Current Time

print(now.time())

4. time Module

import time

print("Start")

time.sleep(3)

print("End")

Program 3 Seconds रुकेगा।


5. calendar Module

import calendar

print(calendar.month(2026,7))

पूरे महीने का Calendar।


6. os Module

Current Folder

import os

print(os.getcwd())

Folder List

print(os.listdir())

New Folder

os.mkdir("Python")

7. sys Module

import sys

print(sys.version)

Python Version


8. platform Module

import platform

print(platform.system())

Output

Windows

9. statistics Module

import statistics

numbers=[10,20,30]

print(statistics.mean(numbers))

Output

20

🔴 Section D – pip

pip क्या है?

pip

Python Package Manager है।


Package Install

pip install numpy

Upgrade

pip install --upgrade numpy

Uninstall

pip uninstall numpy

Installed Packages

pip list

Virtual Environment

Create

python -m venv myenv

Activate (Windows)

myenv\Scripts\activate

Deactivate

deactivate

Real Life Example

हर Project का अपना अलग Workspace।

एक Project की Libraries दूसरे Project को प्रभावित नहीं करतीं।


🟠 Section E – Popular Libraries

NumPy

Scientific Computing

import numpy as np

arr=np.array([1,2,3])

print(arr)

Pandas

Data Analysis

import pandas as pd

data={

"Name":["Ajay","Rahul"],

"Marks":[90,85]

}

df=pd.DataFrame(data)

print(df)

Matplotlib

Charts

import matplotlib.pyplot as plt

plt.plot([1,2,3],[10,20,30])

plt.show()

Requests

Website से Data लेना

import requests

response=requests.get("https://example.com")

print(response.status_code)

BeautifulSoup

HTML Parsing

from bs4 import BeautifulSoup

OpenCV

Computer Vision

import cv2

Image Processing

Face Detection

Object Detection


Mini Project 1

Random Password Generator

import random

chars="abcdefghijklmnopqrstuvwxyz123456789"

password=""

for i in range(8):

    password+=random.choice(chars)

print(password)

Mini Project 2

Current Date & Time

from datetime import datetime

print(datetime.now())

Mini Project 3

Calculator Module

calculator.py

def add(a,b):

    return a+b

main.py

import calculator

print(calculator.add(5,7))

Key Concepts Summary

  • Module एक Python File होती है।

  • Package Modules का Collection होता है।

  • import से Module उपयोग किया जाता है।

  • from ... import से किसी विशेष Function या Class को Import किया जा सकता है।

  • math, random, datetime, os, sys आदि Standard Library Modules हैं।

  • pip से Third-Party Packages Install किए जाते हैं।

  • venv प्रत्येक Project के लिए अलग Environment बनाता है।

  • NumPy, Pandas और Matplotlib Data Science की सबसे लोकप्रिय Libraries हैं।


Important Definitions

Module: Reusable Python File।

Package: Modules का Collection।

Standard Library: Python के साथ आने वाले Built-in Modules।

pip: Python Package Manager।

Virtual Environment: Project-specific Python Environment।

NumPy: Numerical Computing Library।

Pandas: Data Analysis Library।

Matplotlib: Data Visualization Library।


Common Mistakes Students Make

  1. File का नाम math.py या random.py रख देना, जिससे Built-in Module Import नहीं हो पाता।

  2. import के बाद Module Name गलत लिखना।

  3. Package Install किए बिना उसे Import करने की कोशिश करना (ModuleNotFoundError)।

  4. Virtual Environment Activate करना भूल जाना।

  5. pip और python अलग-अलग Versions के होने पर Confusion होना।

  6. Third-Party Library को Standard Library समझ लेना।

  7. Module और Package में अंतर न समझना।


Practice Questions (With Answers)

1. Module क्या है?

Answer: Reusable Python File जिसमें Functions, Classes और Variables होते हैं।

2. Package क्या है?

Answer: Modules का Collection।

3. import math का उपयोग क्यों किया जाता है?

Answer: math Module के Functions और Constants उपयोग करने के लिए।

4. math.sqrt(81) का Output क्या होगा?

Answer: 9.0

5. random.choice() का क्या उपयोग है?

Answer: किसी Sequence से Random Element चुनने के लिए।

6. pip का पूरा काम क्या है?

Answer: Python Packages को Install, Upgrade और Uninstall करना।

7. Virtual Environment क्यों उपयोग किया जाता है?

Answer: हर Project की Dependencies को अलग रखने के लिए।

8. Data Analysis के लिए सबसे लोकप्रिय Library कौन-सी है?

Answer: Pandas।

9. Chart बनाने के लिए कौन-सी Library उपयोग होती है?

Answer: Matplotlib।

10. os.getcwd() क्या Return करता है?

Answer: Current Working Directory।


🎯 Homework

  1. अपना calculator.py Module बनाकर उसे दूसरे Program में Import कीजिए।

  2. random Module का उपयोग करके Dice Simulator बनाइए।

  3. datetime Module से Digital Clock Program बनाइए।

  4. os Module से Current Folder की सभी Files Print कीजिए।

  5. pip का उपयोग करके numpy और pandas Install कीजिए तथा एक Simple DataFrame बनाइए।


📌 अगले Part 13 में हम सीखेंगे:

🌐 Python GUI Development (Tkinter)

  • GUI क्या है?

  • Tkinter Introduction

  • Labels

  • Buttons

  • Entry Box

  • Text Area

  • Checkbutton

  • Radiobutton

  • Listbox

  • Combobox

  • Menu Bar

  • Frames

  • Message Box

  • Event Handling

  • Calculator App

  • Notepad App

  • Login Form

  • Student Management GUI

Part 13 से आप पहली बार Python की मदद से Window आधारित Applications बनाना शुरू करेंगे। इसके बाद आप अपने खुद के Desktop Software तैयार कर सकेंगे।


🐍 Python Complete Course

Part 13 – Python GUI Development with Tkinter (Complete Mastery)

Level: Intermediate → Advanced
Duration: 6–7 Hours
Goal: इस Chapter के बाद आप Python की मदद से Professional Desktop Applications (GUI Apps) बनाना सीख जाएंगे। अब तक आपने Console Programs बनाए थे, अब आप Window, Buttons, Forms और Real Desktop Software बनाएंगे।


📚 आज हम क्या सीखेंगे?

🟢 Section A – GUI Basics

  • GUI क्या है?

  • CLI vs GUI

  • Tkinter क्या है?

  • पहली Window बनाना


🔵 Section B – Tkinter Widgets

  • Label

  • Button

  • Entry

  • Text

  • Frame

  • Checkbutton

  • Radiobutton

  • Listbox

  • Combobox

  • Spinbox

  • Scale


🟣 Section C – Layout Management

  • pack()

  • grid()

  • place()


🔴 Section D – Events & Dialog Boxes

  • Event Handling

  • Message Box

  • File Dialog

  • Color Chooser


🟠 Section E – Mini Projects

  • Calculator

  • Login Form

  • Student Registration Form

  • Notepad

  • Digital Clock


🟢 Section A – GUI Basics

Section 1 – GUI क्या है?

GUI का पूरा नाम है:

Graphical User Interface

यह ऐसा Interface है जहाँ User Mouse और Keyboard की मदद से Window, Button, Menu और Text Box का उपयोग करता है।


Real Life Example

जब आप

  • Calculator

  • Paint

  • Notepad

  • Chrome

  • MS Word

खोलते हैं,

तो जो Window दिखाई देती है, वही GUI है।


CLI vs GUI

CLIGUI
Keyboard आधारितMouse + Keyboard
Text आधारितWindow आधारित
Beginner के लिए कठिनUser Friendly
कम Graphicsआकर्षक Interface

Tkinter क्या है?

Tkinter Python की Built-in GUI Library है।

इससे आप

  • Desktop Software

  • Forms

  • Calculator

  • Billing Software

  • Attendance System

  • School Management System

बना सकते हैं।


पहली Window

import tkinter as tk

root = tk.Tk()

root.title("My First App")

root.geometry("500x300")

root.mainloop()

Output

+-----------------------------+
|       My First App          |
|                             |
|                             |
|                             |
+-----------------------------+

समझिए

root = tk.Tk()

Window बनाता है।


root.title()

Window का नाम बदलता है।


root.geometry()

Window का Size तय करता है।


root.mainloop()

Window को चालू रखता है।


🔵 Section B – Widgets

Widget मतलब GUI का कोई भी Component।

जैसे

  • Button

  • Label

  • Textbox


Label

import tkinter as tk

root = tk.Tk()

label = tk.Label(root, text="Welcome to Python")

label.pack()

root.mainloop()

Button

import tkinter as tk

root = tk.Tk()

button = tk.Button(root, text="Click Me")

button.pack()

root.mainloop()

Button Event

import tkinter as tk

def hello():
    print("Button Clicked")

root = tk.Tk()

button = tk.Button(root, text="Click", command=hello)

button.pack()

root.mainloop()

Real Life Example

Door Bell

Button दबाया

Bell बजी

Button Event भी यही करता है।


Entry Widget

import tkinter as tk

root = tk.Tk()

entry = tk.Entry(root)

entry.pack()

root.mainloop()

User Text लिख सकता है।


Entry से Data लेना

name = entry.get()

Text Widget

text = tk.Text(root, height=10, width=40)

Long Notes लिखने के लिए।


Frame

frame = tk.Frame(root)

GUI को Sections में Divide करता है।


Checkbutton

check = tk.Checkbutton(root, text="Python")

Radiobutton

radio = tk.Radiobutton(root, text="Male")

Listbox

listbox = tk.Listbox(root)

Items जोड़ना

listbox.insert(1,"Python")
listbox.insert(2,"Java")

Combobox

from tkinter import ttk

combo = ttk.Combobox(root)

combo["values"] = ["Python","Java","C++"]

Spinbox

spin = tk.Spinbox(root, from_=1, to=100)

Scale

scale = tk.Scale(root, from_=0, to=100)

🟣 Section C – Layout Managers

Tkinter में Widget रखने के तीन तरीके हैं।


pack()

सबसे आसान।

button.pack()

grid()

Table जैसा Layout।

label.grid(row=0,column=0)

place()

Exact Position

button.place(x=100,y=50)

Comparison

MethodUse
pack()Simple GUI
grid()Forms
place()Fixed Position

🔴 Section D – Event Handling

जब User कोई Action करे

जैसे

  • Button Click

  • Key Press

  • Mouse Click

उसे Event कहते हैं।


Example

import tkinter as tk

def show():

    print("Hello")

root = tk.Tk()

button = tk.Button(root,text="Click",command=show)

button.pack()

root.mainloop()

Message Box

from tkinter import messagebox

messagebox.showinfo("Info","Saved Successfully")

Error Box

messagebox.showerror("Error","Wrong Password")

Warning

messagebox.showwarning("Warning","Low Battery")

Real Life Example

जब Windows कहता है

"File Saved Successfully"

वह Message Box है।


File Dialog

from tkinter import filedialog

file = filedialog.askopenfilename()

Color Chooser

from tkinter import colorchooser

color = colorchooser.askcolor()

🟠 Mini Projects

Project 1 – Simple Calculator

import tkinter as tk

def add():
    result.config(
        text=int(num1.get()) + int(num2.get())
    )

root = tk.Tk()

num1 = tk.Entry(root)
num2 = tk.Entry(root)

result = tk.Label(root)

button = tk.Button(root,text="Add",command=add)

num1.pack()
num2.pack()
button.pack()
result.pack()

root.mainloop()

Project 2 – Login Form

Username

Password

Login Button

Features

✅ Username

✅ Password

✅ Login Button


Project 3 – Student Registration

Fields

  • Name

  • Roll

  • Class

  • Mobile

Submit Button


Project 4 – Notepad

Features

  • Write Notes

  • Save

  • Open

  • Exit


Project 5 – Digital Clock

12:45:32 PM

हर Second Update होगी।


Mini Project 6 – Temperature Converter

  • Celsius → Fahrenheit

  • Fahrenheit → Celsius

  • Convert Button

  • Clear Button


Mini Project 7 – BMI Calculator

Input:

  • Height

  • Weight

Output:

  • BMI

  • Health Category


Mini Project 8 – To-Do List App

Features:

  • Add Task

  • Delete Task

  • Mark Complete

  • Save Tasks


Mini Project 9 – Quiz App

Features:

  • Multiple Choice Questions

  • Next Button

  • Score Display


Mini Project 10 – Expense Tracker GUI

Features:

  • Date

  • Amount

  • Category

  • Save to CSV

  • Total Expense


Key Concepts Summary

  • GUI का अर्थ Graphical User Interface है।

  • Tkinter Python की Built-in GUI Library है।

  • Tk() मुख्य Window बनाता है।

  • mainloop() Window को चालू रखता है।

  • Widgets GUI के Components होते हैं।

  • pack(), grid() और place() Layout Managers हैं।

  • Events User की Actions होती हैं।

  • messagebox सूचना, Warning और Error दिखाने के लिए उपयोग होता है।

  • filedialog File चुनने के लिए उपयोग होता है।

  • Tkinter की मदद से Desktop Applications बनाई जा सकती हैं।


Important Definitions

GUI: Graphical User Interface।

Widget: GUI का कोई भी Component (Button, Label, Entry आदि)।

Event: User द्वारा किया गया Action।

Layout Manager: Widgets को Window में व्यवस्थित करने का तरीका।

Message Box: Popup Dialog जो सूचना या Error दिखाता है।

Frame: Widgets को Group करने वाला Container।


Common Mistakes Students Make

  1. mainloop() लिखना भूल जाना, जिससे Window तुरंत बंद हो जाती है।

  2. command=hello() लिख देना; सही है command=hello (Function Call नहीं, Function Reference देना होता है)।

  3. pack() और grid() को एक ही Parent Widget में मिलाकर उपयोग करना (आमतौर पर इससे Layout Error आता है)।

  4. Entry.get() से Value लेने के बाद Type Conversion (int(), float()) करना भूल जाना।

  5. Widgets बनाकर उन्हें Layout Manager (pack(), grid(), place()) से Window में न जोड़ना।

  6. Event Function में आवश्यक Parameters या Logic न देना।

  7. GUI Logic और Business Logic को एक ही Function में बहुत बड़ा बना देना।


Practice Questions (With Answers)

1. GUI का पूरा नाम क्या है?

Answer: Graphical User Interface।

2. Python की Built-in GUI Library कौन-सी है?

Answer: Tkinter।

3. Window बनाने के लिए कौन-सा Function उपयोग होता है?

Answer: tk.Tk()

4. mainloop() का क्या काम है?

Answer: Window को खुला और Responsive रखना।

5. User से Text Input लेने के लिए कौन-सा Widget उपयोग होता है?

Answer: Entry

6. Button Click होने पर Function चलाने के लिए कौन-सा Parameter उपयोग होता है?

Answer: command

7. Form बनाने के लिए कौन-सा Layout Manager सबसे अधिक उपयोगी है?

Answer: grid()

8. Popup Information दिखाने के लिए कौन-सा Module उपयोग होता है?

Answer: messagebox

9. File चुनने के लिए कौन-सा Module उपयोग होता है?

Answer: filedialog

10. Tkinter में GUI का सबसे छोटा Program किन चार Steps से बनता है?

Answer: Tk() → Widgets → Layout → mainloop()


🎯 Homework

  1. अपना Login Form बनाइए जिसमें Username और Password हों।

  2. Calculator GUI बनाइए जिसमें Addition, Subtraction, Multiplication और Division हों।

  3. Student Registration Form बनाकर Data CSV File में Save कीजिए।

  4. Digital Clock बनाइए जो हर Second Update हो।

  5. To-Do List App बनाइए जिसमें Tasks Add, Delete और Save की जा सकें।


📌 अगले Part 14 में हम सीखेंगे:

🌍 Database Programming with SQLite & MySQL

  • Database क्या है?

  • DBMS और RDBMS

  • SQLite Introduction

  • MySQL Introduction

  • SQL Basics (CREATE, INSERT, SELECT, UPDATE, DELETE)

  • Python + SQLite

  • Python + MySQL

  • CRUD Operations

  • Student Database Project

  • Inventory Management System

  • Employee Management System

  • Authentication System

Part 14 के बाद आप Database से Connected Professional Applications बनाना सीख जाएंगे। यह Web Development, Desktop Software, ERP, CRM और Enterprise Applications का सबसे महत्वपूर्ण हिस्सा है।


 

🐍 Python Complete Course

Part 14 – Database Programming with SQLite & MySQL (Complete Mastery)

Level: Intermediate → Advanced
Duration: 6–8 Hours
Goal: इस Chapter के बाद आप Python को Database से Connect करना, Data Store करना, Retrieve करना, Update करना और Delete करना सीख जाएंगे। यही Skills Professional Software, Web Applications, ERP, CRM और Banking Systems में उपयोग होती हैं।


📚 आज हम क्या सीखेंगे?

🟢 Section A – Database Basics

  • Database क्या है?

  • DBMS क्या है?

  • RDBMS क्या है?

  • SQL क्या है?

  • Primary Key

  • Foreign Key


🔵 Section B – SQLite

  • SQLite Introduction

  • Database बनाना

  • Table बनाना

  • CRUD Operations


🟣 Section C – MySQL

  • MySQL Installation

  • Python से Connect करना

  • CRUD Operations


🔴 Section D – SQL Commands

  • CREATE

  • INSERT

  • SELECT

  • UPDATE

  • DELETE

  • WHERE

  • ORDER BY

  • LIMIT


🟠 Section E – Mini Projects

  • Student Management System

  • Library Management

  • Inventory Management

  • Employee Database


🟢 Section A – Database Basics

Section 1 – Database क्या है?

Database एक ऐसी जगह है जहाँ Data को व्यवस्थित (Organized) तरीके से Store किया जाता है।


Real Life Example

एक School में हजारों Students का Data होता है।

अगर सब कुछ Notebook में लिखा जाए...

तो ढूँढना मुश्किल होगा।

लेकिन Database में

  • Name

  • Roll Number

  • Class

  • Marks

कुछ Seconds में मिल जाता है।


Database कहाँ उपयोग होता है?

  • Banking

  • Railway Reservation

  • Facebook

  • Instagram

  • WhatsApp

  • Hospital

  • School

  • E-commerce


Section 2 – DBMS क्या है?

DBMS

Database Management System

Database को Manage करने वाला Software।

Examples

  • SQLite

  • MySQL

  • PostgreSQL

  • Oracle


Section 3 – RDBMS

RDBMS

Relational Database Management System

यह Tables के माध्यम से Data Store करता है।


Example

Students Table

IDNameMarks
1Ajay95
2Rahul90

SQL क्या है?

SQL

Structured Query Language

Database से बात करने की भाषा।


Real Life Example

Database = Library

SQL = Librarian को दिया गया Instruction


Primary Key

Primary Key

हर Record की Unique पहचान होती है।

ID

1

2

3

दो Students का ID समान नहीं हो सकता।


Foreign Key

एक Table को दूसरी Table से जोड़ती है।

Example

Students Table

Courses Table

StudentID

Student Table से जुड़ा।


🔵 Section B – SQLite

SQLite क्या है?

SQLite

Python के साथ Built-in आता है।

कोई अलग Server नहीं चाहिए।


Import

import sqlite3

Database बनाना

import sqlite3

conn = sqlite3.connect("school.db")

अगर Database नहीं होगा

तो Python खुद बना देगा।


Cursor

cursor = conn.cursor()

Cursor

SQL Commands Execute करता है।


Table बनाना

cursor.execute("""

CREATE TABLE students(

id INTEGER PRIMARY KEY,

name TEXT,

marks INTEGER

)

""")

Data Insert

cursor.execute(

"INSERT INTO students VALUES(1,'Ajay',95)"

)

conn.commit()

Select Data

cursor.execute(

"SELECT * FROM students"

)

rows = cursor.fetchall()

print(rows)

Output

[(1,'Ajay',95)]

Update

cursor.execute(

"UPDATE students SET marks=98 WHERE id=1"

)

conn.commit()

Delete

cursor.execute(

"DELETE FROM students WHERE id=1"

)

conn.commit()

Database Close

conn.close()

🔴 Section C – SQL Commands

CREATE TABLE

CREATE TABLE students(

id INTEGER PRIMARY KEY,

name TEXT,

marks INTEGER

);

INSERT

INSERT INTO students

VALUES

(1,'Ajay',95);

SELECT

SELECT * FROM students;

WHERE

SELECT *

FROM students

WHERE marks>80;

ORDER BY

SELECT *

FROM students

ORDER BY marks DESC;

LIMIT

SELECT *

FROM students

LIMIT 5;

UPDATE

UPDATE students

SET marks=100

WHERE id=1;

DELETE

DELETE FROM students

WHERE id=2;

🟣 Section D – MySQL

MySQL क्या है?

MySQL

एक Powerful Database Server है।

बड़ी Websites में उपयोग होता है।


Examples

  • Amazon

  • Flipkart

  • Hospital Software

  • Banking Systems


Install Package

pip install mysql-connector-python

Connect MySQL

import mysql.connector

conn = mysql.connector.connect(

host="localhost",

user="root",

password="1234",

database="school"

)

Cursor

cursor = conn.cursor()

Select

cursor.execute(

"SELECT * FROM students"

)

print(cursor.fetchall())

Insert

cursor.execute(

"INSERT INTO students VALUES(%s,%s,%s)",

(2,"Rahul",88)

)

conn.commit()

क्यों %s?

क्योंकि इससे SQL Injection जैसी समस्याओं से बचाव होता है और Values सुरक्षित तरीके से भेजी जाती हैं।


🔵 CRUD

CRUD का अर्थ

Create

Read

Update

Delete


यही चार Operations

हर Software में होते हैं।


🟠 Mini Project 1

Student Database

Features

  • Add Student

  • Search Student

  • Delete Student

  • Update Marks


Mini Project 2

Employee Database

Fields

  • ID

  • Name

  • Salary

  • Department


Mini Project 3

Library System

Books

Issue

Return

Student Record


Mini Project 4

Inventory Management

  • Product

  • Quantity

  • Price

  • Stock


Mini Project 5

Login System

Username

Password

Database Verification


Real Life Example

ATM Machine

Card Insert

Database से Verify

PIN Match

Balance Show


Instagram Login

Username

Database Check

Password Verify

Login Success


Key Concepts Summary

  • Database Data को Organized तरीके से Store करता है।

  • DBMS Database को Manage करता है।

  • RDBMS Tables के माध्यम से Data Store करता है।

  • SQL Database से संवाद करने की भाषा है।

  • SQLite Lightweight Database है और Python के साथ उपलब्ध है।

  • MySQL Server आधारित Database है, जो बड़े Applications के लिए उपयुक्त है।

  • CRUD Operations किसी भी Database Application की Foundation हैं।

  • commit() Data को स्थायी रूप से Save करता है।

  • close() Connection को सुरक्षित तरीके से बंद करता है।


Important Definitions

Database: Organized Data Collection।

DBMS: Database Management System।

RDBMS: Relational Database Management System।

SQL: Structured Query Language।

Primary Key: प्रत्येक Record की Unique पहचान।

Foreign Key: दो Tables के बीच संबंध स्थापित करने वाली Key।

Cursor: SQL Commands Execute करने वाला Object।

CRUD: Create, Read, Update, Delete।


Common Mistakes Students Make

  1. INSERT, UPDATE या DELETE के बाद commit() करना भूल जाना।

  2. Database Connection close() न करना।

  3. WHERE Clause भूल जाना, जिससे सभी Records Update या Delete हो सकते हैं।

  4. SQL Query में User Input को सीधे String जोड़कर लिखना (Parameterized Queries का उपयोग करें)।

  5. SQLite और MySQL के Connection Syntax में अंतर भूल जाना।

  6. Primary Key के लिए Duplicate Value Insert करने की कोशिश करना।

  7. fetchone() और fetchall() में अंतर न समझना।


Practice Questions (With Answers)

1. Database क्या है?

Answer: Data को Organized तरीके से Store करने की प्रणाली।

2. DBMS का पूरा नाम क्या है?

Answer: Database Management System।

3. SQL का पूरा नाम क्या है?

Answer: Structured Query Language।

4. CRUD में "R" का क्या अर्थ है?

Answer: Read।

5. SQLite को उपयोग करने के लिए Python में कौन-सा Module Import किया जाता है?

Answer: sqlite3

6. commit() का क्या कार्य है?

Answer: Database में किए गए Changes को स्थायी रूप से Save करना।

7. Primary Key की सबसे महत्वपूर्ण विशेषता क्या है?

Answer: प्रत्येक Record के लिए Unique होती है।

8. SELECT * FROM students; क्या करता है?

Answer: students Table के सभी Records दिखाता है।

9. MySQL से Connect करने के लिए कौन-सा Package उपयोग किया जाता है?

Answer: mysql-connector-python

10. Parameterized Query (%s) का उपयोग क्यों किया जाता है?

Answer: सुरक्षित तरीके से Values भेजने और SQL Injection जैसी समस्याओं से बचने के लिए।


🎯 Homework

  1. SQLite का उपयोग करके Student Management System बनाइए जिसमें Add, Search, Update और Delete की सुविधा हो।

  2. MySQL में एक employees Table बनाकर उसमें कम से कम 5 Records Insert कीजिए।

  3. ऐसा Program लिखिए जो Highest Marks वाले Student का Record दिखाए।

  4. Inventory Management Database बनाइए जिसमें Product, Quantity और Price Store हों।

  5. Login Form (Tkinter) को SQLite Database से जोड़कर Username और Password Verify कीजिए।


📌 अगले Part 15 में हम सीखेंगे:

🌐 Web Development with Python (Flask)

  • Web Development क्या है?

  • Client–Server Architecture

  • HTTP Request & Response

  • Flask Introduction

  • Routes

  • Templates (Jinja2)

  • HTML + CSS + Flask

  • Forms

  • GET & POST Methods

  • SQLite Integration

  • User Authentication

  • Sessions

  • REST API का परिचय

  • Blog Project

  • Student Management Web App

  • Login & Registration System

Part 15 से आप Python का उपयोग करके अपनी पहली Website और Web Application बनाना शुरू करेंगे। यही Skills Freelancing, Startup Development और Full-Stack Python Development की शुरुआत हैं।


🐍 Python Complete Course

Part 15 – Web Development with Python (Flask) (Complete Mastery)

Level: Advanced
Duration: 8–10 Hours
Goal: इस Chapter के बाद आप Python की मदद से Professional Websites और Web Applications बनाना सीख जाएंगे। यही Skills Freelancing, Startup Development, SaaS Products और Full-Stack Python Development की शुरुआत हैं।


📚 आज हम क्या सीखेंगे?

🟢 Section A – Web Development Basics

  • Web Development क्या है?

  • Website vs Web Application

  • Frontend vs Backend

  • Client–Server Architecture

  • HTTP क्या है?

  • Request और Response


🔵 Section B – Flask Introduction

  • Flask क्या है?

  • Flask Install करना

  • पहला Flask App

  • Routing

  • URL Parameters

  • Debug Mode


🟣 Section C – Templates & Forms

  • Jinja2 Templates

  • HTML + Flask

  • CSS जोड़ना

  • Static Folder

  • Forms

  • GET Method

  • POST Method


🔴 Section D – Database Integration

  • Flask + SQLite

  • CRUD Operations

  • User Registration

  • Login System

  • Sessions

  • Logout


🟠 Section E – Mini Projects

  • Personal Portfolio Website

  • Student Management System

  • Blog Website

  • Login & Registration System

  • To-Do Web App


🟢 Section A – Web Development Basics

Section 1 – Web Development क्या है?

Web Development का अर्थ है Website या Web Application बनाना।


Real Life Examples

आप रोज़ जिन Websites का उपयोग करते हैं—

  • Google

  • YouTube

  • Facebook

  • Instagram

  • Amazon

ये सभी Web Development की मदद से बनाई गई हैं।


Website vs Web Application

WebsiteWeb Application
केवल जानकारी दिखाती हैUser Interaction होता है
Static हो सकती हैDynamic होती है
Example: PortfolioExample: Gmail, Facebook

Frontend vs Backend

FrontendBackend
User को दिखाई देता हैServer पर चलता है
HTML, CSS, JavaScriptPython, Flask, Django

Real Life Example

Restaurant

  • Menu = Frontend

  • Kitchen = Backend

Customer केवल Menu देखता है।

लेकिन खाना Kitchen में बनता है।


Client–Server Architecture

Browser (Client)
        │
 HTTP Request
        │
        ▼
Server (Flask)
        │
Process Request
        │
 HTTP Response
        ▼
Browser

HTTP क्या है?

HTTP का पूरा नाम

HyperText Transfer Protocol

Browser और Server के बीच Communication का तरीका।


Request और Response

जब Browser Data मांगता है

Request

Server जवाब देता है

Response


Real Life Example

Restaurant

Customer Order देता है

Kitchen खाना बनाती है

Food वापस आता है


🔵 Section B – Flask Introduction

Flask क्या है?

Flask

Python का Lightweight Web Framework है।

इसकी मदद से

  • Website

  • REST API

  • Dashboard

  • Admin Panel

  • Blog

बनाए जा सकते हैं।


Flask Install

pip install flask

पहला Flask Program

from flask import Flask

app = Flask(__name__)

@app.route("/")
def home():
    return "Welcome to Flask"

app.run(debug=True)

Output

Browser में

http://127.0.0.1:5000

Open करें

Welcome to Flask

Routing

@app.route("/about")
def about():
    return "About Page"

Browser

/about

About Page खुलेगा।


URL Parameters

@app.route("/user/<name>")
def user(name):

    return f"Welcome {name}"

Browser

/user/Ajay

Output

Welcome Ajay

Debug Mode

app.run(debug=True)

Program में बदलाव करने पर Server Automatic Restart हो जाता है।


🟣 Section C – Templates

Templates क्या हैं?

HTML Files

जो Flask Render करता है।


Folder Structure

project/

│

app.py

│

templates/

      index.html

render_template()

from flask import render_template

@app.route("/")
def home():

    return render_template("index.html")

HTML Example

<!DOCTYPE html>

<html>

<body>

<h1>Welcome</h1>

</body>

</html>

CSS जोड़ना

Folder

static/

style.css

HTML

<link rel="stylesheet"

href="{{ url_for('static', filename='style.css') }}">

GET Method

Browser से Data लेना।

Example

Search Box


POST Method

Sensitive Data भेजना।

Example

Login Form


Login Form

<form method="POST">

<input type="text"

name="username">

<input type="password"

name="password">

<button>

Login

</button>

</form>

Flask में Data लेना

from flask import request

username = request.form["username"]

🔴 Section D – SQLite Integration

Database Connect

import sqlite3

conn = sqlite3.connect("students.db")

Registration

cursor.execute(

"INSERT INTO users VALUES(?,?)",

(username,password)

)

Login Check

cursor.execute(

"SELECT * FROM users WHERE username=? AND password=?",

(username,password)

)

Session

Login होने के बाद User को याद रखना।

from flask import session

session["user"]="Ajay"

Logout

session.pop("user")

🟠 Mini Projects

Project 1

Portfolio Website

Features

  • Home

  • About

  • Skills

  • Projects

  • Contact


Project 2

Student Management

Features

  • Add Student

  • Edit Student

  • Delete Student

  • Search Student


Project 3

Blog Website

Features

  • Create Post

  • Edit Post

  • Delete Post

  • Comments


Project 4

Login System

Features

  • Registration

  • Login

  • Logout

  • Dashboard


Project 5

To-Do App

Features

  • Add Task

  • Complete Task

  • Delete Task


Project 6

Expense Tracker

Features

  • Add Expense

  • Monthly Report

  • Category Filter


Project 7

Attendance System

Teacher Login

Student Attendance

Reports


Project 8

Library Management

Books

Issue

Return

Fine


Key Concepts Summary

  • Web Development का उपयोग Websites और Web Applications बनाने के लिए होता है।

  • Flask एक Lightweight Python Web Framework है।

  • Route किसी URL को Function से जोड़ता है।

  • Templates HTML Files होती हैं जिन्हें Flask Render करता है।

  • Static Folder में CSS, JavaScript और Images रखी जाती हैं।

  • GET Method सामान्य Data प्राप्त करने के लिए और POST Method Form Data भेजने के लिए उपयोग होता है।

  • SQLite के साथ Flask जोड़कर Dynamic Applications बनाई जा सकती हैं।

  • Session Login User की जानकारी अस्थायी रूप से Store करता है।

  • Flask छोटे और मध्यम आकार के Projects के लिए बहुत लोकप्रिय Framework है।


Important Definitions

Frontend: User को दिखाई देने वाला भाग।

Backend: Server पर चलने वाला Logic।

HTTP: Browser और Server के बीच Communication Protocol।

Route: URL और Python Function के बीच Mapping।

Template: HTML File जिसे Flask Render करता है।

Session: Login User की अस्थायी जानकारी।

GET: Data प्राप्त करने की Method।

POST: Data भेजने की Method।


Common Mistakes Students Make

  1. templates Folder का नाम गलत रखना।

  2. HTML Files को templates Folder के बाहर रखना।

  3. CSS File को static Folder में न रखना।

  4. Form में method="POST" लिखना भूल जाना।

  5. Session उपयोग करते समय Secret Key सेट न करना।

  6. User Input को Validate किए बिना Database में Save करना।

  7. Password को Plain Text में Store करना (वास्तविक Projects में Password Hashing का उपयोग करें)।


Practice Questions (With Answers)

1. Flask क्या है?

Answer: Python का Lightweight Web Framework।

2. Route का क्या काम है?

Answer: URL को Python Function से जोड़ना।

3. Templates किस Folder में रखी जाती हैं?

Answer: templates

4. CSS Files कहाँ रखी जाती हैं?

Answer: static Folder में।

5. render_template() का उपयोग क्यों किया जाता है?

Answer: HTML Page Render करने के लिए।

6. Form Data प्राप्त करने के लिए कौन-सा Object उपयोग होता है?

Answer: request

7. Session का क्या उपयोग है?

Answer: Login User की जानकारी अस्थायी रूप से Store करना।

8. GET और POST में क्या अंतर है?

Answer: GET Data प्राप्त करने के लिए, POST Data सुरक्षित रूप से भेजने के लिए।

9. Flask Install करने का Command क्या है?

Answer: pip install flask

10. Flask किस प्रकार के Applications बनाने के लिए उपयोग किया जाता है?

Answer: Websites, Web Applications, REST APIs और Dashboards।


🎯 Homework

  1. Flask का उपयोग करके एक Personal Portfolio Website बनाइए।

  2. SQLite के साथ Student Registration System तैयार कीजिए।

  3. Login और Logout वाली Authentication System बनाइए।

  4. एक To-Do Web App बनाकर Tasks Database में Save कीजिए।

  5. CSS जोड़कर अपनी Website को Responsive और Attractive बनाइए।


📌 अगले Part 16 में हम सीखेंगे:

🚀 Python APIs, REST API & JSON (Professional Level)

  • API क्या है?

  • REST API क्या है?

  • JSON Data Structure

  • HTTP Methods (GET, POST, PUT, DELETE, PATCH)

  • Status Codes (200, 201, 400, 401, 404, 500)

  • requests Library

  • Public APIs का उपयोग

  • Flask REST API बनाना

  • API Authentication (API Key, Token, JWT का परिचय)

  • Weather App

  • Currency Converter

  • News App

  • AI API Integration (OpenAI जैसी APIs का परिचय)

Part 16 के बाद आप अपनी Python Applications को दूसरी Services से जोड़ना सीख जाएंगे और Real-World API आधारित Projects बना सकेंगे।

🐍 Python Complete Course

Part 16 – Python APIs, REST API & JSON (Complete Mastery)

Level: Advanced
Duration: 8–10 Hours
Goal: इस Chapter के बाद आप APIs का उपयोग करना, अपनी REST API बनाना, JSON Data के साथ काम करना और Real-World Applications को दूसरी Services से Connect करना सीख जाएंगे।


📚 आज हम क्या सीखेंगे?

🟢 Section A – API Basics

  • API क्या है?

  • API क्यों उपयोग करते हैं?

  • REST API क्या है?

  • Client और Server

  • JSON क्या है?

  • XML vs JSON


🔵 Section B – HTTP Methods

  • GET

  • POST

  • PUT

  • PATCH

  • DELETE

  • HTTP Status Codes


🟣 Section C – Python Requests Library

  • requests Install

  • GET Request

  • POST Request

  • Headers

  • Parameters

  • JSON Response

  • Error Handling


🔴 Section D – Flask REST API

  • API बनाना

  • JSON Response

  • CRUD API

  • Testing with Postman

  • Authentication का परिचय


🟠 Section E – Real Projects

  • Weather App

  • Currency Converter

  • News App

  • Quote Generator

  • Student REST API


🟢 Section A – API Basics

Section 1 – API क्या है?

API का पूरा नाम है:

Application Programming Interface

API दो अलग-अलग Software या Applications के बीच Communication कराने का माध्यम है।


Real Life Example

आप Restaurant में जाते हैं।

  • आप = Customer

  • Waiter = API

  • Kitchen = Server

आप सीधे Kitchen में नहीं जाते।

आप Order Waiter को देते हैं।

Waiter Kitchen से खाना लाकर आपको देता है।

Waiter = API


API क्यों उपयोग करते हैं?

API की मदद से हम

  • Weather Data

  • Google Maps

  • Payment Gateway

  • WhatsApp Messages

  • Email Services

  • AI Services

को अपनी Application में उपयोग कर सकते हैं।


REST API क्या है?

REST

Representational State Transfer

यह Web APIs बनाने का सबसे लोकप्रिय तरीका है।

REST API सामान्यतः HTTP Protocol का उपयोग करती है।


Client और Server

Client (Browser/App)
        │
     Request
        │
        ▼
Server (API)
        │
    Process Data
        │
     Response
        ▼
Client

JSON क्या है?

JSON

JavaScript Object Notation

आज लगभग सभी APIs JSON Format में Data भेजती हैं।


Example

{
    "name": "Ajay",
    "age": 22,
    "city": "Patna"
}

JSON की विशेषताएँ

  • हल्का (Lightweight)

  • पढ़ने में आसान

  • मशीन और इंसान दोनों के लिए सरल

  • लगभग सभी Programming Languages में Supported


XML vs JSON

XMLJSON
बड़ा Formatछोटा Format
पढ़ना कठिनपढ़ना आसान
अधिक TagsKey-Value Pair
कम उपयोगसबसे अधिक उपयोग

🔵 Section B – HTTP Methods

HTTP Methods बताते हैं कि Server पर क्या Operation करना है।


GET

Server से Data प्राप्त करना।

GET /students

Real Life Example

Google Search करना।


POST

नया Data भेजना।

POST /students

Real Life Example

Registration Form Submit करना।


PUT

पूरा Record Update करना।

PUT /students/1

PATCH

केवल कुछ Fields Update करना।

PATCH /students/1

DELETE

Record हटाना।

DELETE /students/1

HTTP Status Codes

CodeMeaning
200Success
201Created
400Bad Request
401Unauthorized
403Forbidden
404Not Found
500Internal Server Error

🟣 Section C – Requests Library

Install

pip install requests

GET Request

import requests

response = requests.get("https://api.example.com/students")

print(response.status_code)

JSON Response

data = response.json()

print(data)

Parameters

params = {
    "city": "Patna"
}

response = requests.get(
    "https://api.example.com/users",
    params=params
)

Headers

headers = {
    "Authorization": "Bearer TOKEN"
}

POST Request

data = {
    "name": "Ajay",
    "marks": 95
}

response = requests.post(
    "https://api.example.com/students",
    json=data
)

Error Handling

try:
    response = requests.get("https://api.example.com")

    response.raise_for_status()

except requests.exceptions.RequestException as e:
    print("Error:", e)

🔴 Section D – Flask REST API

पहला API

from flask import Flask

app = Flask(__name__)

@app.route("/")

def home():
    return {
        "message": "Welcome API"
    }

app.run(debug=True)

JSON Response

from flask import jsonify

@app.route("/student")

def student():
    return jsonify({
        "name": "Ajay",
        "marks": 95
    })

CRUD API

GET

@app.route("/students", methods=["GET"])

POST

@app.route("/students", methods=["POST"])

PUT

@app.route("/students/<int:id>", methods=["PUT"])

DELETE

@app.route("/students/<int:id>", methods=["DELETE"])

Postman क्या है?

Postman API Testing Tool है।

इसकी मदद से

  • GET

  • POST

  • PUT

  • DELETE

को आसानी से Test किया जा सकता है।


Authentication का परिचय

कुछ APIs केवल Authorized Users को Data देती हैं।

उदाहरण

  • API Key

  • Bearer Token

  • JWT (JSON Web Token)


🟠 Real Projects

Project 1

Weather App

Features

  • City Search

  • Current Temperature

  • Humidity

  • Wind Speed


Project 2

Currency Converter

Features

  • INR → USD

  • USD → INR

  • Live Exchange Rate


Project 3

News App

Features

  • Latest Headlines

  • Category Filter

  • Country Filter


Project 4

Quote Generator

Features

  • Random Quote

  • Author Name

  • Refresh Button


Project 5

Student REST API

Features

  • Add Student

  • Delete Student

  • Update Student

  • Search Student


Project 6

Movie Search App

Features

  • Search Movie

  • Rating

  • Release Date

  • Poster URL


Project 7

GitHub Profile Viewer

Features

  • Username Search

  • Followers

  • Repositories

  • Profile Photo


Project 8

AI Chat API (Introduction)

Features

  • User Message

  • AI Response

  • Chat History


Key Concepts Summary

  • API दो Applications के बीच Communication का माध्यम है।

  • REST API HTTP Protocol का उपयोग करती है।

  • JSON सबसे लोकप्रिय Data Exchange Format है।

  • GET Data प्राप्त करने के लिए उपयोग होता है।

  • POST नया Data भेजने के लिए उपयोग होता है।

  • PUT पूरे Record को Update करता है।

  • PATCH केवल आवश्यक Fields Update करता है।

  • DELETE Record हटाता है।

  • requests Library से Python में APIs का उपयोग किया जाता है।

  • Flask की मदद से अपनी REST API बनाई जा सकती है।


Important Definitions

API: Application Programming Interface।

REST API: HTTP आधारित Web API Architecture।

JSON: JavaScript Object Notation।

Endpoint: API का URL।

Request: Client द्वारा भेजा गया संदेश।

Response: Server द्वारा दिया गया उत्तर।

Status Code: Request का Result बताने वाला HTTP Code।

Authentication: User की पहचान सत्यापित करने की प्रक्रिया।


Common Mistakes Students Make

  1. API URL गलत लिख देना।

  2. response.json() कॉल करने से पहले Response सफल है या नहीं, यह न जांचना।

  3. GET और POST Methods में अंतर न समझना।

  4. Authorization Header भेजना भूल जाना।

  5. Error Handling न करना।

  6. Sensitive API Keys को सीधे Code में लिख देना।

  7. Status Codes को Ignore करना।


Practice Questions (With Answers)

1. API का पूरा नाम क्या है?

Answer: Application Programming Interface।

2. REST API किस Protocol का उपयोग करती है?

Answer: HTTP।

3. JSON का पूरा नाम क्या है?

Answer: JavaScript Object Notation।

4. नया Record बनाने के लिए कौन-सा HTTP Method उपयोग होता है?

Answer: POST।

5. Data प्राप्त करने के लिए कौन-सा Method उपयोग होता है?

Answer: GET।

6. 404 Status Code का क्या अर्थ है?

Answer: Resource Not Found।

7. Python में API Call करने के लिए कौन-सी Library सबसे अधिक उपयोग होती है?

Answer: requests

8. Flask में JSON Response भेजने के लिए कौन-सा Function उपयोग किया जाता है?

Answer: jsonify()

9. Postman का उपयोग किसलिए किया जाता है?

Answer: APIs को Test करने के लिए।

10. API Authentication के दो सामान्य तरीके बताइए।

Answer: API Key और Bearer Token (या JWT)।


🎯 Homework

  1. requests Library का उपयोग करके किसी Public API से Data प्राप्त कीजिए और उसे Console पर Print कीजिए।

  2. Flask में Student CRUD REST API बनाइए।

  3. Weather API का उपयोग करके City का Temperature दिखाने वाला Program बनाइए।

  4. GitHub User Profile Viewer बनाइए जो Username लेकर Profile Information दिखाए।

  5. Login वाली API में Basic Token आधारित Authentication जोड़ने का प्रयास कीजिए।


📌 अगले Part 17 में हम सीखेंगे:

🤖 Python Automation, Web Scraping & Task Scheduling

  • Automation क्या है?

  • Python Automation Projects

  • File Automation

  • Email Automation

  • Excel Automation (openpyxl)

  • PDF Automation

  • Web Scraping (BeautifulSoup)

  • Browser Automation (Selenium)

  • Scheduled Tasks (schedule, time)

  • WhatsApp और Telegram Automation (परिचय)

  • Bulk File Renamer

  • Auto Report Generator

  • Auto Email Sender

  • Website Data Extractor

Part 17 के बाद आप ऐसे Python Programs बना सकेंगे जो आपके रोज़मर्रा के कई काम अपने आप (Automatically) कर दें।


🐍 Python Complete Course

Part 17 – Python Automation, Web Scraping & Task Scheduling (Complete Mastery)

Level: Advanced
Duration: 10–12 Hours
Goal: इस Chapter के बाद आप Python की मदद से रोज़मर्रा के कामों को Automatic करना, Websites से Data निकालना (Web Scraping), Files Manage करना और समय के अनुसार Programs Automatically चलाना सीख जाएंगे। यही Skills Freelancing, Office Automation, Data Collection और Business Automation में सबसे अधिक उपयोग होती हैं।


📚 आज हम क्या सीखेंगे?

🟢 Section A – Python Automation Basics

  • Automation क्या है?

  • Automation के फायदे

  • Real World Applications

  • Automation Workflow


🔵 Section B – File Automation

  • Files Copy करना

  • Move करना

  • Rename करना

  • Delete करना

  • Folder बनाना

  • Backup लेना


🟣 Section C – Excel, PDF & Email Automation

  • Excel Automation (openpyxl)

  • PDF पढ़ना और बनाना

  • Email Automation (smtplib)

  • Attachments भेजना


🔴 Section D – Web Scraping & Browser Automation

  • Web Scraping क्या है?

  • BeautifulSoup

  • Selenium

  • HTML Parsing

  • Browser Automation


🟠 Section E – Task Scheduling & Projects

  • Schedule Library

  • Time Module

  • Automatic Tasks

  • Real Projects


🟢 Section A – Automation Basics

Section 1 – Automation क्या है?

Automation का अर्थ है किसी काम को Computer से अपने आप करवाना, ताकि उसे बार-बार हाथ से न करना पड़े।


Real Life Example

मान लीजिए आपके पास 500 Students की Marksheet है।

अगर आप हर Student को अलग-अलग Email भेजेंगे,

तो कई घंटे लग जाएंगे।

लेकिन Python Program

एक Click में

500 Emails भेज सकता है।

यही Automation है।


Automation कहाँ उपयोग होता है?

  • Office Work

  • Banking

  • Schools

  • Hospitals

  • E-commerce

  • Social Media

  • Data Entry

  • Reporting


Automation के फायदे

  • समय की बचत

  • कम Errors

  • तेज़ Processing

  • Repeatable Tasks

  • Productivity बढ़ती है


Automation Workflow

Input
   │
Python Script
   │
Processing
   │
Automatic Output

🔵 Section B – File Automation

Current Folder की Files

import os

print(os.listdir())

Folder बनाना

import os

os.mkdir("Reports")

Folder हटाना

os.rmdir("Reports")

File Copy

import shutil

shutil.copy("report.txt", "backup.txt")

File Move

import shutil

shutil.move("report.txt", "Backup/report.txt")

File Rename

import os

os.rename("old.txt", "new.txt")

File Delete

import os

os.remove("old.txt")

Mini Project

Bulk File Renamer

import os

files = os.listdir()

count = 1

for file in files:
    if file.endswith(".jpg"):
        os.rename(file, f"Image_{count}.jpg")
        count += 1

🟣 Section C – Excel Automation

Install

pip install openpyxl

Workbook बनाना

from openpyxl import Workbook

wb = Workbook()

ws = wb.active

ws["A1"] = "Name"

ws["B1"] = "Marks"

wb.save("students.xlsx")

Excel पढ़ना

from openpyxl import load_workbook

wb = load_workbook("students.xlsx")

ws = wb.active

print(ws["A1"].value)

PDF पढ़ना

Install

pip install PyPDF2

from PyPDF2 import PdfReader

reader = PdfReader("book.pdf")

print(reader.pages[0].extract_text())

Email Automation

import smtplib

Example (Concept)

server = smtplib.SMTP("smtp.gmail.com",587)

server.starttls()

server.login("email","password")

नोट: वास्तविक प्रोजेक्ट में App Password या OAuth जैसे सुरक्षित तरीकों का उपयोग करना चाहिए। अपनी Email का Password सीधे Code में न लिखें।


🔴 Section D – Web Scraping

Web Scraping क्या है?

Website से Data निकालना।


Real Life Example

Amazon

Products

Price

Python निकाल सकता है।


Install

pip install beautifulsoup4

HTML Example

<h1>Python Course</h1>

BeautifulSoup

from bs4 import BeautifulSoup

html = "<h1>Hello</h1>"

soup = BeautifulSoup(html,"html.parser")

print(soup.h1.text)

Output

Hello

Web Page पढ़ना

import requests

from bs4 import BeautifulSoup

url = "https://example.com"

response = requests.get(url)

soup = BeautifulSoup(response.text,"html.parser")

Selenium

Install

pip install selenium

Browser खोलना

from selenium import webdriver

driver = webdriver.Chrome()

driver.get("https://google.com")

Search Box

from selenium.webdriver.common.by import By

search = driver.find_element(By.NAME,"q")

search.send_keys("Python")

Click

search.submit()

Selenium कहाँ उपयोग होता है?

  • Login Automation

  • Form Filling

  • Testing

  • Data Collection


🟠 Section E – Task Scheduling

Install

pip install schedule

Every Minute

import schedule

import time

def job():
    print("Running...")

schedule.every(1).minutes.do(job)

while True:
    schedule.run_pending()
    time.sleep(1)

Every Day

schedule.every().day.at("09:00").do(job)

Every Monday

schedule.every().monday.do(job)

Mini Projects

Project 1 – Bulk File Renamer

Features

  • Rename 1000 Images

  • Automatic Numbering


Project 2 – Excel Report Generator

Features

  • Student Report

  • Total Marks

  • Average


Project 3 – Auto Email Sender

Features

  • Multiple Emails

  • Subject

  • Attachment


Project 4 – Website Title Extractor

Features

  • URL Input

  • Page Title

  • Save to CSV


Project 5 – Price Tracker

Features

  • Product URL

  • Current Price

  • Alert if Price Drops


Project 6 – Attendance Report Generator

Features

  • Read Excel

  • Generate PDF

  • Save Report


Project 7 – Automatic Backup System

Features

  • Copy Files

  • Daily Backup

  • Log File


Project 8 – Browser Auto Login

Features

  • Open Website

  • Fill Username

  • Fill Password

  • Login


Project 9 – News Scraper

Features

  • Latest Headlines

  • Save to CSV

  • Filter by Category


Project 10 – Folder Cleaner

Features

  • Delete Temporary Files

  • Remove Empty Folders

  • Generate Cleanup Report


Key Concepts Summary

  • Automation बार-बार होने वाले कार्यों को अपने आप करने की प्रक्रिया है।

  • os और shutil Modules से Files और Folders Manage किए जा सकते हैं।

  • openpyxl Excel Files के साथ काम करने के लिए उपयोग होता है।

  • PyPDF2 PDF पढ़ने के लिए उपयोग किया जा सकता है।

  • BeautifulSoup HTML Parsing और Web Scraping के लिए उपयोगी है।

  • Selenium Browser Automation के लिए उपयोग होता है।

  • schedule और time की मदद से Tasks निर्धारित समय पर चलाए जा सकते हैं।

  • Automation बनाते समय Error Handling और Logging का उपयोग करना एक अच्छी Practice है।


Important Definitions

Automation: Computer से काम अपने आप करवाना।

Web Scraping: Website से Data निकालना।

HTML Parsing: HTML Structure को पढ़ना और समझना।

Selenium: Browser Automation Library।

BeautifulSoup: HTML/XML Parsing Library।

Scheduler: निश्चित समय पर Program चलाने वाला System।

Backup: Data की सुरक्षित Copy।


Common Mistakes Students Make

  1. Website की Terms of Service और Robots Policy की अनदेखी करना।

  2. Web Scraping करते समय Website पर बहुत तेज़ Requests भेजना।

  3. Selenium Driver Version और Browser Version का मेल न बैठाना।

  4. File Paths Hardcode कर देना।

  5. Email Password सीधे Code में लिखना।

  6. Scheduled Program में Infinite Loop को सही तरह Handle न करना।

  7. Error Handling और Logging न जोड़ना।


Practice Questions (With Answers)

1. Automation क्या है?

Answer: Computer से किसी कार्य को अपने आप करवाना।

2. Excel Automation के लिए कौन-सी Library उपयोग होती है?

Answer: openpyxl

3. HTML Parsing के लिए कौन-सी Library लोकप्रिय है?

Answer: BeautifulSoup

4. Browser Automation के लिए कौन-सी Library उपयोग होती है?

Answer: Selenium

5. os.listdir() क्या करता है?

Answer: Current Folder की Files और Folders की List देता है।

6. shutil.copy() का उपयोग किसलिए होता है?

Answer: File Copy करने के लिए।

7. schedule Library का उपयोग क्यों किया जाता है?

Answer: निश्चित समय पर Tasks चलाने के लिए।

8. PDF पढ़ने के लिए इस Chapter में कौन-सी Library का परिचय दिया गया?

Answer: PyPDF2

9. os.rename() का क्या कार्य है?

Answer: File या Folder का नाम बदलना।

10. Automation बनाते समय Password कहाँ नहीं रखना चाहिए?

Answer: सीधे Source Code में।


🎯 Homework

  1. Bulk Image Renamer बनाइए जो किसी Folder की सभी Images का नाम क्रमवार बदल दे।

  2. Excel Marksheet Generator बनाइए जो Student Data लेकर Excel File बनाए।

  3. Website Title Extractor बनाइए जो कई URLs का Title CSV में Save करे।

  4. Daily Backup Script बनाइए जो किसी Folder की Copy Backup Folder में बनाए।

  5. Simple Browser Automation बनाइए जो Browser खोलकर किसी Website पर Search करे।


📌 अगले Part 18 में हम सीखेंगे:

🤖 Data Science with Python (NumPy, Pandas, Matplotlib & Seaborn)

  • Data Science क्या है?

  • Data Analysis Workflow

  • NumPy (Arrays, Operations, Broadcasting)

  • Pandas (Series, DataFrame, Filtering, GroupBy)

  • Data Cleaning

  • Missing Values

  • CSV & Excel Analysis

  • Matplotlib (Line, Bar, Pie, Histogram)

  • Seaborn (Statistical Visualization)

  • Exploratory Data Analysis (EDA)

  • Student Data Analysis Project

  • Sales Dashboard Project

Part 18 से आप Python का उपयोग करके Data Analysis, Reporting और Data Science की वास्तविक दुनिया में प्रवेश करेंगे। यही Machine Learning सीखने की मजबूत Foundation है।


🐍 Python Complete Course

Part 18 – Data Science with Python (NumPy, Pandas, Matplotlib & Seaborn) (Complete Mastery)

Level: Advanced
Duration: 12–15 Hours
Goal: इस Chapter के बाद आप Data Analysis, Data Cleaning, Visualization और Exploratory Data Analysis (EDA) करना सीख जाएंगे। यही Skills Data Science, Machine Learning, Business Intelligence और AI की मजबूत Foundation हैं।


📚 आज हम क्या सीखेंगे?

🟢 Section A – Data Science Basics

  • Data Science क्या है?

  • Data Analysis Workflow

  • Data Types

  • Structured vs Unstructured Data

  • Dataset क्या है?


🔵 Section B – NumPy (Numerical Python)

  • NumPy Introduction

  • Arrays

  • Array Indexing

  • Slicing

  • Reshape

  • Broadcasting

  • Mathematical Operations

  • Random Numbers


🟣 Section C – Pandas

  • Series

  • DataFrame

  • Read CSV

  • Read Excel

  • Filtering

  • Sorting

  • GroupBy

  • Merge

  • Missing Values

  • Data Cleaning


🔴 Section D – Data Visualization

  • Matplotlib

  • Seaborn

  • Line Chart

  • Bar Chart

  • Pie Chart

  • Histogram

  • Scatter Plot

  • Heatmap


🟠 Section E – Real Projects

  • Student Data Analysis

  • Sales Dashboard

  • Employee Analysis

  • IPL Data Analysis

  • COVID Data Visualization


🟢 Section A – Data Science Basics

Section 1 – Data Science क्या है?

Data Science वह प्रक्रिया है जिसमें Data को Collect, Clean, Analyze और Visualize करके उपयोगी जानकारी (Insights) निकाली जाती है।


Real Life Example

एक Supermarket में हर दिन हजारों Products बिकते हैं।

Data Science की मदद से पता लगाया जा सकता है—

  • सबसे ज्यादा बिकने वाला Product

  • सबसे ज्यादा Sales किस महीने हुई

  • कौन-से Product कम बिक रहे हैं

  • भविष्य की Sales का अनुमान


Data कहाँ उपयोग होता है?

  • Amazon

  • Flipkart

  • Netflix

  • Google

  • Banks

  • Hospitals

  • Schools

  • Cricket Analytics


Data Analysis Workflow

Collect Data
      │
Clean Data
      │
Analyze Data
      │
Visualize Data
      │
Decision Making

Structured vs Unstructured Data

Structured DataUnstructured Data
TablesImages
ExcelVideos
DatabaseAudio
CSVPDF

Dataset क्या है?

Rows + Columns का Collection Dataset कहलाता है।

Example

NameMarksCity
Ajay95Patna
Rahul88Gaya

🔵 Section B – NumPy

NumPy क्या है?

NumPy

Numerical Python

तेज़ Mathematical Calculations के लिए उपयोग होता है।


Install

pip install numpy

Array बनाना

import numpy as np

arr = np.array([10,20,30,40])

print(arr)

Output

[10 20 30 40]

Multi-Dimensional Array

arr = np.array([[1,2],[3,4]])

print(arr)

Indexing

print(arr[0][1])

Output

2

Slicing

print(arr[:,1])

Shape

print(arr.shape)

Reshape

arr = np.arange(12)

print(arr.reshape(3,4))

Mathematical Operations

a = np.array([1,2,3])

b = np.array([4,5,6])

print(a+b)
print(a*b)

Mean

print(np.mean(a))

Maximum

print(np.max(a))

Random Numbers

print(np.random.randint(1,100,5))

Broadcasting

a = np.array([1,2,3])

print(a+10)

Output

[11 12 13]

🟣 Section C – Pandas

Install

pip install pandas

DataFrame

import pandas as pd

data = {
    "Name":["Ajay","Rahul"],
    "Marks":[95,88]
}

df = pd.DataFrame(data)

print(df)

Read CSV

df = pd.read_csv("students.csv")

Read Excel

df = pd.read_excel("students.xlsx")

First Five Rows

print(df.head())

Last Five Rows

print(df.tail())

Information

print(df.info())

Statistics

print(df.describe())

Filtering

print(df[df["Marks"]>80])

Sorting

df.sort_values("Marks",ascending=False)

GroupBy

df.groupby("City")["Marks"].mean()

Missing Values

df.isnull().sum()

Remove Missing Values

df.dropna()

Fill Missing Values

df.fillna(0)

Merge

pd.merge(df1,df2,on="ID")

🔴 Section D – Data Visualization

Matplotlib

Install

pip install matplotlib

Line Chart

import matplotlib.pyplot as plt

plt.plot([1,2,3],[10,20,30])

plt.show()

Bar Chart

plt.bar(["A","B","C"],[50,80,70])

plt.show()

Pie Chart

plt.pie([40,30,30],
labels=["Python","Java","C++"])

plt.show()

Histogram

plt.hist([10,20,20,30,30,40])

plt.show()

Scatter Plot

plt.scatter([1,2,3],[20,25,30])

plt.show()

Seaborn

Install

pip install seaborn

Heatmap

import seaborn as sns

sns.heatmap([[1,2],[3,4]])

Count Plot

sns.countplot(x=["A","A","B","C"])

Box Plot

sns.boxplot(x=[10,20,30,40])

🟠 Real Projects

Project 1

Student Result Analysis

Features

  • Highest Marks

  • Average

  • Topper List

  • Graph


Project 2

Sales Dashboard

Features

  • Monthly Sales

  • Profit

  • Expenses

  • Charts


Project 3

Employee Salary Analysis

Features

  • Department Wise Salary

  • Highest Salary

  • Average Salary


Project 4

IPL Data Analysis

Features

  • Top Batsman

  • Top Bowler

  • Team Performance


Project 5

COVID Data Dashboard

Features

  • Daily Cases

  • Death Rate

  • Recovery Rate

  • Charts


Project 6

School Attendance Dashboard

Features

  • Present Students

  • Absent Students

  • Monthly Attendance


Project 7

Stock Market Analysis

Features

  • Daily Closing Price

  • Moving Average

  • Trend Graph


Project 8

Weather Data Analysis

Features

  • Temperature Trend

  • Rainfall

  • Humidity Analysis


Key Concepts Summary

  • Data Science का उद्देश्य Data से उपयोगी जानकारी निकालना है।

  • NumPy तेज़ Numerical Calculations के लिए उपयोग होता है।

  • Pandas Data Cleaning और Data Analysis के लिए सबसे लोकप्रिय Library है।

  • DataFrame Rows और Columns का Collection होता है।

  • Matplotlib Charts बनाने के लिए उपयोग होता है।

  • Seaborn Statistical Data Visualization के लिए उपयोगी है।

  • Missing Values को Analyze और Handle करना Data Analysis का महत्वपूर्ण भाग है।

  • EDA (Exploratory Data Analysis) Machine Learning से पहले की महत्वपूर्ण प्रक्रिया है।


Important Definitions

Dataset: Rows और Columns में व्यवस्थित Data।

DataFrame: Pandas का Tabular Data Structure।

Series: Pandas का One-Dimensional Data Structure।

Array: NumPy का Data Structure।

Visualization: Data को Graphs और Charts के रूप में प्रस्तुत करना।

EDA: Exploratory Data Analysis।

Missing Value: Dataset में अनुपस्थित Data।

Heatmap: रंगों की सहायता से Data संबंध दिखाने वाला Chart।


Common Mistakes Students Make

  1. NumPy Array और Python List में अंतर न समझना।

  2. read_csv() करते समय File Path गलत देना।

  3. Missing Values को Handle किए बिना Analysis करना।

  4. Graph पर Labels और Titles न देना।

  5. Data Types (int, float, object) की जाँच न करना।

  6. DataFrame को Modify करते समय Original Data का Backup न रखना।

  7. Visualization देखकर बिना पर्याप्त Analysis के निष्कर्ष निकाल लेना।


Practice Questions (With Answers)

1. Data Science का मुख्य उद्देश्य क्या है?

Answer: Data से उपयोगी जानकारी (Insights) निकालना।

2. NumPy का पूरा नाम क्या है?

Answer: Numerical Python।

3. Pandas में Tabular Data किस Structure में रखा जाता है?

Answer: DataFrame।

4. CSV File पढ़ने के लिए कौन-सा Function उपयोग होता है?

Answer: pd.read_csv()

5. Missing Values की जाँच कैसे की जाती है?

Answer: df.isnull().sum()

6. Line Chart बनाने के लिए कौन-सी Library उपयोग होती है?

Answer: Matplotlib।

7. Heatmap किस Library में उपलब्ध है?

Answer: Seaborn।

8. df.describe() क्या करता है?

Answer: Dataset का Statistical Summary देता है।

9. Broadcasting किस Library का Concept है?

Answer: NumPy।

10. EDA का पूरा नाम क्या है?

Answer: Exploratory Data Analysis।


🎯 Homework

  1. किसी CSV File का Analysis करके Top 5 Students की List तैयार कीजिए।

  2. Pandas का उपयोग करके Missing Values हटाइए और Average Marks निकालिए।

  3. Matplotlib से Monthly Sales का Bar Chart बनाइए।

  4. Seaborn का उपयोग करके एक Heatmap बनाइए।

  5. एक Sales Dashboard तैयार कीजिए जिसमें Charts और Summary दोनों हों।


📌 अगले Part 19 में हम सीखेंगे:

🤖 Machine Learning with Python (Scikit-learn)

  • Machine Learning क्या है?

  • AI vs ML vs Deep Learning

  • Supervised Learning

  • Unsupervised Learning

  • Dataset Split (Train/Test)

  • Scikit-learn Introduction

  • Linear Regression

  • Logistic Regression

  • Decision Tree

  • Random Forest

  • K-Nearest Neighbors (KNN)

  • Model Evaluation (Accuracy, Precision, Recall, F1-Score)

  • Model Saving (joblib)

  • House Price Prediction

  • Student Marks Prediction

  • Spam Email Classifier

Part 19 से आप वास्तविक Machine Learning Models बनाना शुरू करेंगे। यह AI Engineer, Data Scientist और ML Developer बनने की दिशा में सबसे महत्वपूर्ण चरण है।


🐍 Python Complete Course

Part 19 – Machine Learning with Python (Scikit-learn) (Complete Mastery)

Level: Advanced
Duration: 15–18 Hours
Goal: इस Chapter के बाद आप Machine Learning की पूरी Foundation समझ जाएंगे, अपना पहला ML Model बनाना, Train करना, Test करना, Evaluate करना और Save करना सीख जाएंगे। यह AI Engineer, Data Scientist और ML Developer बनने की सबसे महत्वपूर्ण शुरुआत है।


📚 आज हम क्या सीखेंगे?

🟢 Section A – Machine Learning Basics

  • Machine Learning क्या है?

  • Artificial Intelligence (AI) क्या है?

  • AI vs Machine Learning vs Deep Learning

  • Machine Learning Workflow

  • Dataset क्या है?

  • Features और Labels


🔵 Section B – Data Preparation

  • Train-Test Split

  • Feature Engineering (Introduction)

  • Data Scaling

  • Encoding

  • Missing Values

  • Normalization

  • Standardization


🟣 Section C – Supervised Learning

  • Linear Regression

  • Logistic Regression

  • Decision Tree

  • Random Forest

  • K-Nearest Neighbors (KNN)

  • Naive Bayes

  • Support Vector Machine (SVM)


🔴 Section D – Model Evaluation

  • Accuracy

  • Precision

  • Recall

  • F1-Score

  • Confusion Matrix

  • Cross Validation

  • Saving Models (joblib)


🟠 Section E – Real Projects

  • House Price Prediction

  • Student Marks Prediction

  • Spam Email Classifier

  • Employee Salary Prediction

  • Customer Churn Prediction


🟢 Section A – Machine Learning Basics

Section 1 – Machine Learning क्या है?

Machine Learning (ML) Artificial Intelligence की एक शाखा है जिसमें Computer को स्पष्ट रूप से हर Rule लिखकर नहीं बताया जाता, बल्कि उसे Data से सीखने (Learn) का अवसर दिया जाता है।


Real Life Example

मान लीजिए आपने बच्चे को 100 बिल्लियों (Cats) की तस्वीरें दिखाई।

धीरे-धीरे वह नई तस्वीर देखकर भी पहचान लेता है कि यह बिल्ली है।

Machine Learning भी इसी तरह Data से Pattern सीखती है।


Artificial Intelligence (AI) क्या है?

AI का उद्देश्य ऐसी Machines बनाना है जो इंसानों की तरह कुछ बुद्धिमान कार्य कर सकें।

Examples:

  • Chatbots

  • Voice Assistants

  • Self Driving Cars

  • Recommendation Systems


AI vs ML vs Deep Learning

AIMachine LearningDeep Learning
सबसे बड़ा क्षेत्रAI का भागML का भाग
नियम + सीखनाData से सीखनाNeural Networks से सीखना
उदाहरण: RobotSpam FilterFace Recognition

Machine Learning Workflow

Collect Data
      │
Clean Data
      │
Train Model
      │
Test Model
      │
Evaluate
      │
Prediction

Features और Labels

Example:

Study HoursMarks
240
460
680
  • Study Hours → Feature (Input)

  • Marks → Label (Output)


🔵 Section B – Data Preparation

Train-Test Split

Model को Training और Testing दोनों Data की आवश्यकता होती है।

from sklearn.model_selection import train_test_split

X_train, X_test, y_train, y_test = train_test_split(
    X, y,
    test_size=0.2,
    random_state=42
)

Data Scaling

from sklearn.preprocessing import StandardScaler

scaler = StandardScaler()

X_train = scaler.fit_transform(X_train)

X_test = scaler.transform(X_test)

Encoding

Text Data को Numbers में बदलना।

from sklearn.preprocessing import LabelEncoder

encoder = LabelEncoder()

gender = encoder.fit_transform(
    ["Male","Female","Male"]
)

print(gender)

Output

[1 0 1]

Missing Values

df.fillna(df.mean(numeric_only=True))

🟣 Section C – Supervised Learning

Linear Regression

जब Output लगातार (Continuous) हो।

Example:

  • House Price

  • Salary

  • Temperature

from sklearn.linear_model import LinearRegression

model = LinearRegression()

model.fit(X_train, y_train)

prediction = model.predict(X_test)

Logistic Regression

Classification के लिए।

Example:

  • Pass / Fail

  • Spam / Not Spam

from sklearn.linear_model import LogisticRegression

model = LogisticRegression()

model.fit(X_train, y_train)

Decision Tree

Tree Structure पर आधारित Algorithm।

from sklearn.tree import DecisionTreeClassifier

model = DecisionTreeClassifier()

model.fit(X_train,y_train)

Random Forest

कई Decision Trees का समूह।

from sklearn.ensemble import RandomForestClassifier

model = RandomForestClassifier()

model.fit(X_train,y_train)

K-Nearest Neighbors (KNN)

सबसे पास वाले Data Points के आधार पर Prediction करता है।

from sklearn.neighbors import KNeighborsClassifier

model = KNeighborsClassifier()

model.fit(X_train,y_train)

Naive Bayes

Text Classification में लोकप्रिय।

Examples:

  • Spam Detection

  • Sentiment Analysis


Support Vector Machine (SVM)

Classification और Regression दोनों के लिए उपयोगी।


🔴 Section D – Model Evaluation

Accuracy

from sklearn.metrics import accuracy_score

print(accuracy_score(y_test,prediction))

Precision

Positive Predictions की Quality।


Recall

सही Positive Results खोजने की क्षमता।


F1 Score

Precision और Recall का संतुलित माप।

from sklearn.metrics import f1_score

print(f1_score(y_test,prediction))

Confusion Matrix

from sklearn.metrics import confusion_matrix

print(confusion_matrix(y_test,prediction))

Cross Validation

Model की Stability जाँचने के लिए।

from sklearn.model_selection import cross_val_score

Model Save

import joblib

joblib.dump(model,"model.pkl")

Model Load

model = joblib.load("model.pkl")

🟠 Real Projects

Project 1 – House Price Prediction

Features

  • Area

  • Bedrooms

  • Location

  • Age

Output

House Price


Project 2 – Student Marks Prediction

Features

  • Study Hours

  • Attendance

  • Assignments

Output

Expected Marks


Project 3 – Spam Email Classifier

Features

  • Email Text

Output

Spam / Not Spam


Project 4 – Employee Salary Prediction

Features

  • Experience

  • Education

  • Skills

Output

Expected Salary


Project 5 – Customer Churn Prediction

Features

  • Monthly Bill

  • Contract Type

  • Support Calls

Output

Customer Will Leave / Stay


Project 6 – Loan Approval Prediction

Features

  • Income

  • Age

  • Credit Score

Output

Loan Approved / Rejected


Project 7 – Disease Prediction (Educational Example)

Features

  • Symptoms

  • Age

Output

Possible Disease Category

नोट: ऐसे Models केवल शैक्षणिक अभ्यास के लिए हैं। वास्तविक चिकित्सा निर्णय केवल योग्य स्वास्थ्य विशेषज्ञ द्वारा किए जाने चाहिए।


Project 8 – Movie Recommendation (Introduction)

Features

  • User Rating

  • Genre

Output

Recommended Movies


Key Concepts Summary

  • Machine Learning Data से सीखने की प्रक्रिया है।

  • AI सबसे बड़ा क्षेत्र है, Machine Learning उसका एक भाग है।

  • Features Input होते हैं और Labels Target Output होते हैं।

  • Train-Test Split Model की Performance जाँचने के लिए आवश्यक है।

  • Linear Regression Continuous Values Predict करता है।

  • Logistic Regression Classification के लिए उपयोग होता है।

  • Decision Tree और Random Forest लोकप्रिय Tree-Based Algorithms हैं।

  • Accuracy के साथ Precision, Recall और F1-Score भी महत्वपूर्ण Evaluation Metrics हैं।

  • Trained Model को joblib की मदद से Save और Load किया जा सकता है।


Important Definitions

Machine Learning: Data से सीखने की तकनीक।

Feature: Model का Input।

Label (Target): Model का Expected Output।

Training Data: Model को सिखाने वाला Data।

Testing Data: Model की जाँच करने वाला Data।

Classification: Categories की Prediction।

Regression: Continuous Values की Prediction।

Overfitting: Training Data पर बहुत अच्छा लेकिन नए Data पर खराब Performance।

Underfitting: Training Data पर भी सही Pattern न सीख पाना।


Common Mistakes Students Make

  1. Train और Test Data को अलग न करना।

  2. Data Leakage होने देना (Testing की जानकारी Training में पहुँच जाना)।

  3. Missing Values Handle किए बिना Model Train करना।

  4. Features को Scale करने की आवश्यकता होने पर भी Scaling न करना।

  5. केवल Accuracy देखकर Model का मूल्यांकन करना।

  6. Imbalanced Dataset में Precision और Recall को Ignore करना।

  7. Model Save करने से पहले उसका Evaluation न करना।


Practice Questions (With Answers)

1. Machine Learning क्या है?

Answer: Data से सीखकर Prediction या Decision लेने की तकनीक।

2. AI और ML में क्या संबंध है?

Answer: Machine Learning, Artificial Intelligence का एक भाग है।

3. Feature क्या होता है?

Answer: Model का Input Data।

4. Label क्या होता है?

Answer: Expected Output या Target।

5. House Price Prediction किस प्रकार की Problem है?

Answer: Regression।

6. Spam Email Detection किस प्रकार की Problem है?

Answer: Classification।

7. Train-Test Split का उद्देश्य क्या है?

Answer: Model को Train करना और उसकी Performance को नए Data पर जाँचना।

8. Accuracy के अलावा कौन-से तीन महत्वपूर्ण Metrics हैं?

Answer: Precision, Recall और F1-Score।

9. Trained Model Save करने के लिए इस Chapter में कौन-सी Library का उपयोग किया गया?

Answer: joblib

10. Overfitting क्या है?

Answer: जब Model Training Data को बहुत अधिक याद कर लेता है और नए Data पर अच्छा प्रदर्शन नहीं करता।


🎯 Homework

  1. Student Marks Prediction Model बनाइए जिसमें Study Hours के आधार पर Marks Predict हों।

  2. Spam Email Classifier तैयार कीजिए।

  3. House Price Prediction Dataset पर Linear Regression लागू कीजिए।

  4. Decision Tree और Random Forest की Accuracy की तुलना कीजिए।

  5. किसी Trained Model को joblib से Save करके दोबारा Load कीजिए।


📌 अगले Part 20 में हम सीखेंगे:

🧠 Deep Learning with TensorFlow & Keras

  • Deep Learning क्या है?

  • Neural Network क्या है?

  • Perceptron

  • Artificial Neural Network (ANN)

  • Activation Functions (ReLU, Sigmoid, Softmax)

  • TensorFlow Introduction

  • Keras API

  • Model Building

  • Training & Validation

  • Loss Functions

  • Optimizers

  • CNN (Convolutional Neural Networks)

  • RNN (Recurrent Neural Networks) का परिचय

  • Image Classification Project

  • Handwritten Digit Recognition (MNIST)

  • Cat vs Dog Classifier

Part 20 से आप आधुनिक AI की सबसे शक्तिशाली तकनीकों में प्रवेश करेंगे। यही Technology Image Recognition, Voice Recognition, Chatbots और Generative AI की आधारशिला है।


🐍 Python Complete Course

Part 20 – Deep Learning with TensorFlow & Keras (Complete Mastery)

Level: Expert
Duration: 18–22 Hours
Goal: इस Chapter के बाद आप Artificial Neural Networks (ANN), Deep Learning, TensorFlow और Keras का उपयोग करके आधुनिक AI Models बनाना सीख जाएंगे। यह Chapter Image Recognition, Face Detection, Speech Recognition, Chatbots और Generative AI की मजबूत Foundation तैयार करेगा।


📚 आज हम क्या सीखेंगे?

🟢 Section A – Deep Learning Basics

  • Deep Learning क्या है?

  • AI → ML → Deep Learning

  • Neural Network क्या है?

  • Biological Neuron vs Artificial Neuron

  • Perceptron

  • Layers (Input, Hidden, Output)


🔵 Section B – TensorFlow & Keras

  • TensorFlow Introduction

  • Keras API

  • Installation

  • पहला Neural Network

  • Model Compile

  • Model Train

  • Prediction


🟣 Section C – Deep Learning Concepts

  • Activation Functions

  • Loss Functions

  • Optimizers

  • Epochs

  • Batch Size

  • Overfitting

  • Dropout

  • Early Stopping


🔴 Section D – Convolutional Neural Networks (CNN)

  • Image Data

  • CNN Architecture

  • Convolution Layer

  • Pooling Layer

  • Flatten Layer

  • Dense Layer

  • Image Classification


🟠 Section E – Real Projects

  • Handwritten Digit Recognition

  • Cat vs Dog Classifier

  • Face Mask Detection (Introduction)

  • Flower Classification

  • Fashion MNIST


🟢 Section A – Deep Learning Basics

Deep Learning क्या है?

Deep Learning, Machine Learning का एक उन्नत (Advanced) भाग है जिसमें कई Layers वाले Neural Networks का उपयोग करके Computer स्वयं जटिल Patterns सीखता है।


Real Life Example

मान लीजिए आपको 50,000 बिल्लियों और कुत्तों की Images दिखाई जाएँ।

Deep Learning Model उन Images से सीखकर नई Image देखकर बता सकता है कि यह Cat है या Dog


AI → ML → Deep Learning

Artificial Intelligence
        │
Machine Learning
        │
Deep Learning

Biological Neuron vs Artificial Neuron

Human BrainNeural Network
NeuronArtificial Neuron
SynapseWeight
SignalInput
DecisionOutput

Artificial Neuron

Input
  │
Weights
  │
Activation Function
  │
Output

Neural Network Layers

Input Layer
      │
Hidden Layer
      │
Hidden Layer
      │
Output Layer

Perceptron

Perceptron सबसे सरल Neural Network Model है जो Binary Classification Problems को हल कर सकता है।


🔵 Section B – TensorFlow & Keras

TensorFlow क्या है?

TensorFlow Google द्वारा विकसित Open Source Deep Learning Framework है।

इसका उपयोग किया जाता है—

  • Image Recognition

  • NLP

  • Voice Recognition

  • Recommendation Systems

  • Robotics


Keras क्या है?

Keras TensorFlow का High-Level API है जिससे Deep Learning Models आसानी से बनाए जा सकते हैं।


Installation

pip install tensorflow

पहला Neural Network

import tensorflow as tf
from tensorflow import keras

model = keras.Sequential([
    keras.layers.Dense(16, activation="relu"),
    keras.layers.Dense(1)
])

Model Compile

model.compile(
    optimizer="adam",
    loss="mse",
    metrics=["accuracy"]
)

Model Train

model.fit(
    X_train,
    y_train,
    epochs=20
)

Prediction

prediction = model.predict(X_test)

🟣 Section C – Deep Learning Concepts

Activation Functions

Activation Function यह तय करती है कि Neuron Activate होगा या नहीं।


ReLU

activation="relu"

सबसे अधिक उपयोग होने वाली Activation Function।


Sigmoid

activation="sigmoid"

Binary Classification में उपयोगी।


Softmax

activation="softmax"

Multi-Class Classification के लिए।


Loss Function

Model की गलती (Error) को मापती है।

उदाहरण:

  • Mean Squared Error (Regression)

  • Binary Crossentropy

  • Categorical Crossentropy


Optimizer

Model के Weights को बेहतर बनाता है।

Popular Optimizers:

  • SGD

  • RMSProp

  • Adam (सबसे लोकप्रिय)


Epoch

पूरा Dataset एक बार Model को दिखाना = 1 Epoch


Batch Size

एक बार में Model को दिए जाने वाले Samples की संख्या।


Overfitting

जब Model Training Data को बहुत अच्छी तरह याद कर लेता है लेकिन नए Data पर खराब प्रदर्शन करता है।


Dropout

Overfitting कम करने की Technique।

keras.layers.Dropout(0.3)

Early Stopping

Validation Performance खराब होने पर Training को पहले ही रोक देना।


🔴 Section D – Convolutional Neural Networks (CNN)

CNN क्या है?

CNN विशेष रूप से Images के लिए बनाए गए Neural Networks हैं।

इनका उपयोग किया जाता है—

  • Face Recognition

  • Medical Imaging

  • OCR

  • Self Driving Cars


CNN Architecture

Image
  │
Convolution
  │
ReLU
  │
Pooling
  │
Flatten
  │
Dense Layer
  │
Prediction

Convolution Layer

Image से Features निकालती है।

उदाहरण:

  • Edges

  • Shapes

  • Patterns


Pooling Layer

Image का Size कम करती है और महत्वपूर्ण Features को बनाए रखती है।


Flatten Layer

2D Data को 1D में बदलती है।


Dense Layer

Final Prediction करती है।


Image Classification Example

model = keras.Sequential([
    keras.layers.Conv2D(32,(3,3),activation="relu"),
    keras.layers.MaxPooling2D((2,2)),
    keras.layers.Flatten(),
    keras.layers.Dense(128,activation="relu"),
    keras.layers.Dense(10,activation="softmax")
])

🟠 Real Projects

Project 1 – Handwritten Digit Recognition (MNIST)

Features

  • Digit Recognition

  • Accuracy Report

  • Prediction


Project 2 – Cat vs Dog Classifier

Features

  • Upload Image

  • Predict Animal

  • Confidence Score


Project 3 – Flower Classification

Features

  • Flower Image

  • Species Prediction


Project 4 – Fashion MNIST

Features

  • Dress Recognition

  • Shoes

  • Bags

  • Shirts


Project 5 – Face Mask Detection (Introduction)

Features

  • Camera Input

  • Mask / No Mask Prediction


Project 6 – Fruit Classification

Features

  • Apple

  • Mango

  • Orange

  • Banana


Project 7 – Plant Disease Detection (Educational Example)

Features

  • Leaf Image

  • Disease Category Prediction

नोट: ऐसे Models केवल शैक्षणिक उद्देश्य के लिए हैं। वास्तविक कृषि या चिकित्सा निर्णय विशेषज्ञ की सलाह के साथ ही लिए जाने चाहिए।


Project 8 – Signature Verification (Introduction)

Features

  • Signature Matching

  • Similarity Score


Key Concepts Summary

  • Deep Learning, Machine Learning का उन्नत भाग है।

  • Neural Networks मानव मस्तिष्क के Neurons से प्रेरित होते हैं।

  • TensorFlow सबसे लोकप्रिय Deep Learning Frameworks में से एक है।

  • Keras, TensorFlow का सरल High-Level API है।

  • ReLU, Sigmoid और Softmax महत्वपूर्ण Activation Functions हैं।

  • Adam सबसे अधिक उपयोग किए जाने वाले Optimizers में से एक है।

  • CNN Images से Features निकालने और Classification करने में अत्यंत प्रभावी है।

  • Dropout और Early Stopping Overfitting कम करने में मदद करते हैं।


Important Definitions

Deep Learning: Multi-Layer Neural Networks द्वारा सीखने की तकनीक।

Neuron: Neural Network की मूल इकाई।

Epoch: पूरे Training Dataset पर एक Training Cycle।

Batch Size: एक बार में Model को दिए जाने वाले Samples।

Activation Function: Neuron के Output को नियंत्रित करने वाला Function।

Optimizer: Model के Weights सुधारने वाला Algorithm।

CNN: Convolutional Neural Network, Image Processing के लिए विशेष Architecture।

Overfitting: Training Data पर अच्छा लेकिन नए Data पर कमजोर प्रदर्शन।


Common Mistakes Students Make

  1. Training Data बहुत कम रखना।

  2. Validation Data का उपयोग न करना।

  3. बहुत अधिक Epochs चलाकर Overfitting करना।

  4. Images को Normalize न करना।

  5. Loss Function और Activation Function का गलत संयोजन चुनना।

  6. GPU उपलब्ध होने पर भी CPU पर बड़े Models Train करना।

  7. Model Evaluation केवल Accuracy तक सीमित रखना।


Practice Questions (With Answers)

1. Deep Learning क्या है?

Answer: Multi-Layer Neural Networks द्वारा Data से सीखने की तकनीक।

2. TensorFlow किसने विकसित किया?

Answer: Google।

3. Keras क्या है?

Answer: TensorFlow का High-Level API।

4. ReLU का उपयोग क्यों किया जाता है?

Answer: Hidden Layers में तेज़ और प्रभावी Training के लिए।

5. Softmax कहाँ उपयोग होती है?

Answer: Multi-Class Classification में।

6. CNN किस प्रकार के Data के लिए सबसे उपयुक्त है?

Answer: Image Data।

7. Epoch क्या है?

Answer: पूरे Dataset पर Training का एक पूरा चक्र।

8. Dropout का उद्देश्य क्या है?

Answer: Overfitting कम करना।

9. Pooling Layer का क्या कार्य है?

Answer: Feature Maps का Size कम करना और महत्वपूर्ण Features बनाए रखना।

10. Adam क्या है?

Answer: Deep Learning में उपयोग होने वाला एक लोकप्रिय Optimizer।


🎯 Homework

  1. MNIST Digit Recognition Model बनाइए।

  2. Cat vs Dog Classifier तैयार कीजिए।

  3. CNN का उपयोग करके किसी Image Dataset पर Classification कीजिए।

  4. अलग-अलग Epochs (10, 20, 50) पर Model की Performance की तुलना कीजिए।

  5. Dropout जोड़कर Overfitting कम करने का प्रयास कीजिए।


📌 अगले Part 21 में हम सीखेंगे:

🚀 Natural Language Processing (NLP) with Python

  • NLP क्या है?

  • Text Processing

  • Tokenization

  • Stop Words

  • Stemming

  • Lemmatization

  • Regular Expressions (Regex)

  • Bag of Words (BoW)

  • TF-IDF

  • Word Embeddings (Word2Vec का परिचय)

  • Sentiment Analysis

  • Spam Detection

  • Text Classification

  • Chatbot Basics

  • Hindi Text Processing

  • Real NLP Projects

Part 21 से आप Text Data पर काम करना सीखेंगे और Chatbots, Language Translation, Text Classification तथा आधुनिक Large Language Models (LLMs) की बुनियादी समझ विकसित करेंगे।


🐍 Python Complete Course

Part 21 – Natural Language Processing (NLP) with Python (Complete Mastery)

Level: Expert
Duration: 18–22 Hours
Goal: इस Chapter के बाद आप Text Data को Computer द्वारा समझने योग्य बनाना, उसका विश्लेषण करना, Sentiment Analysis करना, Spam Detection, Text Classification, Chatbot की बुनियाद और आधुनिक Large Language Models (LLMs) की Foundation समझ जाएंगे।


📚 आज हम क्या सीखेंगे?

🟢 Section A – NLP Basics

  • NLP क्या है?

  • NLP कहाँ उपयोग होता है?

  • Text Data क्या है?

  • NLP Workflow

  • Corpus, Document, Token


🔵 Section B – Text Preprocessing

  • Tokenization

  • Lowercase Conversion

  • Stop Words

  • Punctuation Removal

  • Stemming

  • Lemmatization

  • Regular Expressions (Regex)


🟣 Section C – Feature Extraction

  • Bag of Words (BoW)

  • TF-IDF

  • N-Grams

  • Word Embeddings

  • Word2Vec (Introduction)


🔴 Section D – NLP Models

  • Text Classification

  • Sentiment Analysis

  • Spam Detection

  • Named Entity Recognition (NER)

  • Chatbot Basics

  • Transformer Models (Introduction)


🟠 Section E – Real Projects

  • Movie Review Sentiment Analysis

  • SMS Spam Detector

  • News Category Classifier

  • Resume Analyzer

  • FAQ Chatbot


🟢 Section A – NLP Basics

NLP क्या है?

NLP (Natural Language Processing) Artificial Intelligence की वह शाखा है जो Computer को मानव भाषा (Human Language) समझने, पढ़ने, लिखने और उसका विश्लेषण करने में सक्षम बनाती है।


Real Life Examples

आप रोज़ जिन Applications का उपयोग करते हैं—

  • ChatGPT

  • Google Translate

  • Grammarly

  • Gmail Spam Filter

  • Alexa

  • Siri

इन सभी में NLP का उपयोग होता है।


NLP कहाँ उपयोग होता है?

  • Chatbots

  • Voice Assistants

  • Translation

  • Search Engines

  • Spam Detection

  • Text Summarization

  • Recommendation Systems


NLP Workflow

Raw Text
    │
Text Cleaning
    │
Tokenization
    │
Feature Extraction
    │
Model Training
    │
Prediction

Corpus, Document और Token

Example Sentence:

Python is very easy to learn.
  • Corpus: Documents का Collection

  • Document: एक Text File या Paragraph

  • Token: प्रत्येक Word या Meaningful Unit

Tokens:

Python
is
very
easy
to
learn

🔵 Section B – Text Preprocessing

Lowercase Conversion

text = "Python Programming"

print(text.lower())

Output

python programming

Tokenization

from nltk.tokenize import word_tokenize

text = "Python is easy."

tokens = word_tokenize(text)

print(tokens)

Output

['Python', 'is', 'easy', '.']

Stop Words

Stop Words ऐसे सामान्य शब्द होते हैं जो अक्सर अर्थ में बहुत कम योगदान देते हैं।

Examples:

  • is

  • the

  • a

  • an

  • of


Stop Words हटाना

from nltk.corpus import stopwords

stop_words = set(stopwords.words("english"))

Punctuation हटाना

import string

text = "Hello, World!"

clean = text.translate(
    str.maketrans('', '', string.punctuation)
)

print(clean)

Output

Hello World

Stemming

शब्द को उसके मूल रूप (Root Form) के करीब लाना।

Examples:

OriginalStem
PlayingPlay
PlayedPlay
PlaysPlay

from nltk.stem import PorterStemmer

stemmer = PorterStemmer()

print(stemmer.stem("playing"))

Lemmatization

Stemming की तुलना में अधिक सही Dictionary Form देता है।

Examples:

WordLemma
BetterGood
RunningRun
FeetFoot

Regular Expressions (Regex)

Regex का उपयोग Text Search और Pattern Matching के लिए किया जाता है।

import re

text = "My number is 9876543210"

numbers = re.findall(r"\d+", text)

print(numbers)

Output

['9876543210']

🟣 Section C – Feature Extraction

Bag of Words (BoW)

Text को Word Frequency में बदलना।

Example

Sentence:

Python is Easy
Python is Powerful

Bag of Words

WordCount
Python2
Easy1
Powerful1

TF-IDF

TF-IDF महत्वपूर्ण Words को अधिक Weight देता है और बहुत सामान्य Words का प्रभाव कम करता है।


from sklearn.feature_extraction.text import TfidfVectorizer

vectorizer = TfidfVectorizer()

X = vectorizer.fit_transform([
    "Python is easy",
    "Python is powerful"
])

N-Grams

Examples

Sentence

I Love Python

Unigram

I
Love
Python

Bigram

I Love

Love Python

Trigram

I Love Python

Word Embeddings

Word Embeddings शब्दों को Dense Numeric Vectors में बदलते हैं ताकि उनके अर्थ (Semantic Meaning) को बेहतर तरीके से दर्शाया जा सके।


Word2Vec (Introduction)

Word2Vec समान अर्थ वाले शब्दों को Vector Space में एक-दूसरे के पास रखने की कोशिश करता है।

उदाहरण:

  • King ≈ Queen

  • Delhi ≈ Mumbai (स्थान के रूप में)

  • Teacher ≈ Student (संदर्भ के अनुसार)


🔴 Section D – NLP Models

Text Classification

Examples:

  • News Classification

  • Email Category

  • Intent Detection


Sentiment Analysis

Text का भाव (Positive, Negative, Neutral) पहचानना।

Example:

This course is amazing.

Output:

Positive

Spam Detection

Input

Congratulations! You won ₹1,00,000.

Output

Spam

Named Entity Recognition (NER)

NER Text में महत्वपूर्ण Entities पहचानता है।

Example

Ajay lives in Patna.

Output

WordEntity
AjayPerson
PatnaLocation

Chatbot Basics

Chatbot सामान्यतः निम्न चरणों में कार्य करता है:

User Message

Intent पहचानना

Response तैयार करना

User को Reply देना


Transformer Models (Introduction)

Transformer आधुनिक NLP Models की Architecture है।

इसी विचार पर आधारित कई लोकप्रिय Models विकसित हुए हैं, जिनका उपयोग Text Generation, Translation, Question Answering और Summarization जैसे कार्यों में किया जाता है।


🟠 Section E – Real Projects

Project 1 – Movie Review Sentiment Analysis

Features

  • Movie Review Input

  • Positive / Negative Prediction

  • Confidence Score


Project 2 – SMS Spam Detector

Features

  • SMS Input

  • Spam Detection

  • Probability


Project 3 – News Category Classifier

Features

  • Politics

  • Sports

  • Technology

  • Business


Project 4 – Resume Analyzer

Features

  • Skills Detection

  • Keyword Matching

  • Missing Skills Report


Project 5 – FAQ Chatbot

Features

  • Question Answering

  • Multiple Topics

  • Simple Conversation Flow


Project 6 – Email Classifier

Features

  • Personal

  • Work

  • Promotions

  • Social


Project 7 – Hindi Text Analyzer

Features

  • Hindi Tokenization

  • Word Frequency

  • Stop Word Analysis


Project 8 – Product Review Analyzer

Features

  • Customer Reviews

  • Positive / Negative Summary

  • Frequent Keywords


Key Concepts Summary

  • NLP Computer को Human Language समझने में सक्षम बनाता है।

  • Text Preprocessing किसी भी NLP Project का पहला और महत्वपूर्ण चरण है।

  • Tokenization, Stop Word Removal, Stemming और Lemmatization Text Cleaning के प्रमुख भाग हैं।

  • Bag of Words और TF-IDF Text को Numeric Features में बदलते हैं।

  • Word Embeddings शब्दों के अर्थ को बेहतर ढंग से दर्शाते हैं।

  • Sentiment Analysis और Spam Detection NLP के सामान्य Applications हैं।

  • NER Text से महत्वपूर्ण नाम, स्थान और संगठन जैसी Entities पहचानता है।

  • Transformer आधारित Models आधुनिक NLP का महत्वपूर्ण आधार हैं।


Important Definitions

NLP: Natural Language Processing।

Corpus: Documents का Collection।

Token: Text का छोटा Meaningful भाग।

Stop Words: सामान्य शब्द जिन्हें अक्सर हटाया जाता है।

Stemming: शब्द को उसके मूल रूप के करीब लाना।

Lemmatization: शब्द का Dictionary Form प्राप्त करना।

TF-IDF: महत्वपूर्ण शब्दों को अधिक Weight देने की तकनीक।

NER: Named Entity Recognition।

Transformer: आधुनिक NLP Models की एक प्रभावशाली Architecture।


Common Mistakes Students Make

  1. Text Cleaning किए बिना Model Train करना।

  2. Stop Words हटाने की आवश्यकता होने पर भी उन्हें छोड़ देना या जहाँ ज़रूरत हो वहाँ बिना सोचे-समझे हटा देना।

  3. Stemming और Lemmatization में अंतर न समझना।

  4. Training और Testing Data को मिलाना।

  5. Imbalanced Dataset का ध्यान न रखना।

  6. केवल Accuracy देखकर Model का मूल्यांकन करना।

  7. Domain के अनुसार सही Text Preprocessing न चुनना।


Practice Questions (With Answers)

1. NLP का पूरा नाम क्या है?

Answer: Natural Language Processing।

2. Tokenization क्या है?

Answer: Text को छोटे-छोटे Tokens (Words या Units) में विभाजित करना।

3. Stop Words क्या होते हैं?

Answer: ऐसे सामान्य शब्द जो अक्सर कम अर्थपूर्ण जानकारी देते हैं।

4. Stemming और Lemmatization में मुख्य अंतर क्या है?

Answer: Stemming शब्द को Root Form के करीब लाता है, जबकि Lemmatization Dictionary Form देता है।

5. TF-IDF का उपयोग क्यों किया जाता है?

Answer: महत्वपूर्ण Words को अधिक Weight देने के लिए।

6. NER का पूरा नाम क्या है?

Answer: Named Entity Recognition।

7. Sentiment Analysis क्या बताता है?

Answer: Text का Positive, Negative या Neutral भाव।

8. Spam Detection किस प्रकार की समस्या है?

Answer: Classification।

9. Word2Vec का उद्देश्य क्या है?

Answer: शब्दों को Meaningful Vector Representation में बदलना।

10. आधुनिक NLP में Transformer क्यों महत्वपूर्ण है?

Answer: क्योंकि यह Context को प्रभावी ढंग से समझकर Translation, Summarization, Question Answering और Text Generation जैसे कार्यों में उत्कृष्ट प्रदर्शन करता है।


🎯 Homework

  1. Movie Review Sentiment Analyzer बनाइए।

  2. SMS Spam Detector तैयार कीजिए।

  3. किसी Text File पर TF-IDF लागू करके महत्वपूर्ण Keywords निकालिए।

  4. NER का उपयोग करके किसी समाचार लेख से Person, Location और Organization पहचानिए।

  5. एक सरल FAQ Chatbot बनाइए जो 10–15 सामान्य प्रश्नों के उत्तर दे सके।


📌 अगले Part 22 में हम सीखेंगे:

🚀 Generative AI, Large Language Models (LLMs) & AI Applications

  • Generative AI क्या है?

  • Large Language Models (LLMs)

  • Prompt Engineering

  • AI Assistants

  • Retrieval-Augmented Generation (RAG) का परिचय

  • AI Agents का परिचय

  • Text Generation

  • Image Generation का परिचय

  • Code Generation

  • AI APIs का उपयोग

  • Responsible AI और AI Ethics

  • Real-World AI Projects

Part 22 से आप आधुनिक Generative AI की दुनिया में प्रवेश करेंगे और समझेंगे कि ChatGPT जैसे AI Assistants कैसे काम करते हैं तथा उनके साथ Applications कैसे बनाई जाती हैं।


🐍 Python Complete Course

Part 22 – Generative AI, Large Language Models (LLMs) & AI Applications (Complete Mastery)

Level: Expert
Duration: 20–25 Hours
Goal: इस Chapter के बाद आप Generative AI, Large Language Models (LLMs), Prompt Engineering, AI APIs और आधुनिक AI Applications की मजबूत समझ विकसित कर लेंगे। आप Python की सहायता से AI आधारित Applications बनाना शुरू कर सकेंगे।


📚 आज हम क्या सीखेंगे?

🟢 Section A – Generative AI Basics

  • Generative AI क्या है?

  • Traditional AI vs Generative AI

  • LLM (Large Language Model) क्या है?

  • Tokens क्या होते हैं?

  • Context Window


🔵 Section B – Prompt Engineering

  • Prompt क्या है?

  • Effective Prompt कैसे लिखें?

  • Zero-shot Prompting

  • One-shot Prompting

  • Few-shot Prompting

  • Chain of Thought (परिचय)

  • Prompt Templates


🟣 Section C – AI APIs & Python

  • AI APIs क्या हैं?

  • API Key

  • Environment Variables

  • Python से AI API Call

  • Streaming Responses

  • Error Handling

  • Cost Optimization


🔴 Section D – AI Applications

  • AI Chatbot

  • AI Content Generator

  • AI Code Assistant

  • AI Translator

  • AI Document Summarizer

  • AI Email Writer


🟠 Section E – Advanced AI Concepts

  • Retrieval-Augmented Generation (RAG) का परिचय

  • AI Agents का परिचय

  • Vector Database का परिचय

  • Embeddings क्या हैं?

  • Responsible AI

  • AI Ethics


🟢 Section A – Generative AI Basics

Generative AI क्या है?

Generative AI ऐसे AI Models का समूह है जो नया Content बना सकते हैं।

उदाहरण:

  • Text

  • Images

  • Audio

  • Code

  • Video


Real Life Examples

  • ChatGPT

  • AI Image Generators

  • AI Coding Assistants

  • AI Music Tools


Traditional AI vs Generative AI

Traditional AIGenerative AI
Prediction करता हैनया Content बनाता है
ClassificationText Generation
RecommendationImage Generation
Fraud DetectionCode Generation

Large Language Model (LLM) क्या है?

LLM एक Deep Learning आधारित Language Model है जिसे बहुत बड़ी मात्रा में Text Data पर प्रशिक्षित (Train) किया जाता है ताकि वह भाषा के Patterns को समझ सके और उपयोगी उत्तर तैयार कर सके।


Tokens क्या हैं?

LLMs पूरे Paragraph को एक साथ नहीं पढ़ते।

वे Text को छोटे-छोटे भागों (Tokens) में विभाजित करके Process करते हैं।

Example

Sentence

Python is amazing.

संभव Tokens

Python

is

amazing

.

Context Window

Context Window वह सीमा है जितना Text Model एक समय में ध्यान में रख सकता है।


🔵 Section B – Prompt Engineering

Prompt क्या है?

Prompt वह Instruction है जो हम AI को देते हैं।

Example

Python में Fibonacci Program लिखिए।

Effective Prompt कैसे लिखें?

एक अच्छा Prompt सामान्यतः इन बातों को स्पष्ट करता है:

  • उद्देश्य (Goal)

  • Context

  • Format

  • Language

  • Constraints


Example

कमज़ोर Prompt

Python बताओ।

बेहतर Prompt

Beginner के लिए Python में List को आसान भाषा में उदाहरण सहित समझाइए।

Zero-shot Prompting

Model को बिना किसी Example के Instruction देना।


One-shot Prompting

एक Example देकर नया उत्तर माँगना।


Few-shot Prompting

कई Examples देकर Model को Pattern समझाना।


Chain of Thought (Introduction)

कुछ जटिल समस्याओं में समस्या को छोटे-छोटे चरणों में सोचने की रणनीति उपयोगी हो सकती है। व्यवहार में हमेशा विस्तृत आंतरिक तर्क की आवश्यकता नहीं होती; अक्सर स्पष्ट चरण, उदाहरण और आवश्यक निर्देश देना पर्याप्त होता है।


Prompt Template

Role:
Task:
Context:
Output Format:
Constraints:

🟣 Section C – AI APIs & Python

AI API क्या है?

AI API की सहायता से Python Program किसी AI Service से उत्तर प्राप्त कर सकता है।


API Key

API Key एक Secret Key होती है जो आपकी Application को Authenticate करती है।

महत्वपूर्ण: API Key को कभी भी Public Repository या Source Code में Hardcode न करें।


Environment Variables

import os

api_key = os.getenv("API_KEY")

Basic API Request (Concept)

import requests

headers = {
    "Authorization": "Bearer YOUR_API_KEY"
}

response = requests.post(
    "https://example-api.com/v1/chat",
    headers=headers,
    json={
        "message": "Hello"
    }
)

print(response.json())

वास्तविक API का Endpoint, Parameters और Response Structure Service Provider के अनुसार अलग हो सकता है।


Error Handling

try:
    response.raise_for_status()
except Exception as e:
    print(e)

Streaming Responses (Introduction)

कुछ AI APIs उत्तर को एक साथ भेजने के बजाय धीरे-धीरे (Streaming) भेजती हैं ताकि User को जल्दी Response दिखाई दे।


Cost Optimization

  • छोटे Prompt लिखें।

  • अनावश्यक Context न भेजें।

  • केवल आवश्यक Output माँगें।

  • Responses Cache करें (जहाँ उपयुक्त हो)।


🔴 Section D – AI Applications

Project 1 – AI Chatbot

Features

  • User Question

  • AI Response

  • Chat History


Project 2 – AI Content Writer

Features

  • Blog Generation

  • SEO Outline

  • Title Suggestions


Project 3 – AI Email Assistant

Features

  • Professional Emails

  • Grammar Improvement

  • Reply Suggestions


Project 4 – AI Translator

Features

  • Multi-language Translation

  • Language Detection


Project 5 – AI Document Summarizer

Features

  • Long Document Summary

  • Key Points

  • Bullet Format


Project 6 – AI Code Assistant

Features

  • Python Code

  • Bug Fix Suggestions

  • Code Explanation


Project 7 – AI Study Assistant

Features

  • Notes Generation

  • Quiz Creation

  • Flashcards


Project 8 – AI Resume Helper

Features

  • Resume Improvement

  • Skill Suggestions

  • Professional Summary


🟠 Section E – Advanced AI Concepts

Retrieval-Augmented Generation (RAG)

RAG में AI Model को बाहरी Documents या Knowledge Base से आवश्यक जानकारी उपलब्ध कराई जाती है ताकि वह अधिक सटीक और अद्यतन उत्तर दे सके।


AI Agents (Introduction)

AI Agent ऐसा System है जो किसी Goal को पूरा करने के लिए Planning, Tool Usage और Decision Making का उपयोग कर सकता है।


Embeddings

Embeddings Text को Numeric Vectors में बदलती हैं ताकि समान अर्थ वाले Text को खोजा और तुलना किया जा सके।


Vector Database (Introduction)

Vector Database Embeddings को Store और Search करने के लिए उपयोग किया जाता है।


Responsible AI

Responsible AI का उद्देश्य AI Systems को सुरक्षित, निष्पक्ष, पारदर्शी और उपयोगी बनाना है।


AI Ethics

महत्वपूर्ण विषय:

  • Privacy

  • Bias

  • Fairness

  • Transparency

  • Human Oversight

  • Copyright का सम्मान

  • सुरक्षित उपयोग


🟠 Final Real-World Projects

Project 1 – AI Customer Support Bot

Features

  • FAQ

  • Ticket Suggestions

  • Conversation History


Project 2 – AI Blog Generator

Features

  • SEO Content

  • Headings

  • Meta Description


Project 3 – AI Research Assistant

Features

  • Notes

  • Summary

  • Key Insights


Project 4 – AI PDF Assistant

Features

  • PDF Upload

  • Question Answering

  • Summary


Project 5 – AI Coding Tutor

Features

  • Code Explanation

  • Practice Questions

  • Bug Detection


Project 6 – AI Business Assistant

Features

  • Email Drafts

  • Meeting Notes

  • Report Summaries


Project 7 – AI Personal Study Planner

Features

  • Daily Schedule

  • Revision Plan

  • Progress Tracking


Project 8 – AI Knowledge Base Search

Features

  • Document Search

  • Semantic Search

  • Related Answers


Key Concepts Summary

  • Generative AI नया Content बना सकता है।

  • LLMs बड़े Text Datasets से भाषा के Patterns सीखते हैं।

  • Prompt Engineering बेहतर AI Results प्राप्त करने में महत्वपूर्ण भूमिका निभाती है।

  • API Keys को सुरक्षित रखना आवश्यक है।

  • RAG बाहरी Knowledge का उपयोग करके AI Responses को बेहतर बना सकता है।

  • AI Agents कई चरणों वाले कार्यों में Tools का उपयोग कर सकते हैं।

  • Embeddings Semantic Search और Recommendation Systems में उपयोगी हैं।

  • Responsible AI और AI Ethics आधुनिक AI Development के महत्वपूर्ण भाग हैं।


Important Definitions

Generative AI: नया Content बनाने वाली AI Technology।

LLM: Large Language Model।

Token: Text की Processing Unit।

Prompt: AI को दिया गया Instruction।

Embedding: Text का Numeric Representation।

RAG: Retrieval-Augmented Generation।

AI Agent: Goal पूरा करने के लिए निर्णय लेने वाला AI System।

Vector Database: Embeddings Store और Search करने वाला Database।


Common Mistakes Students Make

  1. अस्पष्ट Prompt लिखना।

  2. API Keys को Source Code में Hardcode करना।

  3. AI के उत्तरों को बिना Verify किए सही मान लेना।

  4. Sensitive Data को बिना आवश्यकता AI Services को भेजना।

  5. Cost Monitoring को Ignore करना।

  6. Responsible AI और Privacy का ध्यान न रखना।

  7. Context बहुत लंबा या बहुत छोटा देना।


Practice Questions (With Answers)

1. Generative AI क्या है?

Answer: ऐसी AI Technology जो नया Text, Image, Code या अन्य Content बना सकती है।

2. LLM का पूरा नाम क्या है?

Answer: Large Language Model।

3. Prompt क्या होता है?

Answer: AI को दिया गया Instruction।

4. API Key का उद्देश्य क्या है?

Answer: Application को Authenticate करना।

5. Embeddings का उपयोग किसलिए होता है?

Answer: Text को Numeric Vector में बदलने और Semantic Search के लिए।

6. RAG का पूरा नाम क्या है?

Answer: Retrieval-Augmented Generation।

7. AI Agent क्या करता है?

Answer: किसी Goal को पूरा करने के लिए Planning और Tools का उपयोग करता है।

8. Responsible AI क्यों महत्वपूर्ण है?

Answer: ताकि AI सुरक्षित, निष्पक्ष और भरोसेमंद तरीके से उपयोग किया जा सके।

9. Context Window क्या है?

Answer: वह सीमा जितना Text Model एक समय में ध्यान में रख सकता है।

10. Prompt Engineering का मुख्य उद्देश्य क्या है?

Answer: AI से अधिक उपयोगी और सटीक उत्तर प्राप्त करना।


🎯 Homework

  1. Python का उपयोग करके एक Simple AI Chat Interface बनाइए।

  2. Prompt Templates तैयार कीजिए और अलग-अलग Prompts के Results की तुलना कीजिए।

  3. किसी Document का AI आधारित Summary Workflow डिज़ाइन कीजिए।

  4. RAG Architecture का एक Diagram बनाकर उसके Components समझाइए।

  5. Responsible AI के पाँच सिद्धांतों पर एक छोटा Note लिखिए।


🎉 आगे क्या?

अब आपने Python की लगभग पूरी Professional Journey पूरी कर ली है:

  • ✅ Python Fundamentals

  • ✅ Object-Oriented Programming

  • ✅ File Handling & Database

  • ✅ Flask Web Development

  • ✅ REST APIs

  • ✅ Automation & Web Scraping

  • ✅ Data Science

  • ✅ Machine Learning

  • ✅ Deep Learning

  • ✅ Natural Language Processing

  • ✅ Generative AI & LLMs

📌 अगला चरण (Part 23 – Capstone Projects & Career Roadmap)

अगले Part में हम केवल Theory नहीं पढ़ेंगे, बल्कि 10–15 Industry-Level Projects बनाएंगे, जैसे:

  • 🤖 AI Chatbot with Memory

  • 🛒 E-Commerce Website (Flask)

  • 💬 Real-Time Chat Application

  • 🎓 Student Management System

  • 🏦 Banking Management System

  • 📊 Sales Analytics Dashboard

  • 🤖 AI Resume Analyzer

  • 📄 PDF Question Answering System

  • 🧠 RAG-based Knowledge Assistant

  • 🚀 Python Developer Portfolio

साथ ही सीखेंगे:

  • Git & GitHub

  • Portfolio Building

  • Resume Writing

  • Freelancing (Fiverr, Upwork)

  • Interview Preparation

  • Python Developer Career Roadmap (2026–2027)

Part 23 इस पूरी Python Series का Grand Finale होगा, जहाँ सीखी हुई सभी Skills को वास्तविक Projects में लागू किया जाएगा।


 

🐍 Python Complete Course

Part 23 – Capstone Projects & Career Roadmap (Grand Finale)

Level: Expert (Industry Ready)
Duration: 30–40 Hours
Goal: इस Chapter के बाद आप एक Professional Python Developer, AI Developer या Data Analyst के रूप में अपना Portfolio तैयार कर सकेंगे। आप वास्तविक (Industry-Level) Projects बनाना, GitHub Portfolio तैयार करना, Resume बनाना, Freelancing शुरू करना और Job Interview की तैयारी करना सीखेंगे।


🎯 इस Chapter में क्या सीखेंगे?

🟢 Section A – Professional Development Setup

  • Python Developer Roadmap

  • Git & GitHub

  • Virtual Environment

  • Project Structure

  • README.md लिखना

  • Requirements.txt

  • Code Documentation


🔵 Section B – Industry Level Capstone Projects

हम शुरुआत से अंत तक Professional Projects बनाएंगे।


🚀 Project 1 – Student Management System

Technologies

  • Python

  • Flask

  • SQLite

  • Bootstrap

Features

  • Student Registration

  • Login

  • Attendance

  • Result Management

  • Fees Management

  • Dashboard

  • Search Student

  • Export PDF


Folder Structure

StudentManagement/

│

app.py

requirements.txt

README.md

database.db

│

templates/

│

static/

│

models/

│

routes/

│

utils/

Skills Covered

  • Flask

  • CRUD

  • Authentication

  • Database

  • Sessions

  • File Upload


🚀 Project 2 – AI Chatbot

Technologies

  • Python

  • Flask

  • AI API

  • HTML

  • CSS

  • JavaScript


Features

  • Chat Interface

  • Chat History

  • Markdown Support

  • Copy Response

  • Dark Mode

  • Typing Animation


Skills Covered

  • API Integration

  • JSON

  • Prompt Engineering

  • Frontend Integration


🚀 Project 3 – Personal Finance Manager

Features

  • Income Tracking

  • Expense Tracking

  • Budget

  • Monthly Report

  • Charts

  • CSV Export


Skills

  • Pandas

  • Matplotlib

  • SQLite


🚀 Project 4 – AI Resume Analyzer

Features

  • Resume Upload

  • Skill Detection

  • Missing Skills

  • Resume Score

  • Suggestions


Skills

  • NLP

  • PDF Reading

  • AI Integration


🚀 Project 5 – Face Recognition Attendance (Educational)

Features

  • Camera Input

  • Face Detection

  • Attendance

  • Excel Export


Skills

  • OpenCV

  • Face Recognition

  • CSV

नोट: Face Recognition Systems बनाते समय Privacy और स्थानीय कानूनों का पालन करना आवश्यक है।


🚀 Project 6 – Sales Dashboard

Features

  • Charts

  • KPIs

  • Monthly Sales

  • Profit

  • Export Excel


Skills

  • Pandas

  • Plotly

  • Dashboard


🚀 Project 7 – E-Commerce Website

Features

  • Login

  • Products

  • Cart

  • Orders

  • Admin Panel

  • Search


Skills

  • Flask

  • Database

  • Sessions

  • Templates


🚀 Project 8 – PDF Question Answering System

Features

  • Upload PDF

  • Search Content

  • Ask Questions

  • Summary


Skills

  • PDF Processing

  • Embeddings (Introduction)

  • RAG Concepts


🚀 Project 9 – News Aggregator

Features

  • Latest News

  • Search

  • Categories

  • Save Articles


Skills

  • APIs

  • JSON

  • Requests


🚀 Project 10 – Weather Dashboard

Features

  • Current Weather

  • Forecast

  • Graphs

  • City Search


Skills

  • REST API

  • Charts

  • Data Processing


🟣 Section C – Git & GitHub

Git क्या है?

Git एक Version Control System है।

यह Code का पूरा इतिहास सुरक्षित रखता है।


GitHub क्या है?

GitHub एक Cloud Platform है जहाँ आप अपना Code Store कर सकते हैं।


Git Install

git --version

पहला Repository

git init

Status Check

git status

Files Add

git add .

Commit

git commit -m "First Commit"

GitHub पर भेजना

git push origin main

README.md

हर Project में README होना चाहिए।

Example

# Student Management System

Features

Installation

Usage

Screenshots

License

requirements.txt

Flask
pandas
numpy
matplotlib
requests

Install

pip install -r requirements.txt

🔴 Section D – Resume & Portfolio

Python Developer Resume

Include

  • Summary

  • Skills

  • Projects

  • Education

  • Certifications

  • GitHub

  • LinkedIn


Portfolio Website

Sections

  • About

  • Skills

  • Projects

  • Resume

  • Contact


GitHub Portfolio

कम से कम

  • 10 अच्छे Projects

  • Proper README

  • Screenshots

  • Installation Guide


Interview Questions

Python

  • OOP

  • List vs Tuple

  • Dictionary

  • Exception Handling


SQL

  • JOIN

  • GROUP BY

  • PRIMARY KEY

  • FOREIGN KEY


Flask

  • Routing

  • Templates

  • Sessions

  • CRUD


Machine Learning

  • Regression

  • Classification

  • Overfitting

  • Cross Validation


AI

  • Neural Network

  • CNN

  • NLP

  • LLM


Coding Practice

Platforms

  • LeetCode

  • HackerRank

  • CodeChef

  • GeeksforGeeks


🟠 Section E – Career Roadmap

Python Developer

Skills

  • Python

  • Flask

  • SQL

  • Git

Average Learning Time

6–8 Months


Data Analyst

Skills

  • Excel

  • SQL

  • Python

  • Pandas

  • Power BI


Data Scientist

Skills

  • Python

  • Machine Learning

  • Statistics

  • Deep Learning


AI Engineer

Skills

  • Python

  • TensorFlow

  • NLP

  • LLM

  • APIs


Backend Developer

Skills

  • Flask

  • Django

  • REST API

  • Database


Freelancing

Platforms

  • Fiverr

  • Upwork

  • Freelancer


Remote Jobs

Platforms

  • LinkedIn

  • Wellfound

  • Remote OK

  • We Work Remotely


💰 Income Opportunities

SkillIncome Source
PythonJob
FlaskFreelancing
Data ScienceConsulting
AIProduct Development
AutomationOffice Solutions
APIsSaaS Development
Web DevelopmentClient Projects

📅 12-Month Learning Plan

Month 1–2

  • Python Basics

  • OOP

  • File Handling


Month 3–4

  • Flask

  • SQL

  • Git


Month 5–6

  • APIs

  • Automation

  • Projects


Month 7–8

  • Data Science

  • Visualization


Month 9–10

  • Machine Learning

  • Deep Learning


Month 11

  • NLP

  • Generative AI


Month 12

  • Portfolio

  • Resume

  • Interviews

  • Freelancing

  • Job Applications


🌟 Final Course Challenge

इन Projects में से कम से कम 5 Projects Complete कीजिए और उन्हें GitHub पर Publish कीजिए।

Beginner

  • Weather App

  • Calculator

  • Expense Tracker


Intermediate

  • Student Management System

  • Blog Website

  • Sales Dashboard


Advanced

  • AI Chatbot

  • Resume Analyzer

  • E-Commerce Website

  • PDF Question Answering


📚 Complete Python Course Summary

इस Complete Series में आपने सीखा—

  • ✅ Python Fundamentals

  • ✅ Variables & Data Types

  • ✅ Operators

  • ✅ Strings

  • ✅ Conditional Statements

  • ✅ Loops

  • ✅ Functions

  • ✅ OOP

  • ✅ File Handling

  • ✅ Exception Handling

  • ✅ Modules & Packages

  • ✅ Database Programming

  • ✅ Flask Web Development

  • ✅ REST APIs

  • ✅ Automation

  • ✅ Web Scraping

  • ✅ Data Science

  • ✅ Machine Learning

  • ✅ Deep Learning

  • ✅ Natural Language Processing

  • ✅ Generative AI

  • ✅ Industry-Level Projects

  • ✅ Career Roadmap


🎯 Final Practice Assignment

एक ऐसा Smart Student Portal बनाइए जिसमें निम्न Features हों:

  • User Registration & Login

  • Student Profile

  • Attendance Management

  • Marks Management

  • PDF Report Card Generation

  • Email Notifications

  • Dashboard with Charts

  • AI Study Assistant (Question Answering)

  • Search Functionality

  • Responsive Web Interface

इस एक Project में आपने इस पूरी Series के लगभग सभी महत्वपूर्ण Concepts का उपयोग कर लिया होगा।


🏆 Congratulations!

आपने "Complete Python Mastery Course" सफलतापूर्वक पूरा कर लिया है।

इस Course के बाद आपके पास Python Programming से लेकर Web Development, Automation, Data Science, Machine Learning, Deep Learning, NLP और Generative AI तक की मजबूत Foundation है।

🚀 अगला सुझाव

अब Theory कम और Practice अधिक करें। अपने GitHub पर नियमित रूप से Projects डालें, Documentation लिखें, और वास्तविक समस्याओं के समाधान बनाने का प्रयास करें। यही Portfolio आपको Freelancing, Internships और Python Developer Jobs के लिए सबसे अधिक मदद करेगा।

🎉 आपकी Python Journey यहीं समाप्त नहीं होती—यहीं से आपकी Professional Journey शुरू होती है।

Post a Comment

0 Comments