1 00:00:00,659 --> 00:00:02,140 - [Instructor] We have two self check 2 00:00:02,140 --> 00:00:04,880 exercises for you here on tuples. 3 00:00:04,880 --> 00:00:07,450 In the first one, we'd like you to create a single element 4 00:00:07,450 --> 00:00:11,702 tuple that just contains the floating point value 123.45 5 00:00:11,702 --> 00:00:15,136 and display it, and in the second one, we want you to 6 00:00:15,136 --> 00:00:19,190 test out what happens if you add together 7 00:00:19,190 --> 00:00:23,180 with the plus operator two sequences of different types, 8 00:00:23,180 --> 00:00:24,330 which is something that I didn't 9 00:00:24,330 --> 00:00:27,100 actually mention in the preceding video. 10 00:00:27,100 --> 00:00:29,903 So give those a shot and then come back for the answers. 11 00:00:34,780 --> 00:00:36,870 Okay, let's go ahead and reveal the 12 00:00:36,870 --> 00:00:39,010 answer here for the first exercise. 13 00:00:39,010 --> 00:00:42,580 Again, with a singleton tuple, what defines this 14 00:00:42,580 --> 00:00:45,430 as a tuple is the comma, not the parentheses, 15 00:00:45,430 --> 00:00:49,200 but we use the parentheses for readability and emphasis. 16 00:00:49,200 --> 00:00:51,920 So let's just go ahead and display the contents 17 00:00:51,920 --> 00:00:54,950 of that tuple after creating it, and again, 18 00:00:54,950 --> 00:00:58,220 when it displays a singleton tuple to emphasize 19 00:00:58,220 --> 00:01:01,920 that it is a tuple, not just a value in parentheses, 20 00:01:01,920 --> 00:01:05,366 they put the comma at the end of that one value. 21 00:01:05,366 --> 00:01:08,810 Now, in this second exercise, we did not talk 22 00:01:08,810 --> 00:01:12,476 previously about the fact that the plus operator 23 00:01:12,476 --> 00:01:16,240 requires two arguments of the same type. 24 00:01:16,240 --> 00:01:18,770 Now of course, it'll work with a floating point number 25 00:01:18,770 --> 00:01:21,440 and an integer because it can treat the integer 26 00:01:21,440 --> 00:01:24,550 as a floating point number in that case, 27 00:01:24,550 --> 00:01:28,209 but when it comes to sequences being concatenated 28 00:01:28,209 --> 00:01:32,320 with the plus operator, you can see that by executing this, 29 00:01:32,320 --> 00:01:34,950 we wind up with a type error, indicating that 30 00:01:34,950 --> 00:01:38,190 you can only concatenate a list to a list. 31 00:01:38,190 --> 00:01:42,540 So it's making that decision based on which type of object 32 00:01:42,540 --> 00:01:45,310 is on the left side of the operator in terms of 33 00:01:45,310 --> 00:01:48,570 the error message that it's actually displaying here. 34 00:01:48,570 --> 00:01:51,720 So for concatenating data structures together, 35 00:01:51,720 --> 00:01:54,870 or sequences together, you have to have two sequences 36 00:01:54,870 --> 00:01:57,613 of the same type, so that would be of course two lists, 37 00:01:57,613 --> 00:02:02,150 two tuples, or two strings, in which case the two strings' 38 00:02:02,150 --> 00:02:05,613 contents would be added together or concatenated.