All language subtitles for 012 [Interactive Coding Exercise] Variables.en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
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
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

Original subtitles

1

All right guys, it's time for your final coding exercise.

2

So click on day 1.4 variables.

3

Now the aim of the game is to switch the values of these two variables around.

4

So if we go ahead and run our code as it is,

5

it's going to ask us for a value of a. Let's call it five.

6

And then it's going to ask us a value for b. Let's call that a hundred.

7

And then when I hit enter,

8

what you want the code to do is to go ahead and print a equals 100 and b equals

9

five.

10

So, basically switch those values around. And you're going to have to write your

11

code in here. And it's really,

12

really important that you don't change any of the code here or the code here.

13

Now it's easy enough to simply just write print a equals b and b equals a.

14

But this doesn't test you on anything. This is not the solution.

15

This is wrong. Don't change the code here, don't change the code here.

16

Instead, all

17

you have are these lines where you can write as much code or as little code as

18

you need to achieve this end. And when you achieve it,

19

it should look something like this.

20

You type a value for a, you type a value for b. And when you hit enter,

21

they get printed out,

22

but switched around. Have a think about how variables work,

23

how they store data. And if you get really stuck,

24

imagine that you have two cups; one holds a cup of milk, one

25

holds a cup of coffee,

26

and you wanna switch the contents of the cup around. How would you do that in

27

real life? And then try and see if you can apply that logic to the code.

28

Pause the video now and give this a go.

29

All right. So I hope you didn't cheat

30

and instead you actually had a think about this problem. If you got stuck,

31

remember how I said

32

if you have a cup of coffee and you have a cup of milk and you wanna switch the

33

contents of the cups around, how would you do this in real life? Well,

34

you would probably get a third cup, right?

35

And then you'd be able to shift the contents around.

36

So that's exactly what we're going to do with our code as well.

37

We can create a new variable called c and we can set that to equal the value that's

38

stored inside a. And then later on,

39

we can get the variable a to store the value that's currently inside b.

40

And finally,

41

we're now ready to get b to store the value that was previously inside a,

42

which is now contained inside the variable c. These three lines achieve this

43

little switch rule that we've got here.

44

And this is one of the most common Programming interview questions that you will

45

come across. And the code is super simple,

46

but what you have to apply here is some logic.

47

And I usually think about real life examples

48

like the cups and I hope that helped you as well.

49

If this was at all confusing,

50

then have a go at trying this out in Thonny.

51

But if you got it right, then congratulations.

52

This was actually quite a hard challenge.

53

You had to think about a lot of things and think outside the box as well.

54

So give yourself a pat on the back if you've got it right.

55

If you didn't get it right,

56

then I really recommend to put this code inside Thonny and see how it's being

57

moved around so that you really,

58

really understand what's going on behind the scenes.

59

And then you can move on to the next lesson where we're going to talk about some

60

of the rules around naming variables. For all of that

61

and more, I'll see you there.

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