- [Instructor] We have two self check
exercises for you here on tuples.
In the first one, we'd like you to create a single element
tuple that just contains the floating point value 123.45
and display it, and in the second one, we want you to
test out what happens if you add together
with the plus operator two sequences of different types,
which is something that I didn't
actually mention in the preceding video.
So give those a shot and then come back for the answers.
Okay, let's go ahead and reveal the
answer here for the first exercise.
Again, with a singleton tuple, what defines this
as a tuple is the comma, not the parentheses,
but we use the parentheses for readability and emphasis.
So let's just go ahead and display the contents
of that tuple after creating it, and again,
when it displays a singleton tuple to emphasize
that it is a tuple, not just a value in parentheses,
they put the comma at the end of that one value.
Now, in this second exercise, we did not talk
previously about the fact that the plus operator
requires two arguments of the same type.
Now of course, it'll work with a floating point number
and an integer because it can treat the integer
as a floating point number in that case,
but when it comes to sequences being concatenated
with the plus operator, you can see that by executing this,
we wind up with a type error, indicating that
you can only concatenate a list to a list.
So it's making that decision based on which type of object
is on the left side of the operator in terms of
the error message that it's actually displaying here.
So for concatenating data structures together,
or sequences together, you have to have two sequences
of the same type, so that would be of course two lists,
two tuples, or two strings, in which case the two strings'
contents would be added together or concatenated.