1 00:00:08,871 --> 00:00:10,497 Welcome back. 2 00:00:10,497 --> 00:00:15,334 In many places where the Python interpreter is expecting a single value, 3 00:00:15,334 --> 00:00:19,703 but the code provides multiple expressions separated by commas it 4 00:00:19,703 --> 00:00:23,619 automatically packs all those values into a single tuple. 5 00:00:23,619 --> 00:00:27,050 This is just a convenience that makes the code look a little nicer. 6 00:00:27,050 --> 00:00:30,280 It looks like you are working with multiple values, 7 00:00:30,280 --> 00:00:33,580 when really is just making one tuple out of them. 8 00:00:33,580 --> 00:00:38,340 For example, in this code we have several pieces of the information about an actor 9 00:00:38,340 --> 00:00:41,400 Julie Roberts and a movie she was in Duplicity. 10 00:00:42,770 --> 00:00:47,060 We can explicit make those different pieces of information into a tuple 11 00:00:47,060 --> 00:00:50,520 using parenthesis like we do on line number 1. 12 00:00:50,520 --> 00:00:53,590 So, we have open parenthesis there, closed parenthesis, 13 00:00:53,590 --> 00:00:57,230 this is our usual way of creating a tuple. 14 00:00:57,230 --> 00:01:02,902 In between we have a bunch of values there's Julia, Roberts, 1967. 15 00:01:02,902 --> 00:01:07,369 All of these values are separated by commas to indicate where one expression 16 00:01:07,369 --> 00:01:08,920 ends and another begins. 17 00:01:10,890 --> 00:01:15,190 So that's the syntax that you've already seen for creating tuples. 18 00:01:15,190 --> 00:01:19,980 It turns out that line 3 does exactly the same thing. 19 00:01:19,980 --> 00:01:22,762 It's exactly the same except that we've left out the parentheses. 20 00:01:24,740 --> 00:01:29,111 No more parentheses here and it implicitly reads that as, 21 00:01:29,111 --> 00:01:32,910 we got a bunch of values, we gotta pack it into a tuple. 22 00:01:34,180 --> 00:01:40,485 On line 4 you can see as with any tuple, Julia is the name of the variable. 23 00:01:40,485 --> 00:01:46,817 We look up its value, its value is a tuple, square bracket 4 says, 24 00:01:46,817 --> 00:01:52,498 go and get the fifth item, so Julia is 1, 2, 3, 4, 5. 25 00:01:52,498 --> 00:01:55,871 So what it prints out here should be 2009. 26 00:02:00,030 --> 00:02:05,870 So lines 1 and line 3 are just synonyms for each other. 27 00:02:05,870 --> 00:02:10,200 Line 3 is just a way that maybe looks a little bit better as if 28 00:02:10,200 --> 00:02:11,200 you have multiple values. 29 00:02:12,930 --> 00:02:16,990 One place where this is especially useful is when a function wants to return 30 00:02:16,990 --> 00:02:17,650 multiple values. 31 00:02:19,190 --> 00:02:23,960 For example, in this code, circleInfo is a function 32 00:02:26,290 --> 00:02:30,130 and it wants to return two values. 33 00:02:30,130 --> 00:02:33,900 The circumference of the circle, and the area of the circle. 34 00:02:35,120 --> 00:02:39,050 You can only return one value from a Python function, but 35 00:02:39,050 --> 00:02:41,750 that value can be a tuple as we've done here. 36 00:02:44,160 --> 00:02:50,381 So that works fine, I can print the circle information of a circle with radius 10. 37 00:02:50,381 --> 00:02:55,427 And it has a circumference of 62.83, 38 00:02:55,427 --> 00:03:01,782 and an area of 314 But 39 00:03:01,782 --> 00:03:07,010 I also have the option, if I think it looks better to leave the parenthesis out. 40 00:03:07,010 --> 00:03:10,350 And it will automatically return a tuple, and 41 00:03:10,350 --> 00:03:14,380 I'll get exactly the same output, there you go. 42 00:03:15,840 --> 00:03:19,850 So that's tuple packing, we'll see you next time for unpacking.