All language subtitles for 29. args and kwargs

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,790 --> 00:00:04,570 Let's talk about something called arguments and keyword arguments. 2 00:00:04,570 --> 00:00:11,250 I mean we've already seen that before right with a function we actually have this special characters 3 00:00:11,250 --> 00:00:18,530 that we can use called ARGs and star star key word args. 4 00:00:18,580 --> 00:00:21,380 How can we use these. 5 00:00:21,390 --> 00:00:23,240 Well let's have a look. 6 00:00:23,400 --> 00:00:31,070 Let's try and have a function let's say define and we'll call this a super func for a super function 7 00:00:31,670 --> 00:00:38,140 that receives some sort of arguments and these arguments that we're going to receive. 8 00:00:38,150 --> 00:00:44,900 And remember although I'm calling these args this itself is a parameter remember. 9 00:00:44,900 --> 00:00:53,480 But let's say that we want to just return some of the arguments and you might be wondering where. 10 00:00:53,540 --> 00:00:59,080 Some don't we have to define that function well some actually exists in Python as you can see over here. 11 00:00:59,510 --> 00:01:02,770 So we can just return the sum of the arguments. 12 00:01:03,110 --> 00:01:04,610 So let's try this. 13 00:01:04,610 --> 00:01:08,890 Let's say super func and give it arguments. 14 00:01:08,880 --> 00:01:11,540 One two three four five. 15 00:01:11,560 --> 00:01:12,520 If I click Run 16 00:01:16,930 --> 00:01:17,780 I get an error. 17 00:01:18,100 --> 00:01:22,590 Super func takes 1 positional argument but 5 where. 18 00:01:22,590 --> 00:01:25,150 Give it and that makes sense right. 19 00:01:25,150 --> 00:01:32,990 Like I only have one parameter here which is a positional argument that it accepts and I'm trying to 20 00:01:32,990 --> 00:01:34,260 sum this. 21 00:01:34,310 --> 00:01:40,550 So it only receives one but I'm giving it to all these things that it doesn't know but and this is where 22 00:01:40,550 --> 00:01:51,500 we can use something like this by adding a star to here we're saying hey this can accept any number 23 00:01:51,680 --> 00:01:56,610 of positional arguments like this as many as I want. 24 00:01:56,810 --> 00:01:58,840 As a matter of fact let's print this out. 25 00:01:58,880 --> 00:02:12,700 If I do print star ARGs and we run this function we see that the print star args gives us 1 2 3 4 5. 26 00:02:12,790 --> 00:02:17,560 These are all the parameters or the arguments that we get. 27 00:02:17,560 --> 00:02:26,290 And if I actually remove the star here and click Run look at that I actually get this as a couple. 28 00:02:26,390 --> 00:02:33,260 So args inside of this function is a topple of arguments that I give it. 29 00:02:33,290 --> 00:02:34,770 One two three four five. 30 00:02:34,790 --> 00:02:36,730 So some of the topple. 31 00:02:36,740 --> 00:02:40,670 One two three four five is going to give us the right answer. 32 00:02:40,670 --> 00:02:42,890 It's going to print for us 33 00:02:46,380 --> 00:02:51,650 the answer 15 very very cool. 34 00:02:51,700 --> 00:03:00,490 So this way we can extend and use our star args to have enough a function that can accept any number 35 00:03:00,790 --> 00:03:03,390 of arguments. 36 00:03:03,400 --> 00:03:12,590 So what is this one now well this one allows us to use keyword arguments for example let's say I have 37 00:03:13,010 --> 00:03:17,990 the star star key word args like this. 38 00:03:17,990 --> 00:03:20,810 And by the way this can technically be anything. 39 00:03:20,810 --> 00:03:26,370 So this is a variable that we're creating so I can name it who if I wanted to. 40 00:03:26,450 --> 00:03:34,520 But the standard is to name it ARGs and keyword args because other developers are using it this way 41 00:03:34,530 --> 00:03:39,830 and it's just the way it's done in the Python community now with the keyword arcs as you might have 42 00:03:39,830 --> 00:03:40,600 guessed. 43 00:03:40,670 --> 00:03:55,440 I can add keywords like num 1 equals 5 and then num two equals 10 so that if I print the key word ARGs 44 00:03:55,620 --> 00:04:05,180 and I click Run I get a dictionary of num one equals 2 Five and num two equals to 10. 45 00:04:05,390 --> 00:04:19,700 So I can actually do something like some plus sum of items in the keyword ARGs and grab the values right. 46 00:04:19,740 --> 00:04:30,220 We've seen that before and let's actually grab this and do a for loop and say items in keyword arcs 47 00:04:30,850 --> 00:04:31,990 dot values. 48 00:04:31,990 --> 00:04:38,840 Remember to grab the values over here and in here just add up the totals. 49 00:04:38,900 --> 00:04:52,150 So let's say that in here total equals or plus equals items and will add a total in here. 50 00:04:52,200 --> 00:04:55,010 That is initially zero. 51 00:04:55,620 --> 00:05:12,120 So that sum will be some args plus total if I run this I get 30 which looks about right now. 52 00:05:12,170 --> 00:05:14,150 This does look a little confusing. 53 00:05:14,240 --> 00:05:15,960 So let's go over it. 54 00:05:16,040 --> 00:05:23,840 We have the star args which allow us to grab these positional arguments and just some everything. 55 00:05:23,840 --> 00:05:31,730 And we also have keyword arcs which allow us to grab any number of keyword arguments and get a dictionary 56 00:05:32,150 --> 00:05:38,060 which comes as keyword arcs and then use them however we want in our case we're looping over all the 57 00:05:38,060 --> 00:05:46,880 values so items in keyword arc values and then I'm just going to total all those items have a total 58 00:05:46,970 --> 00:05:50,390 and just return the sum. 59 00:05:50,440 --> 00:05:58,120 Now this is again extremely useful because our super fund can now take as many arguments as many positional 60 00:05:58,300 --> 00:06:02,310 and keyword arguments as we want now. 61 00:06:02,320 --> 00:06:03,700 One final thing. 62 00:06:03,700 --> 00:06:09,590 There is a rule of the ordering that we can do of our parameters here. 63 00:06:09,700 --> 00:06:10,940 Right. 64 00:06:10,960 --> 00:06:12,020 So the order. 65 00:06:12,050 --> 00:06:24,690 The rule is this first in our parameters we have well our actual programs then we can do star arcs then 66 00:06:25,290 --> 00:06:35,400 default parameters then star star keyword parks. 67 00:06:35,570 --> 00:06:36,890 Let me show you what I mean. 68 00:06:37,160 --> 00:06:43,280 If we want to define this function we want to make sure that if we give it a parameter of let's say 69 00:06:43,730 --> 00:06:54,340 name that should come before Star arcs and if we have default parameters that should usually come after 70 00:06:54,460 --> 00:06:54,810 arcs. 71 00:06:54,820 --> 00:06:56,320 But before keyword arcs. 72 00:06:56,320 --> 00:07:07,090 So if I do let's say i equals high and make sure we add a comma here we now have following the rule. 73 00:07:07,090 --> 00:07:12,310 And by the way you would never actually write a function like this because well frankly you look super 74 00:07:12,310 --> 00:07:12,960 confusing. 75 00:07:12,970 --> 00:07:18,850 Usually you're only using two of these or maybe just one of these. 76 00:07:19,060 --> 00:07:24,190 But this way I can call this function with name Andy. 77 00:07:24,640 --> 00:07:26,270 Then my args. 78 00:07:26,530 --> 00:07:34,150 Then my default parameter which will be I equals to high which lets say we don't even pass in and then 79 00:07:34,150 --> 00:07:41,990 we have this so if we run here this still works we are just not using name. 80 00:07:42,050 --> 00:07:50,460 And I bet you see that I'm following the rule of Paramus args default parameters and then keyword arcs. 81 00:07:50,690 --> 00:07:51,140 All right. 82 00:07:51,150 --> 00:07:53,440 Hopefully your head doesn't hurt too much after this one. 83 00:07:53,580 --> 00:07:55,810 Take a break and I'll see you in the next one. 84 00:07:55,830 --> 00:07:56,040 Bobby. 8284

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.