Python Lists in Hindi | पाइथन लिस्ट क्या है और कैसे उपयोग करें?
📘 Chapter 6: पाइथन में लिस्ट (List in Python in Hindi)
पाइथन में लिस्ट (List) एक ordered collection होता है जिसमें आप एक से अधिक items को एक साथ store कर सकते हैं।
🔹 लिस्ट कैसे बनाते हैं?
my_list = [1, 2, 3, 4, 5]
print(my_list)
🔹 लिस्ट में अलग-अलग टाइप के डेटा हो सकते हैं:
mixed_list = [1, "Hello", 3.14, True]
print(mixed_list)
🔹 लिस्ट में indexing:
numbers = [10, 20, 30, 40]
print(numbers[0]) # पहला आइटम
print(numbers[-1]) # आखिरी आइटम
🔹 लिस्ट में slicing:
print(numbers[1:3]) # 20 और 30
🔹 लिस्ट के महत्वपूर्ण methods:
fruits = ["apple", "banana", "cherry"]
fruits.append("mango") # नया आइटम जोड़ना
fruits.remove("banana") # आइटम हटाना
fruits.sort() # सॉर्ट करना
print(fruits)
🔹 लिस्ट में loop:
for fruit in fruits:
print(fruit)
🔹 लिस्ट को अपडेट कैसे करें?
fruits[1] = "orange"
print(fruits)
🔹 लिस्ट को जोड़ना (Concatenation):
list1 = [1, 2]
list2 = [3, 4]
combined = list1 + list2
print(combined)
📌 इस चैप्टर में आपने सीखा:
- लिस्ट क्या होती है
- Indexing और Slicing
- List methods जैसे append(), remove(), sort()
- लूप के साथ लिस्ट का उपयोग
- लिस्ट अपडेट और जोड़ना
➡️ अगला चैप्टर:
Chapter 7: Python Tuples – ट्यूपल क्या है और लिस्ट से कैसे अलग है?
Post a Comment
0 Comments