Hello World!!!!!!!!! Welcome Back to my World. Its JITHU, your friend who gonna help you to play with Python. Let’s get ready for getting dirty your hands. Today we will dive into Day-9 that is TUPLE. Yeap this is another Data-Structure as I promised you that I will tell u one DataStructure a day, let’s Begin with a Question What is TUPLE?
What is Tuple?
Let me answer this in a simple way, Tuples are the immutable Lists and it has Parenthesis ().
Creation of Tuple:
Creating a Tuple without any Element.
A Tuple that containing only integers is called Numbered Tuple.
A Tuple that contains only Strings is called String Tuple.
A Tuple that contains both the integers and String type of data is called Mixed Tuple.
A Tuple that contains integers, string, and Other lists are called as nested Tuple.
Tuples can be created in another 2 ways…
Creating a Tuple without Parenthesis is called Packing Tuple
Creating a with parenthesis and getting the tuple name by accessing the tuple items.
By Default, the Single Character in the Tuple may be an “int” Or “Str”, But it can be overridden by adding a Comma[,] to it.
Python has 2 Methods. They are 1] count() 2] index()
This method is used for count the items that the user mentioned in the parenthesis. SYNTAX: tuple.count(x)
This method is used to get the index value of the first item in the tuple SYNTAX: tuple.index(x)
Hey, Tuples are immutable so if want to delete Or add elements what to do know?
Adding and Deleting Elements in Tuple:
Built-in functions in Tuple:
This method returns true when all items are iterable, or false.
TRUE: when all Elements in the iterable are true.
FALSE: when all the Elements in the iterable are false.
This method returns true when any element in the iterable is true, or false.
Bye, Wizards Let’s meet later with the Topic called SETS……….