1
00:00:00,600 --> 00:00:07,740
Hello and welcome to the part two of interacting with python in this part.

2
00:00:07,740 --> 00:00:18,060
We are going to be interacting with Python through a python file a python file is basically a file that

3
00:00:18,060 --> 00:00:23,130
is saved with an extension and then in dot P Y.

4
00:00:23,850 --> 00:00:34,020
So any text that is inside that saved file is interpreted as a python code.

5
00:00:34,170 --> 00:00:46,590
You can create a python file by using a text editor or you can use the python Idol which is an integrated

6
00:00:46,890 --> 00:00:51,960
development environment which is also known as an I D E.

7
00:00:51,960 --> 00:01:01,450
I have opened up my Python Idol when you open up the idol e opens up in python shell.

8
00:01:01,650 --> 00:01:08,550
So Python Idol consists of the python shell and also the text editor.

9
00:01:08,580 --> 00:01:17,490
So to access the text editor you click on file and then you click on new file and you basically just

10
00:01:17,490 --> 00:01:24,830
give the file a name so I'm going to save this file with a dot P Y file extension.

11
00:01:24,900 --> 00:01:31,290
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

12
00:01:31,290 --> 00:01:32,270
file.

13
00:01:32,340 --> 00:01:38,480
I'll just call this up the P were very important.

14
00:01:38,480 --> 00:01:44,420
You add the top P Y and then you can save it in any location for simplicity.

15
00:01:44,420 --> 00:01:48,060
I'm going to save mine on my desktop.

16
00:01:48,290 --> 00:01:54,090
So now that I've got a pipe on file you can see he has got up the P Y.

17
00:01:54,350 --> 00:01:57,730
I can just write on line of code just to test it.

18
00:01:57,830 --> 00:02:10,070
So I'll say print in parentheses just came to the quote Just say hello world.

19
00:02:10,140 --> 00:02:15,750
Now close the quote and I'll close the parentheses.

20
00:02:15,750 --> 00:02:18,820
I do a file and I can just save.

21
00:02:19,190 --> 00:02:30,230
So now this is my python file so I can run it from the Python Idol which is the IDC by going and run

22
00:02:30,940 --> 00:02:40,010
an on to run module fired click on run module it will run the file inside the shell so I click on that.

23
00:02:40,010 --> 00:02:47,510
You can see here is giving me the output of the file which is hello world which is what I have in the

24
00:02:47,510 --> 00:02:52,470
line of code I've written inside the up to P1.

25
00:02:52,820 --> 00:03:00,220
So this is one way of interacting with Python through a python file.

26
00:03:00,440 --> 00:03:05,030
So this is the actual file here that I've saved on my desktop.

27
00:03:05,090 --> 00:03:06,530
This file you're looking at here.

28
00:03:06,530 --> 00:03:14,750
This is here on my desktop so to exit the editor you just click on the X that will exit and if you want

29
00:03:14,750 --> 00:03:16,850
to exit the shell as well.

30
00:03:16,880 --> 00:03:26,510
Just click on the X and you can exit another way we can create a python file is by using a text editor

31
00:03:26,960 --> 00:03:30,480
and a text editor I'm going to illustrate with is code after.

32
00:03:31,220 --> 00:03:33,380
So I have got my hat on.

33
00:03:33,380 --> 00:03:40,910
Text editor open so I'm going to just create a simple python file.

34
00:03:40,910 --> 00:03:51,230
So I'm just going to save this file onto my desktop as a python file with a dot P Y extension.

35
00:03:51,380 --> 00:03:55,640
So this is a file I've created on my desktop.

36
00:03:55,640 --> 00:03:56,760
You can see it here.

37
00:03:57,740 --> 00:04:00,430
It's called my app.

38
00:04:00,740 --> 00:04:08,030
OK so let me go back to the editor because I've created it on my desktop.

39
00:04:08,030 --> 00:04:12,120
It also has a folder so he can remove it.

40
00:04:12,140 --> 00:04:18,650
I'm just going to click right click and say remove project folder and it give me more space so let me

41
00:04:19,040 --> 00:04:29,760
just do a simple print statement to print and I will enclose that in parentheses which is say and I'll

42
00:04:29,760 --> 00:04:34,190
save that undo file save.

43
00:04:34,270 --> 00:04:38,220
You can see now this is known as a python file.

44
00:04:38,320 --> 00:04:43,580
So in order to I can run this file from my terminal.

45
00:04:43,600 --> 00:04:48,010
So if I open up my terminal I've got my command prompt here.

46
00:04:48,580 --> 00:04:51,500
So all I need to do I want to run this file.

47
00:04:51,520 --> 00:04:54,540
I'm just going to minimise the text editor.

48
00:04:54,910 --> 00:05:03,340
I can just drag this as a file here I just drag that into my command prompt.

49
00:05:03,350 --> 00:05:07,230
See and it just tells me the location I press enter.

50
00:05:07,510 --> 00:05:12,940
It will execute you can see is executed the line of code I wrote.

51
00:05:12,940 --> 00:05:19,350
So this how you can interact with python from a python file.

52
00:05:19,360 --> 00:05:27,250
So if you create in a program or an application you'll be writing multiple lines of code sometimes hundreds

53
00:05:27,250 --> 00:05:29,590
or even thousands lines of code.

54
00:05:29,860 --> 00:05:33,880
And you can interact with Python that way.

55
00:05:33,880 --> 00:05:41,290
So that's it for this video on interactive the python via a python file.

56
00:05:41,290 --> 00:05:43,300
Thanks for watching and bye for now.
