- [Instructor] Up to this point on our Python discussion,
if we wanted to assign a value to a variable,
we've been doing that ourselves.
We've been saying, for example, X equals 12
or first name equals Kevin in quotes for a string.
But sometimes we're running a program
and we might want to query the user
to ask them for some input.
For example, we might ask a user to enter a VLAN number
or a DSCP Quality of Service value.
And in this short video we're going to take a look
at how to do that.
We're going to use the input function to get that user input,
and we could do that from the interactive interpreter
or we could do that within a program.
Here I'm just going to use the interactive interpreter,
and I'm going to say firstName=
and we're going to use the input function.
I'm going to say input and then in parentheses
I'll put in the string that's going to query the user.
I'll say What is your first name?
Close quote, close parentheses.
And when I press enter, it's prompting me
to enter my first name.
And I'll say Kevin, and we'll press Enter.
Now that our variable of firstName has a value,
let's print out a string that says, Hi Kevin!
And we can use the print function to do that.
I'll say print, open parentheses,
and I'll say Hi and a space, close quote.
Now let's concatenate on the value
of the variable firstName.
I'll say + and then the variable of firstName,
and then I'll say + again,
and we'll concatenate on an exclamation point.
I will say, in quotes, exclamation point.
Close quote, close parentheses, press Enter,
and it says, Hi Kevin!
So what we've done in this short video
was to take a look at the input function
that can be used to ask the user to enter something,
like a string or a number.
Now by the way, this is one of the differences
between Python 2 and Python 3.
We're running 3.8 right now.
If I wanted to get a string input from a user
in Python 2, the input command would not work.
I would have to use the raw,
R-A-W, underscore input function,
but here in Python 3, we can just use the input function.