All language subtitles for 006 Getting Input From The User_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
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 Download
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

Now what we've done so far is pretty good.

We can use variables now to change the MAC address to any MAC address we want easily and to any interface.

But every time the user wants to change these variables, they have to open the code, they have to

open the program and modify its code manually, which is not very good.

It will be nicer if we can get the user to input the variables that they want through the terminal.

So there are a number of ways to do that.

And in this lecture we're going to talk about the input function.

So all we have to do is just use the input function like.

So I put a string that will be displayed to the user.

So for example, ask for your age and then initialize that to be stored in a variable called anything

we want.

And in this example we're calling it age.

Then the user is going to see this What's your age?

If they input, for example, ten, then ten will be stored in this variable and then we can print it

again.

This is very boring.

So what we're going to do is we're going to use something within our cool code and ask the user to enter

the interface and the new Mac and then use it in here.

So we already have a variable called interface and all we have to do instead of initializing it like

this, we want the user to put this value for us.

So instead of initializing it and saying it had zero here, we're going to say the interface is going

to equal to the input that the user will give me.

And inside this we're going to put the text that the user will see.

So we're going to ask for the interface.

Same goes for the Mac.

So instead of initializing the Mac within the code like this, we're going to say new Mac is going to

equal to and I want that to be taken from the user input.

So we're using the input function and I want the user to see a message asking for the new Mac.

So in that message I'm going to say New Mac.

And that's it.

We're going to start this and let's run it and see what it's going to look like.

So Python might change your dot pie.

And as you can see, the program will not execute further code.

It will stop and it will first ask me for the interface.

So whenever I put Land Zero in here, this will automatically initialize interface to land zero because

we said interface equals input and I'm given the input in here.

So the user is given the input themselves through the terminal.

Now if I enter.

Now we got an error because this is actually a Python three function.

So we have to say Python three in here because if you just type Python, it will run with Python 2.7.

So we run this again.

It's asking me for the interface.

We set that to land zero.

Now the code will stop again and it asks me for the new Mac.

So we're going to set that to 0011, two, two, three, three, four, four.

And I'm going to go for four four again to just use something different to make sure that this code

is going to work.

And now it's already the code has already initialized interface with land zero.

Once I hit Enter, it's going to initialize new Mac with the value that I just inputted, which is the

new Mac.

Then it's going to use it in here and in here exactly the same way as before.

So let's set enter and see what happens.

It's printing the right print statement for also telling us that it's changing MAC address for line

zero to this MAC address.

So again, the print statement, it's a really good way of knowing that interface and New Mac actually

hold the values that we want.

So they hold the values that the user did actually input because when your code gets more complicated,

you can make mistakes and maybe the variables will not hold the value that you expect them to hold.

So let's do if config line zero.

And see if the Mac changed.

And as you can see, it actually did get changed to the Mac address that we want.

Now, going back to this error.

We got this because we were running the code using Python 2.7, not Python three.

And like I said, these two versions are very, very similar.

So if you want this code to run with Python 2.7, all you have to do is just type pro input instead

of input.

So it's just the function has a different name.

So we change that to raw input and we change that to row input.

Going down.

And we're just going to run it this time with Python, not Python three.

Hit enter.

Ask me for the interface.

Let's set it to zero this time and set the new mark to 0011223344, two, two.

Hit enter.

We get the right values in the print statement, the right interface and the right mac address.

And if we do, if config at zero.

You can see the Mac address changed to four, four, two, two.

The same Mac address that we said in here.

So this just goes to show you that Python 2.7 and three are very similar.

Once you know one of them, you can use the other.

So that's it for this lecture.

I just wanted to introduce the input or the raw input function that allows the user to initialize variables

or interact with the program through the terminal.

So when they actually run the program, instead of having to manually modify the code every time they

need to change a variable.

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