Hello and welcome to Pythonlearn.com.
We are on this particular video we're going to show you how to write a simple
program using a text editor and a terminal on the Raspberry Pi.
Raspberry Pi is a really cool system that runs Unix Linux and
so we have a desktop, once you got your Raspberry Pi working.
You should have a desktop. It has a Start icon at the bottom.
And we're going to start.
We actually don't have to install anything.
For the Macintosh and the Windows we had to install various things but
now everything comes on Linux because it's sort of set up for programmers.
I'll start a text, a simple text editor and
I'll write a little Python program in the text editor.
We call these scripts.
And the classic thing to do is to write a program
that says "hello world". And I am going to do a Save to this file,
and I am going to put it on my desktop and make a new folder called assignment 0.
And then, in assignment 0 I'm going to call my file hello.py and save it.
I got my screen a little small, so you can see a little better.
You'll notice on that desktop that folder showed up, and if I click inside
the folder, there is indeed hello.py.
So now what we're going to do is we're going to
there's a lot of ways you could run this.
There are things, there are tools called idle and
you may have even learned and used these before.
I prefer showing you really how stuff works.
The technique I'm going to show you works pretty much the same on a
Macintosh or Windows, where you actually talk to the operating system and say hey,
run my Python for me. So I'm going to open up a terminal window.
And a terminal window lets us type operating system commands.
And so for example, the first command is ls,
That lists the directories and files that of wherever you're at.
The pwd stands for print working directory.
It says where are you at.
And I'm in the /home/c7, that's my account.
And cd says change directory. And I'm going to change
into the desktop.
And just as, I can type d e tab, and
as long as that's unique it automatically goes to the desktop.
And then Enter.
If I type ls, well I see kind of what's kind of on that desktop.
That desktop has a folder called assn0. A-S-S-N-0.
And, then I go into that folder, assn0, so you navigate one
folder in, and you'll see it's telling you roughly where you're at.
And if I do an ls here in this command line,
it says, oh, you've got one file, and it's named hello.py.
And if you look at this, it's showing you the exact same information.
So we're really, this, this terminal's a different view.
And I like it because we can type commands here, and
be smaller, there we go. You type commands.
I can tell you exactly what to type.
It's easier to write documentation frankly.
So, we want to run this program.
We wrote the program over here and now we want to run the program in this window.
So we type python hello.py.
And that says, go find Python.
That's like Microsoft Word or some other
program that happens to be the Python itself
that we're running. And feed it hello.py, this one file.
So, when I type Enter, it's going to run it.
And so it's going to interpret these commands.
And I told Python that the first thing and last thing
I wanted to do was to do a print of hello world.
That, of course, is they're traditional. This is a script.
It is a series of commands. Print howdy world.
Print yo world. I can have all kinds of things in here.
Print peace out. I don't know what to type.
Now there are some short cuts that you will get used to using pretty fast.
I can keep saying File Save, but you'll notice Ctrl+S is a save.
And you'll notice this little asterisk up here.
Watch when I press Ctrl+S, that asterisk means the file's been
modified, but not saved.
This will save you a little bit of insanity.
Make sure you know that.
It's like oh it's not saved, so Ctrl+S, pressed, and now it's been saved.
That's how I know it's saved and it's been saved over here.
And now I'm going to say, python hello.py, to
run it again. And, oh now it's yelling at me.
Oops, I see what I did wrong.
I should've said print, I should've said instead of pring I should've said print.
You'd think it would be smart enough to know that like why
isn't this guy doing print. So I now have to save it again,
so I do Ctrl+S. And now here is now is another trick.
You can hit the up arrow and run the previous command again.
So I hit the up arrow, and hit Enter, and there is my output.
Okay? So not too hard.
Everything's already pre-installed on the Raspberry Pi Linux.
Pretty much all Linux are going to have something like this.
And so away we go. Thanks for listening.