Home >> Python Tutorial >> Python Tuple
Edit Template
Edit Template

Python Tuple in Hindi

What is Tuple in Python in Hindi

Python में  Tuple, data का एक ordered और immutable collection होता है जो Elements को round bracket के अंदर  comma separate करके  Store करता है, Tuple का use हम तब करते हैं जब हमें data को  unchangeable form मे store करना होता है।

🐍
tuple.py
Copy to clipboard
num_tuple = (4, 3, 8)
print(num_tuple)

# Output : (4, 3, 8)

How to Access Tuple Items in Hindi

indexing का use करके हम tuple के elements को access कर सकते हैं, indexing 0 से शुरू होती है tuple में negative indexing भी possival है यह -1 से शुरू होती है जो की last value को represent करता है

🐍
access.py
Copy to clipboard
fruits = ("banana", "apple", "guava")
print(fruits[0])
print(fruits[1])
print(fruits[-1])
# Output :  banana
            apple
            guava

How to Updates Tuple in Hindi

Tuple immutable होने के कारण हम इसे direct update तो नहीं कर सकते but अगर tuple के अंदर mutable elements हो जैसे list तो उन elements को modified किया जा सकता है

🐍
update.py
Copy to clipboard
num = (4, 6, [5, 2])
num[2][0] = 1
print(num)

# Output : (4, 6, [1, 2])

How to Iterate Tuple Items in Hindi

tuple के items को iterate करने के लिए हम loop का use करते हैं

🐍
iterate.py
Copy to clipboard
fruits = ("banana", "apple", "guava")
for i in fruits:
    print(i)
# Output :  banana
#           apple
#           guava

How to Join More Than One Tuples in hindi

+ operator का use करके हम दो या दो से ज्यादा tuples को join कर सकते है

🐍
join.py
Copy to clipboard
num1 = (4, 3, 8)
num2 = (2, 1, 5)
print(num1 + num2)

# Output : (4, 3, 8, 2, 1, 5)

Nested Tuple in Hindi

जब हम tuple के अंदर भी tuple का use करते हैं तो इसे nested tuple कहा जाता है

🐍
nested.py
Copy to clipboard
num1 = (4, 3, (2, 1, 5), 8)
print(num1)

# Output : (4, 3, (2, 1, 5), 8)

Tuple Methods in Hindi

python मे tuple के लिए कुछ ही build-in methods होते है, क्योंकि tuple immutable होता है। 

Syntex:

method को किसी भी variable के साथ use करने के लिए dot ( . ) का use करते है।

Example:

count() : इस method का use करके हम tuple के किसी element को काउंट कर सकते हैं। कि वो element, tuple में कितनी बार आया है.

🐍
count.py
Copy to clipboard
my_tuple = (1, 2, 3, 2, 4, 2, 5)
count_of_2 = my_tuple.count(2)
print(f"Count of 2: {count_of_2}") # Output: Count of 2: 3

count_of_6 = my_tuple.count(6)
print(f"Count of 6: {count_of_6}") # Output: Count of 6: 0

another_tuple = ('apple', 'banana', 'apple', 'orange')
count_apple = another_tuple.count('apple')
print(f"Count of 'apple': {count_apple}") # Output: Count of 'apple': 2

यहाँ कुछ tuple के methods दिए गए है जिन्हे आप इसी तरह से tuple के साथ use करके इनके result को देख सकते है।

 

🐍
tuple methods.py
Copy to clipboard
my_tuple1 = (1, 2, 3, 4, 5)
total_sum = sum(my_tuple)
print(f"Sum of elements: {total_sum}") 
# Output: Sum of elements: 15

my_list = [1, 2, 3]
new_tuple_from_list = tuple(my_list)
print(f"Tuple from list: {new_tuple_from_list}") 
# Output: Tuple from list: (1, 2, 3)

my_tuple2 = (10, 5, 20, 3)
minimum_value = min(my_tuple)
print(f"Minimum value: {minimum_value}") 
# Output: Minimum value: 3

my_tuple3 = (5, 2, 8, 1, 9)
sorted_list = sorted(my_tuple)
print(f"Original tuple: {my_tuple}")    
# Output: Original tuple: (5, 2, 8, 1, 9)
print(f"Sorted list: {sorted_list}")    
# Output: Sorted list: [1, 2, 5, 8, 9]

my_tuple4 = (1, 2, 3, 'hello')
length = len(my_tuple)
print(f"Length of the tuple: {length}") 
# Output: Length of the tuple: 4

उम्मीद करते है कि आपको python tuple अच्छे समझ मे आ गया होगा । अपने learning को continue रखने के लिए next button पर click करे,

Add a comment...

  • All Posts
  • Artificial Intelligence
  • Computer Fundamentals
  • Computer Networks
  • Data Analytics
  • Data Science
  • DBMS
  • Deep Learning
  • Digital Fundamentals
  • DSA with Python
  • Excel
  • Exercise
  • Git & Github
  • Machine Learning
  • Matplotlib
  • Natural Language Processing
  • NumPy
  • Operating System
  • Pandas-s
  • Power BI
  • Python Tutorial
  • Scikit-learn
  • Seaborn
  • SQL & MySQL
Python Set

Table of Contents All Chapters 1. Python Set 2. Iterate Set items 3. Set Methods      3.1. Add items...

Python Tuple

Table of Contents All Chapters 1. Python Tuple 2. Access Tuple Items 3. Update Tuple 4. Iterate Tuple Items 5....

Python List

Table of Contents All Chapters 1. Python List 2. Nested List 3. Range List 4. List Indexing 5. list Methods...

Python String

Table of Contents All Chapters 1. Python String 2. String Indexing 3. String Slicing 4. String Concatenation 5. String Formatting...

Python Loops

Table of Contents All Chapters 1. Python Loops 2. While Loop      2.1. Nested While Loop 3. For Loop...

Python Operators

Table of Contents All Chapters 1. Python Operators 2. Types of Operators in Python      2.1. Arithmetic Operators  ...

Python Data Type

Table of Contents All Chapters 1. Data Type 2. Types of Data Type      2.1. Numeric Data Type  ...

Scikit-learn

Table of Contents All Chapters 1. Scikit Learn 2. Install Scikit-learn 3. Features of Scikit-learn Scikit-learn Tutorial Scikit-learn Hamburger Toggle...

Edit Template
Scroll to Top