Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,120 --> 00:00:03,050
Welcome to your first video on Python.
2
00:00:03,060 --> 00:00:08,940
So in this python series we're going to cover a lot of different topics and we're just going to build
3
00:00:08,940 --> 00:00:14,010
upon them slowly so that everything builds kind of upon the last less it.
4
00:00:14,010 --> 00:00:19,770
So in this first lesson we're gonna be talking about strings and we're going to be working primarily
5
00:00:19,770 --> 00:00:21,090
in Python 3.
6
00:00:21,110 --> 00:00:26,890
So quick thing to note is that my Cally interface might look a little bit different.
7
00:00:26,940 --> 00:00:29,390
I'm on my personal pen test machine here.
8
00:00:29,400 --> 00:00:34,590
The only reason I'm doing that is because when we get into the text editor my text editor on the newer
9
00:00:34,590 --> 00:00:39,090
version of Kelly would not let me edit my preferences very easily so I went ahead and just went back
10
00:00:39,090 --> 00:00:44,640
to my machine that has an older text editor on it so you can follow along completely step by step in
11
00:00:44,640 --> 00:00:46,800
your your Cally and you should be fine.
12
00:00:46,800 --> 00:00:50,490
I just wanted to make sure that the font size is good enough for the recording.
13
00:00:50,490 --> 00:00:56,760
So from here let's go ahead and make a new directory and I'm just gonna call this directory python and
14
00:00:56,760 --> 00:01:02,520
then we're going to change directory into Python and the first thing we're gonna do is we're going to
15
00:01:02,610 --> 00:01:08,460
get it and I'm just going to call this first dot PI.
16
00:01:08,460 --> 00:01:13,200
This will be our first python script and we're gonna build on it.
17
00:01:13,230 --> 00:01:19,430
So the first thing we need to do is declare what it's called a shebang.
18
00:01:19,500 --> 00:01:27,290
So that is a hash bang like this and we're just going to declare bean Python 3 here at the top.
19
00:01:27,300 --> 00:01:28,410
Now what is this do.
20
00:01:28,440 --> 00:01:37,470
This allows us to know or the Linux to know when we run this say we were to run this like Python 3 and
21
00:01:37,470 --> 00:01:43,650
then we just say first stop pi if we run it like this then Python interprets the hash here which you're
22
00:01:43,650 --> 00:01:45,570
going to learn a little bit as a comment.
23
00:01:45,600 --> 00:01:50,370
So all this is commented out we don't worry about it but let's say we wanted to run this a different
24
00:01:50,370 --> 00:01:50,550
way.
25
00:01:50,550 --> 00:01:58,520
We want to say dot forward slash first stop pi then it would actually be interpreted here at the top.
26
00:01:58,520 --> 00:02:00,860
So let's go in here and read this.
27
00:02:00,860 --> 00:02:06,530
It would say hey this I'm going to go ahead and look for bean Python 3.
28
00:02:06,560 --> 00:02:11,780
It's going to find Python 3 in bean because that's where it's stored and then it's going to use that
29
00:02:11,780 --> 00:02:15,620
to execute Python or this python script here.
30
00:02:15,650 --> 00:02:17,270
So we have two ways of running it.
31
00:02:17,270 --> 00:02:21,920
We can either run it Python 3 first at Pi or we can run it as you've seen it with some of our other
32
00:02:21,920 --> 00:02:24,890
scripts with the dot slash like this.
33
00:02:24,920 --> 00:02:29,750
So I always like to declare at the top it's not necessary if you're just going to type in Python 3 but
34
00:02:29,810 --> 00:02:31,110
I always like to do it.
35
00:02:31,340 --> 00:02:38,390
So I'm going to give you some headers here so I'm just going to put a comment in and it's going to say
36
00:02:39,470 --> 00:02:40,350
print strain.
37
00:02:40,660 --> 00:02:44,520
And so the first thing we're going to do is print a string.
38
00:02:44,660 --> 00:02:52,670
Now in the very stereotypical lesson the very first string that most people print is the hello world.
39
00:02:52,670 --> 00:02:54,260
So we're gonna go ahead and just do that.
40
00:02:54,650 --> 00:02:59,990
So let's go ahead and print Hello World and we're going to do that by just typing in print and then
41
00:02:59,990 --> 00:03:04,970
in parentheses with quotation and we're gonna say hello world.
42
00:03:05,270 --> 00:03:06,680
Something like this.
43
00:03:06,680 --> 00:03:09,200
OK and that's it.
44
00:03:09,230 --> 00:03:16,130
So what we can do here is we can just save this and we can go ahead and give this a go.
45
00:03:16,160 --> 00:03:22,620
So what we'll do is we'll say Python 3 and then we can say first in an auto tab out to first stop pi
46
00:03:23,840 --> 00:03:26,220
and you can see now that it wrote out hello world.
47
00:03:26,510 --> 00:03:35,120
So if we go up twice and go back to our g at it we can see here that it ignored printing out anything
48
00:03:35,120 --> 00:03:40,900
here with the comment it didn't interpret this because this is a comment with the hash and we just told
49
00:03:40,900 --> 00:03:45,360
that one instruction which was to print Hello World and it did just that.
50
00:03:45,410 --> 00:03:52,160
So the nice thing about strings is we could use double quotes or we could use single quotes so we could
51
00:03:52,160 --> 00:04:04,250
say sorry hello world like this and we can also use multi line strings so I'm going to tab or hit enter
52
00:04:04,250 --> 00:04:10,460
twice here and we could say something along the lines of print and what if we have a long quote We could
53
00:04:10,460 --> 00:04:24,980
say something like this string runs and then we could say multiple lines like this and we just put that
54
00:04:24,980 --> 00:04:28,020
with triple quotations like this.
55
00:04:28,060 --> 00:04:33,220
And lastly we can do a little bit of what is called concatenation.
56
00:04:33,220 --> 00:04:43,270
We could say something like print this string is and then we'll want to put a space at the end here
57
00:04:43,450 --> 00:04:51,190
and end the quotation that we can put a plus sign in here and we could say something like awesome and
58
00:04:52,120 --> 00:04:59,240
and that parentheses so with all of this you're going to see that OK we can print Hello World.
59
00:04:59,240 --> 00:05:01,700
It should print Hello World hello world.
60
00:05:01,730 --> 00:05:06,580
This string runs multiple lines and this string is awesome and it should be space.
61
00:05:06,650 --> 00:05:09,020
Awesome here because we included the space.
62
00:05:09,020 --> 00:05:13,730
Now you're going to notice even though we've put line breaks in for us no line breaks are going to be
63
00:05:13,730 --> 00:05:14,180
printed.
64
00:05:14,180 --> 00:05:15,980
We'll talk about that here in one second.
65
00:05:15,980 --> 00:05:18,290
So let's save this and let's just run it.
66
00:05:19,160 --> 00:05:21,830
So we're gonna go ahead and run Python 3.
67
00:05:21,830 --> 00:05:23,090
First up Pi.
68
00:05:23,690 --> 00:05:27,730
And everything looks as anticipated right.
69
00:05:27,740 --> 00:05:29,390
So I want to show you one thing.
70
00:05:29,390 --> 00:05:32,300
Let's tab up twice and let's put an ampersand at the end of this.
71
00:05:32,300 --> 00:05:33,170
Watch what this does.
72
00:05:34,560 --> 00:05:42,510
Now we have access not only to our script here but we can also run code as well.
73
00:05:42,510 --> 00:05:47,160
So as long as we save this we can run the code and we don't have to keep exiting out back and forth.
74
00:05:47,730 --> 00:05:52,220
So let's say that we did want to put a line in between these two Hello worlds.
75
00:05:52,360 --> 00:05:59,280
We've got this here what we can do is we can print this can say something like a
76
00:06:02,490 --> 00:06:10,380
and like this like a type today and we close this off and you can put a little note next to it say you
77
00:06:10,380 --> 00:06:12,840
remember and just say new line.
78
00:06:12,840 --> 00:06:17,370
So when you have that backslash n that prints out a new line.
79
00:06:17,370 --> 00:06:21,680
So let's say that and just take a look at that and there you go.
80
00:06:21,680 --> 00:06:28,390
You have a new line put in there so quick and easy way to add a line in a line break.
81
00:06:28,390 --> 00:06:29,210
And.
82
00:06:29,300 --> 00:06:31,010
So here.
83
00:06:31,100 --> 00:06:33,440
Very simple very simple lesson right.
84
00:06:33,440 --> 00:06:35,740
All we're doing is just learning how to print things.
85
00:06:35,750 --> 00:06:40,640
And we're dealing with string so even if you want to go in and build upon this you can add comments
86
00:06:40,640 --> 00:06:42,530
in for yourself to make this easier.
87
00:06:42,830 --> 00:06:51,860
So you can come in here and say double quotes you could say single quotes and then you can come in here
88
00:06:51,860 --> 00:06:58,290
and say triple closed for multiplying.
89
00:06:58,600 --> 00:06:59,380
Right.
90
00:06:59,390 --> 00:07:03,740
And this way you know kind of what everything is doing.
91
00:07:03,740 --> 00:07:10,330
This one you can say here you could say we can also can cat in name.
92
00:07:10,620 --> 00:07:13,500
I don't know if he spelled that correctly but I'm hoping I did.
93
00:07:13,520 --> 00:07:15,890
So that's really it for this lesson.
94
00:07:15,890 --> 00:07:17,730
Just want to cover the basics.
95
00:07:17,810 --> 00:07:24,180
So in the next lesson we're going to start talking about math and the math that python can do and again
96
00:07:24,200 --> 00:07:25,840
where does it continue to build upon this.
97
00:07:25,850 --> 00:07:28,070
So I'll catch you over in the next lesson.
10050
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.