Important Notice:

Course Content
Tuples in Python (Chapter-8) M3-R5
About Lesson

Tuple:-

           Tuple Python का एक ऐसा Data Structure है, जिसे एक बार Define कर देने के बाद Change नहीं किया जा सकता। Tuples एक प्रकार के Sequence होते हैं लेकिन ये Strings की तरह ही Immutable होते हैं। Python में tuple का प्रयोग हम multiple data elements को store करने के लिए करते है। जिस तरह से List को Square Brackets और Dictionary को Curly Braces के माध्‍यम से Specify किया जाता है। ठीक उसी तरह से Tuples को Specify करने के लिए Parenthesis का प्रयोग किया जाता है, और Tuples में हम किसी भी प्रकार के Data को Store कर सकते हैं, किसी भी प्रकार के Data की Nesting कर सकते हैं

newtuple= (“grapes”, “mango”, “cherry”)

print(newtuple)                #  (“grapes”, “mango”, “cherry”)

 

t1 = (“apple”, “banana”, “cherry”)

t2 = (1, 5, 7, 9, 3)

t3 = (True, False, False)

print(t1)                                   # (‘apple’, ‘banana’, ‘cherry’)

print(t2)                                   # (1, 5, 7, 9, 3)

print(t3)                                   # (True, False, False)

 

 

Tuple:-

             Tuple is a data structure of Python, which once defined cannot be changed. Tuples are a type of sequence but they are immutable like Strings. In Python we use tuple to store multiple data elements. The way List is specified through Square Brackets and Dictionary through Curly Braces. In the same way, Parenthesis is used to specify Tuples, and in Tuples we can store any type of data, can do nesting of any type of data.

 

newtuple= (“grapes”, “mango”, “cherry”)

print(newtuple)                  #  (“grapes”, “mango”, “cherry”)

 

t1 = (“apple”, “banana”, “cherry”)

t2 = (1, 5, 7, 9, 3)

t3 = (True, False, False)

print(t1)                                   # (‘apple’, ‘banana’, ‘cherry’)

print(t2)                                   # (1, 5, 7, 9, 3)

print(t3)                                   # (True, False, False)

error: Content is protected !!