Instructor: Hey, you're still sticking around.
That's good, I didn't bore you
with all my talking, but yes, in this video
finally we're going to write some Python code.
Holy moly.
Thank God I thought that was gonna last forever.
All right, so what is our first program going to do?
Well, let's create a very, very simple function.
And probably the first thing
any programmer learns to do, to print our own name.
So in here, once you have your repl.it set up
or remember you can also use glot.io.
We're simply going to write print.
And then you see over here
that it gives us some information,
but all we wanna do is write brackets, a quote.
So you can do double quotes here
or a single quote and just type your name.
And if we click run on the right side,
we've just ran our very first Python program.
Very exciting.
But what's happening here?
Well, let's look at everything.
First of all, if you're confused why my thing is darkened,
yours might be light.
It's because if I go to settings,
I've set my theme to light or to dark.
I prefer the dark version.
But you can change some of your settings.
You can change the font size if you want,
based on when you watch the video.
This website, the look might be different
but most of the settings should be the same.
We see that we have a main.py,
which is the Python extension.
Any file that has a .py or py is a Python file.
So what we've just written here
on line one is a program that prints
in this case Andrei Neagoie or in your case, your own name.
And we've written it to this file.
Now, repl.it takes this file
already has this interpreter for us.
It runs this piece of code, gives this source code
of main.py to the interpreter and runs it right here
on our right side.
If you look over here, we're using Python version 3.6 0.1
and down below we see that,
Oh, we have Andrei Neagoie print it.
That's awesome.
So this is our code running.
Remember this diagram?
All we've done is we have our main.py
where we wrote print Andrei Neagoie.
We gave it to the interpreter that the repl
already provides for us.
That interpreter takes our code, converts it
into bite code, and here it'll say Andrei Neagoie.
And then it runs it in the CPython VM,
which was on the right side that we saw.
And it finally prints our name
because it tells the machine,
"hey we want that text printed".
So that's what we're seeing here.
This is the CPython virtual machine essentially
running this code and telling this machine,
"hey I want you to print this".
All right, but this isn't very exciting.
I mean, let's make this program a little bit more dynamic.
For our first program,
we wanna do something more impressive than just print name.
So I'm going to teach you another thing we can do in Python
and it's called input.
Now, in here I can say input.
And you see that repl actually gives me
some information saying that, "Oh, I have this".
You can just click here, and this input over here.
Well, what can we do?
This input is going to prompt a user.
And if I hover over it, you can see how it's giving me
some information.
But input simply gives us a way to capture information.
So let's say, what is your name?
And if I run this code,
we see that we have our Python code running,
and it's asking me what is my name
with this cursor here.
So I can actually type something here.
I can say Andrei, and if I hit enter, well, there you go.
I've just typed in my own name.
Nothing that exciting, right?
But this is where code becomes interesting
because we can store this information on our computer.
So again, these are things that we're gonna go over
in detail in our basics Python section,
but just to write our first code.
Let's assign this to memory.
That is, let's say that name equals whatever is the input
of what is your name.
And then finally, we can just print the name.
So remember the interpreter
is going to take this first line.
It's going to ask, What is your name?
I'm going to type something, that typed information
is going to get assigned to name.
And then finally, we print name.
Remember, an interpreter takes line by line,
converts code to bite code, and then finally runs it.
So let's give this a try.
I'm going to click run.
All right, what's your name?
My name is Andrei.
Did you see that?
I typed in my name hit enter,
and then it printed out Andrei.
So for the final feed, let's greet.
So we're going to say print hello, and then plus name.
Now, don't worry about this syntax, we're gonna go over it,
but all we're doing is saying hello
and then adding our name to the end of this.
So let's see what happens
if I run this and say, What is your name?
My name is Andrei and I hit enter.
I get, "hello Andrei", but no spaces.
So let's add a little space.
Hit run again for the fourth time.
My name's Andrei and it says, "hello, Andrei".
There it is.
Our first Python program.
Now, it's not very exciting because it is our first program.
We're just learning the steps here.
But I hope because we've covered some of these topics
ahead of time,
that this isn't just pure magic, right?
You understand that this is source code.
This is main.py that we give
to an interpreter that runs our code line by line
and then executes our program.
In this case, our what is your name program?
How cool is that?
This is just the beginning.
We're gonna get more and more advanced here.
See if you can play around with this.
We don't know that much about Python yet
but I hope this gets you excited because well,
there's a lot more coding coming along.
I'll see you in the next one.
Bye-bye.