We will see the different building functions with Japan.
It's the first function is all and this function returns true if all of the elements of the tuple are
true or if the tuple is empty.
Now let us pass the tuple to do to this function.
Since all of the elements in Japan are true this function returns true.
Now we will define and not that tuple which contains the following element 0 or 1 2 3.
So the tuple Contains these elements.
If you can recall from our discussion on boolean data type the value 0 is considered false whereas 1
is considered true.
So if we pass this tuple to the function all it has returned funds because zero is considered false.
This function has returned false.
Similarly let's define another tuple which is empty and if we now pass this jeopardy to the function
ie it is going to return true because this function returns true even if the tuple is empty.
Next is the any function and it returns true if any of the element is true.
If the tuple is empty it returns false.
So if we pass the tuple to 6 to the function in need it's going to return false because this tuple is
empty.
Next if we pass the tuple to 5 which contains one of the elements which is false and the other elements
are true in that case it should return true because because this function returns true even if one of
the elements is true.
Next is the length function which it adorned the length of the tuple or the number of items in the tuple
Max returns the largest item in the tuple.
So let us now pass the tuple to 5 to the function Max.
So it is going to return 3 because 3 is the largest number in this tuple coming to the next function
men it is going to return the least number in the tuple.
So this is going to return 0 from the stupid next is the sum function and it is going to return the
sum of all the elements in a tuple so if we pass this triple chip five to the function sum it's going
to calculate the sum of the elements in this tuple 0 1 2 and 3.
Next is the function tuple and this constructor the tuple constructor can be used to create a tuple
it can be used to convert an item a goal like a list string set or a dictionary to Japan.
So here I have defined a string containing this text.
And then I have defined a list containing these elements.
Now using the built in function tuple also known as the tuple constructor I can convert an eye trouble
into a tuple.
So let us pass this string SDR one to the to the built in function tuple auditable constructor.
So as you can see the string SDR 1 has been converted into a tuple each substring in the string is converted
into an element in the tuple enclosed in parentheses.
Now let us pass a list which is another item a bill to the built in function tuple so this list has
been converted to a tuple here.
As you can see if you want to check the type of the tuple your ID we can pass this as an argument to
the function type.
And as you can see the data type is Japan.
Next is.
We are going to discuss about the methods that can be used on Python tuples the index method it returns
the index of the first appearance of an item manageable.
So I'm going to call the index method on the tuple to 5 and I want to know the index of the element
to in this tuple so the element 2 has an index 2 as you can see next as the count method and it returns
the number of times an item appears in our tuple so calling the method count on the tuple took five.
I'm going to pass the element 1 and it has appeared once in this tuple and say for example I want to
pass another element which is not present.
Indeed Japan in that case it returns zero because the element 6 does not exist in the Japan.
And this brings us to the end of the topic on functions and method entrepreneurs.