All language subtitles for 011 Python 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

Now in this lesson, I want to talk to you about Python variables and it's a

2

really, really useful concept. But before we get started,

3

first I want you to head over to the course resources and get hold of the Day

4

1 variables start Repl.it sandbox or you can simply type the URL into the

5

browser.

6

I want you to first go ahead and fork this starting code so that you can work on

7

your own version of it. Now once you've done that,

8

then the first thing I want to do is to take a look at this line of code that

9

you should have already. And when we run this,

10

we should be pretty familiar with what happens, right?

11

It will ask us for our name and when we hit enter, nothing happens.

12

But behind the scenes,

13

this name or this input has now been received by this function.

14

But once that's done, it kind of just disappears, right?

15

And there's no way for us to be able to refer to it in the future. Or is there?

16

Well, this is where variables come in really handy.

17

If I give the results of this action a name,

18

well then I'll be able to refer to it later on.

19

So at the beginning of the line,

20

I'm going to call it name and then I'm going to add an equal sign

21

and what this does is it assigns whatever it is that the user typed in as the

22

input to this prompt to a variable called name.

23

So now if I go ahead and run my code again and I enter a name,

24

now once I hit enter,

25

normally there's no way for me to get hold of this anymore, right?

26

But now I can actually go ahead and write print.

27

I'm going to print the value of this variable name.

28

So now if I run my code and I write a name,

29

hit enter,

30

you'll see that this gets printed and I can use this at any point in my code

31

just by referring to the name that's attached to this value.

32

So it's almost like we've saved the data from this action to a name.

33

And if you think about it, if you had a phone book, let's say,

34

and you just jotted down the numbers of people,

35

the next time you look at this,

36

there's no way for you to know who's number that is, right?

37

In a sense it's the same thing with the computer.

38

Even though we've inputted this piece of data,

39

there's no way for us to be able to refer to this data unless we give it a name.

40

So in our phone book, we might say that this particular number is associated with

41

the name James. And in programming we would call this name James a variable.

42

So we could write something like James equals and then his phone number.

43

And this means that in the future, if we ever need this piece of data,

44

we can just refer to it by its name,

45

the variable name of James. Now,

46

as the name variable suggests,

47

it's something that can be changed or can be varied.

48

So for example,

49

just because this name is set to something up here doesn't mean that I can't

50

change it later on. So to make things simple,

51

let's go ahead and delete the input function and let's just say name is equal to

52

Jack. Print name.

53

When I run that Jack is what gets printed inside the console because I'm now

54

referring to that piece of data by the variable name.

55

But if later on I decide to give this variable a different piece of data to hold

56

on to,

57

let's say Angela and I print name at this time point after I've changed it,

58

what do you think these two lines will print?

59

What do you think will first be printed?

60

What do you think will be printed second? Let's hit command + enter or control +

61

enter and see for ourselves.

62

So even though they're both printing the same variable, at this point when we first

63

call print, it's holding on to the value of Jack,.

64

But by line 5 I've now changed it so that it's holding onto the value of

65

Angela.

66

This makes it a lot easier when we want to write code like what we did before.

67

For example,

68

this is the line of code that we had before and we knew that we were going to

69

get a piece of data from this input function and then we would calculate a new

70

piece of data using the Len function

71

and finally we're going to print everything out.

72

Instead of having such a long line of code, which can be quite confusing,

73

we can, if we wanted to, use variables to store each of these steps.

74

So for example,

75

we could say that the name was equal to whatever the user inserted as the

76

input

77

and then when we wanted to calculate the length,

78

then we could set that variable to equal the Len function.

79

And then inside the parentheses, we'll pass in the name, the value, that's stored

80

in the name variable right here. And finally,

81

all that we need to do is to print the length,

82

like so. So in this case,

83

this data is stored under this name and then that data is what's going to be

84

used in order to carry out this function

85

and then the result will get stored in yet another variable

86

and finally that variable will be printed out.

87

So let's go ahead and run this code and type in my name.

88

So Angela and hit enter and it does exactly the same thing,

89

but now we've got all of these pieces of data all associated with a name that we

90

can refer to at any later point in our code. Now it's time,

91

you guessed it, for a code challenge.

92

And I'm going to get you to apply what you've learned.

93

So for all of that and more, I'll see you on the next lesson.

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