Like in this example, I created a tupple with the numeric string wrote and this data types, and you can see that it has created a topic. So I run this function and it gets me that it is a double letter type interval that Apple is created. Generally, it's a good practice to create Apple within parenthesis. And however, we can do it without parentheses and all the elements of the tupple are separated by comma. What if there is only one variable in the tupple for example, this tupple too. I just removed a comma.
And I read I checked the data type for this tupple and it gives me string, actually the Python engine recognizes this as a string. Because how would it know that it is a tupple with only one element. So generally, we put a comma, but there is only a single variable inside a single element inside the tupple. And by this comma by an engineer cognizes, that it is a double data type. Now, let's do it again. Now we get the double data type, we can access the elements in a tupple by using square brackets, and putting the index number within it, for example, at Apple two that we just created as only a single variable and that had an index of zero so so we get this, another example.
Apple, and that's past three as an index. Let's see. It's 3.901 To add 3.9, so we get the exact value. What if I want to get to that has an index of four and second dimension is 012. So it's one. And when I pass this on, I'll get to exactly this.
So you see, a couple can have different data types. And now, as I said that the tupple elements in the tupple cannot change, we cannot assign different values. Once a value is defined in a tupple. We cannot change it. Let's try changing it. Double v Let's do 2.8 instead, earlier it was Apple three had a valid 3.9.
I just reassigned the value of 2.8 to Apple with an index three. Let's see what it does. So this gives an error tupple object does not support item assignment, it cannot reassign a value. So now in list we can change, we can assign different values, or we can change to an already assigned value to to a new value at Apple can have a list inside it as well. So if I try changing the elements within that list, can I do it? Let's try for this index, the value was two now I'm assigning another value.
Three to it. Let's see if it does or not. It does When the list is passed when a list is inside the tupple still we can change its value. Let's see all the values and see if this value has been assigned to three instead of two. There are a couple of advantages for top elements in the tupple are right protected, since it cannot be reassigned it is right preset protected unless there is a nested side topple. And iterating through a topple is faster than then in the list because once the elements assigned to within the tupple cannot be changed.
And another that we just discussed. We discussed earlier that tupple elements can be used as in dictionary tupple elements can be used as the key in the dictionary. And let's try to pass a float as an index parameter to get the value The top of point zero it gives an error. So, interval, we can only use integer in the index to get the value. Getting a passing a float value, inside a tupple at an index is not allowed, allowed. Slicing in interval is similar to index is similar to slicing next, for example, double zero to three needs index zero to index two Three excluded.
And let's see, what do we get one, two and eight. Let's do a bit differently, negative three. So it means it is going to get all the elements from zero to negative three. This is minus one minus two minus three, it's going to get one to negative three is excluded. So from zero to negative three, one and two are that if we want to get all the elements of multiple, just write, write down either this topple and get the answer or pass on just call it get all that so the top experts discuss the deleting changing the elements in Within the tupple is not possible. However, if you want to like remove or change, delete an entire tuple we can use double, double, two and this will delete all the elements or in fact the whole topic.
So now it has deleted the apple two. Now, when I tried this season the apple two is not defined because this stuff or two has been deleted a couple of methods for Apple that we'll discuss in the next video. Thank you