Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
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.