Type Here to Get Search Results !

Advanced Python Topics in Hindi | पाइथन के एडवांस्ड टॉपिक्स सीखें

0
Advanced Python Topics in Hindi | पाइथन के एडवांस्ड टॉपिक्स सीखें

Advanced Python Topics in Hindi | पाइथन के एडवांस्ड टॉपिक्स सीखें

📘 Chapter 11: एडवांस्ड टॉपिक्स

Python की असली ताकत इसके एडवांस्ड टॉपिक्स में छुपी होती है। इस अध्याय में हम जानेंगे Python की कुछ खास खूबियों के बारे में, जो आपके कोड को स्मार्ट और प्रोफेशनल बनाती हैं।

🔹 Lambda Function (एनॉनिमस फंक्शन)

add = lambda x, y: x + y
print(add(10, 5))

Lambda फंक्शन एक लाइन में लिखा जाने वाला छोटा function होता है।

🔹 List Comprehension

nums = [x for x in range(10) if x % 2 == 0]
print(nums)  # [0, 2, 4, 6, 8]

लिस्ट comprehension से कोड छोटा और तेज बनता है।

🔹 Dictionary Comprehension

square = {x: x*x for x in range(1, 6)}
print(square)

🔹 Generator Function

def counter():
    for i in range(5):
        yield i

for val in counter():
    print(val)

Generators मेमोरी बचाते हैं और lazy loading के लिए उपयोगी होते हैं।

🔹 Decorators

def decorator(func):
    def wrapper():
        print("Function call हो रहा है")
        func()
        print("Function call समाप्त")
    return wrapper

@decorator
def greet():
    print("नमस्ते!")

greet()

🔹 Database Connection (SQLite)

import sqlite3

conn = sqlite3.connect('mydata.db')
cursor = conn.cursor()

cursor.execute("CREATE TABLE IF NOT EXISTS student (name TEXT, roll INTEGER)")
cursor.execute("INSERT INTO student VALUES ('राहुल', 101)")
conn.commit()

cursor.execute("SELECT * FROM student")
print(cursor.fetchall())

conn.close()

SQLite के ज़रिए Python से सीधे database से डेटा पढ़ना और लिखना संभव है।

📌 इस चैप्टर में आपने सीखा:

  • Lambda Function और List/Dictionary Comprehension
  • Generators और Decorators
  • SQLite Database से कनेक्शन

➡️ Next Chapter:

Chapter 12: Python Projects – छोटे-छोटे Python प्रोजेक्ट्स बनाना सीखें

Tags

Post a Comment

0 Comments

Show ad in Posts/Pages