Hello and welcome to the part two of interacting with python in this part.
We are going to be interacting with Python through a python file a python file is basically a file that
is saved with an extension and then in dot P Y.
So any text that is inside that saved file is interpreted as a python code.
You can create a python file by using a text editor or you can use the python Idol which is an integrated
development environment which is also known as an I D E.
I have opened up my Python Idol when you open up the idol e opens up in python shell.
So Python Idol consists of the python shell and also the text editor.
So to access the text editor you click on file and then you click on new file and you basically just
give the file a name so I'm going to save this file with a dot P Y file extension.
So I'm just going to do a file save as and you give the file name and then you can see here's his python
file.
I'll just call this up the P were very important.
You add the top P Y and then you can save it in any location for simplicity.
I'm going to save mine on my desktop.
So now that I've got a pipe on file you can see he has got up the P Y.
I can just write on line of code just to test it.
So I'll say print in parentheses just came to the quote Just say hello world.
Now close the quote and I'll close the parentheses.
I do a file and I can just save.
So now this is my python file so I can run it from the Python Idol which is the IDC by going and run
an on to run module fired click on run module it will run the file inside the shell so I click on that.
You can see here is giving me the output of the file which is hello world which is what I have in the
line of code I've written inside the up to P1.
So this is one way of interacting with Python through a python file.
So this is the actual file here that I've saved on my desktop.
This file you're looking at here.
This is here on my desktop so to exit the editor you just click on the X that will exit and if you want
to exit the shell as well.
Just click on the X and you can exit another way we can create a python file is by using a text editor
and a text editor I'm going to illustrate with is code after.
So I have got my hat on.
Text editor open so I'm going to just create a simple python file.
So I'm just going to save this file onto my desktop as a python file with a dot P Y extension.
So this is a file I've created on my desktop.
You can see it here.
It's called my app.
OK so let me go back to the editor because I've created it on my desktop.
It also has a folder so he can remove it.
I'm just going to click right click and say remove project folder and it give me more space so let me
just do a simple print statement to print and I will enclose that in parentheses which is say and I'll
save that undo file save.
You can see now this is known as a python file.
So in order to I can run this file from my terminal.
So if I open up my terminal I've got my command prompt here.
So all I need to do I want to run this file.
I'm just going to minimise the text editor.
I can just drag this as a file here I just drag that into my command prompt.
See and it just tells me the location I press enter.
It will execute you can see is executed the line of code I wrote.
So this how you can interact with python from a python file.
So if you create in a program or an application you'll be writing multiple lines of code sometimes hundreds
or even thousands lines of code.
And you can interact with Python that way.
So that's it for this video on interactive the python via a python file.
Thanks for watching and bye for now.