Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,650 --> 00:00:03,390
Hi, and welcome back.
2
00:00:03,420 --> 00:00:09,780
In this video, I'll show you how to run or execute Python code using the interpreter.
3
00:00:09,870 --> 00:00:11,320
There are several ways.
4
00:00:11,340 --> 00:00:13,560
And we'll take a look at each of them.
5
00:00:13,860 --> 00:00:19,510
If you want to test some basic concepts or execute just a few Python instructions.
6
00:00:19,530 --> 00:00:23,880
You can write an execute them directly in the python interpreter.
7
00:00:24,180 --> 00:00:26,550
Here you have two options.
8
00:00:27,260 --> 00:00:35,840
The first option is to open the interpreter from the Windows Command line or cmd dot TCS and write all
9
00:00:35,840 --> 00:00:38,000
the Python instructions there.
10
00:00:39,160 --> 00:00:45,920
Even if this works perfectly, it isn't the recommended way, or at least not for beginners.
11
00:00:45,940 --> 00:00:54,490
That's because it lacks the advanced features like auto completion or a color highlighting of key words
12
00:00:54,490 --> 00:00:55,600
or errors.
13
00:00:55,720 --> 00:00:58,780
It will be harder for you to write your code here.
14
00:00:59,200 --> 00:01:01,540
However, this is how it's done.
15
00:01:01,990 --> 00:01:07,090
Go to start type CMD and hit enter.
16
00:01:08,150 --> 00:01:13,370
Now I'll write the python and press the enter key.
17
00:01:14,940 --> 00:01:18,010
The python interpreter has just started.
18
00:01:18,030 --> 00:01:21,420
Here we can execute Python instructions.
19
00:01:33,920 --> 00:01:41,270
The second option to execute Python code using the python interpreter is to use idle, which stands
20
00:01:41,270 --> 00:01:45,050
for Integrated Development and Learning Environment.
21
00:01:46,290 --> 00:01:52,740
On Windows Idol comes by default with the Python installation, so it's already there.
22
00:01:53,860 --> 00:02:01,690
To open idol just type idol in the Windows Linux or Mac Start menu.
23
00:02:04,110 --> 00:02:05,880
And you'll see something like this.
24
00:02:06,910 --> 00:02:13,300
This is a python shell or interpreter where you can write and execute short scripts and see their output
25
00:02:13,330 --> 00:02:15,160
immediately in real time.
26
00:02:16,000 --> 00:02:19,660
Each line starts with a three greater than size.
27
00:02:19,750 --> 00:02:22,420
This is the ideal command prompt.
28
00:02:23,110 --> 00:02:29,530
Throughout this course, when we say three greater than size will know that the code has been executed
29
00:02:29,530 --> 00:02:30,790
in Python idle.
30
00:02:31,760 --> 00:02:33,620
Let's write something very simple.
31
00:02:34,430 --> 00:02:41,150
Print and the Hello Python in parentheses and double quotes.
32
00:02:46,880 --> 00:02:48,650
Now let's do something else.
33
00:02:48,680 --> 00:02:53,060
X equals six x times two.
34
00:02:54,840 --> 00:02:56,010
What have I done?
35
00:02:56,040 --> 00:03:04,440
I've just declared a variable called X that is equal to six and then printed out x times two.
36
00:03:06,640 --> 00:03:07,810
In Python idle.
37
00:03:07,810 --> 00:03:12,490
It's not necessary to use the print function to see the value of a variable.
38
00:03:12,520 --> 00:03:15,520
You can just type its name and hit enter.
39
00:03:17,000 --> 00:03:22,170
We won't focus right now on variables or other Python programming concepts.
40
00:03:22,190 --> 00:03:25,520
We'll have a lot of time for that in the next lecture.
41
00:03:25,910 --> 00:03:31,580
For the moment, I just want to show you how to execute Python statements in idle.
42
00:03:32,620 --> 00:03:39,880
If you want to execute a statement again, you simply go with the arrow keys to that line and press
43
00:03:39,880 --> 00:03:40,810
the enter key.
44
00:03:43,080 --> 00:03:47,760
And we can see how that statement has been copied on the last line.
45
00:03:47,940 --> 00:03:52,080
I can modify it and run it again if I want.
46
00:03:56,010 --> 00:04:00,940
Another useful feature is the autocomplete or word completion.
47
00:04:00,970 --> 00:04:06,220
The application will predict the rest of the world a user is typing.
48
00:04:06,400 --> 00:04:14,260
This time I'll declare another variable that stores a string, which is a sequence of characters name
49
00:04:14,260 --> 00:04:16,870
equals and between double quotes.
50
00:04:16,870 --> 00:04:17,560
Andre.
51
00:04:19,120 --> 00:04:22,029
And then I'll write the name and the date.
52
00:04:22,029 --> 00:04:23,070
And I'll wait.
53
00:04:23,510 --> 00:04:31,870
Idle will open up a pop up window with all the methods and attributes available to the string objects.
54
00:04:33,430 --> 00:04:35,480
Let me say it again for the moment.
55
00:04:35,500 --> 00:04:39,400
Don't focus on the language, but only on Python idle.
56
00:04:40,800 --> 00:04:50,370
You can change the completion, pop up, wait time by going to options, configure idle and the windows.
57
00:04:52,790 --> 00:04:57,650
Shares the completion of pop up wait time, which is given in milliseconds.
58
00:05:04,780 --> 00:05:10,210
Other options like the font size can be changed in this window to.
59
00:05:12,210 --> 00:05:20,130
Also keep in mind that you can run many simultaneous sessions of Idol as you want without one interfering
60
00:05:20,130 --> 00:05:21,390
with the other.
61
00:05:21,570 --> 00:05:24,570
I'm opening another idle session.
62
00:05:28,780 --> 00:05:32,530
They are completely separated working environments.
63
00:05:32,560 --> 00:05:41,560
In our course we use idle only for small tasks and examples for complex scripts Picture, which is probably
64
00:05:41,560 --> 00:05:46,180
the most used professional python ID will be our choice.
65
00:05:46,420 --> 00:05:50,770
I'll show you how to run your scripts in picture in the next video.
66
00:05:50,800 --> 00:05:51,910
I'll see you soon.
6177
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.