All language subtitles for 2. Our First Python Program

af Afrikaans
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English Download
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:05,240 --> 00:00:08,580 So it's a tradition, when learning any new programming language, 2 00:00:08,580 --> 00:00:12,520 that the first program you write should print out the text Hello World, 3 00:00:12,520 --> 00:00:14,740 and we're going to do just that in this video. 4 00:00:14,740 --> 00:00:21,520 So start Intellij DEA, as I have, and choose Create New Project from the Main menu. 5 00:00:21,520 --> 00:00:27,760 Now if you're using a different IDE or editor, use its command for creating a new Python project. 6 00:00:27,760 --> 00:00:31,160 So we want to select Python, on the left hand side, as I've done here, 7 00:00:31,160 --> 00:00:39,080 and also make sure you've got a valid Python SDK selected at the top right, and click on Next. 8 00:00:39,080 --> 00:00:42,940 Once you get to this screen, you can type in the project name. 9 00:00:42,940 --> 00:00:47,620 So I'm just going type in there, Hello World. 10 00:00:47,620 --> 00:00:52,020 Now I don't like using spaces in the names of things, as that can cause problems. 11 00:00:52,020 --> 00:00:54,940 To make the name more readable, I've used Pascal case. 12 00:00:54,940 --> 00:00:59,660 I've used a capital H for the word Hello, and W for the word World. 13 00:00:59,660 --> 00:01:05,840 Now you can change the location if you want, but make sure you don't put one project inside another project directory 14 00:01:05,840 --> 00:01:10,080 So what I'm going to do, and I'll fix up that spelling first, 15 00:01:10,080 --> 00:01:14,880 I'm going to move to a new folder, just to show you what you would do, the first time you're setting this up. 16 00:01:14,880 --> 00:01:16,680 Then come to the folder. 17 00:01:16,680 --> 00:01:19,780 That's my main folder where I've got all my different programming languages. 18 00:01:19,780 --> 00:01:22,640 I'm going to create a new project. 19 00:01:22,640 --> 00:01:23,560 I need folder, rather, and I'm going to call 20 00:01:23,560 --> 00:01:33,200 this one python-masterclass-remaster-shared, and this is just a format that I've used on my computer. 21 00:01:33,200 --> 00:01:37,260 Alright, so scrolling up here, i'm gonna do the same thing that I've done for my java masterclass. 22 00:01:37,260 --> 00:01:44,080 I'm gonna create a subfolder called current Java masterclass remaster, but we're going to obviously call that Python. 23 00:01:44,080 --> 00:01:47,500 And this is just the way that I've set things up: 24 00:01:47,500 --> 00:01:57,420 python-masterclass-remaster, and I think I called it current at the start, so I'll put that current, 25 00:01:57,420 --> 00:02:01,100 and that's where all my projects are going to go, in that folder. 26 00:02:01,100 --> 00:02:06,140 Now the first time you do that, you create a new folder. If we look at the end of this project location, 27 00:02:06,140 --> 00:02:08,340 note that it hasn't got the project name there. 28 00:02:08,340 --> 00:02:16,360 So what you'll need to do for the very first project, is put a slash in there, and HelloWorld, being the name of the project. 29 00:02:16,360 --> 00:02:21,040 Subsequent times that you create new projects, it'll automatically find this project location, 30 00:02:21,040 --> 00:02:23,060 and put the project name after it. 31 00:02:23,060 --> 00:02:27,480 Alright, so at this point now that I've done that, I'm going to click on Finish. 32 00:02:27,480 --> 00:02:29,860 You're prompted now, do we want to create that folder? 33 00:02:29,860 --> 00:02:35,880 This is, I know it's a long path, but this is the path that I'm storing my files on a network drive, so for me that's valid. 34 00:02:35,880 --> 00:02:40,660 You would choose whichever folder you wanted to, and make sure that was valid and then click OK. 35 00:02:40,660 --> 00:02:43,640 At this point, IntelliJ is setting up the project. 36 00:02:43,640 --> 00:02:47,820 Now it won't take long but it's a good idea not to do anything until it's finished. 37 00:02:47,820 --> 00:02:51,360 So you can see the messages down there in the status bar, at the bottom of the screen. 38 00:02:51,360 --> 00:02:58,000 Wait for these to disappear, and you'll see IntelliJ uploading skeletons, whatever that means, and indexing the project, 39 00:02:58,000 --> 00:03:06,740 and then the project's been built and we should see the project pane open, and we'll be able to see some files there. 40 00:03:06,740 --> 00:03:09,760 Alright, so you can see now the project pane open. There's no more, 41 00:03:09,760 --> 00:03:13,300 well actually there is a bit, there's the updating skeletons message you can see down the bottom there. 42 00:03:13,300 --> 00:03:15,340 So we'll just give that a moment to finish. 43 00:03:15,340 --> 00:03:18,900 Once it's done that, we can get started. 44 00:03:18,900 --> 00:03:25,180 Alright, so you can see now it's finally finished. There's now no more working messages appearing in the status bar. 45 00:03:25,180 --> 00:03:29,040 So what we want to do is create a new file for our program. 46 00:03:29,040 --> 00:03:32,360 So you want to make sure the project pane is open and you can see it is there. 47 00:03:32,360 --> 00:03:35,480 If it wasn't, by the way, you can come over here and click on project, 48 00:03:35,480 --> 00:03:39,420 and that will open and close the project tab. So make sure that's open. 49 00:03:39,420 --> 00:03:42,840 So at the top of the project pane in bold, is the name of our project. 50 00:03:42,840 --> 00:03:45,060 That's Hello World in this case. 51 00:03:45,060 --> 00:03:47,880 So make sure that you click on this, which I'm doing now, 52 00:03:47,880 --> 00:03:52,920 before we do the next step, and once we do that the file menu changes, depending on what you've got selected. 53 00:03:52,920 --> 00:03:56,120 So after clicking on the Hello World project, which I've just done, 54 00:03:56,120 --> 00:04:01,380 I can either right click and select New, Python File. 55 00:04:01,380 --> 00:04:07,300 Alternatively, I could come up here after selecting that and click on File, New, Python File. 56 00:04:07,300 --> 00:04:13,380 Either way will do the same thing. Okay, I'm going to call this one helloworld. 57 00:04:13,380 --> 00:04:16,400 Then note that I've typed it all in lowercase with no spaces. 58 00:04:16,400 --> 00:04:23,700 IntelliJ will automatically add the dot py extension to the file, which is what Python files typically have as their source file, 59 00:04:23,700 --> 00:04:28,940 but if your IDE or editor doesn't do that, then you would type in the full name, helloworld.py 60 00:04:28,940 --> 00:04:30,580 I'm gonna click on OK 61 00:04:30,580 --> 00:04:35,440 and we can see there in the project pane to the left, that it has been named with helloworld.py. 62 00:04:35,440 --> 00:04:39,400 So at this point we've now got a new Python file open in the editor. 63 00:04:39,400 --> 00:04:43,260 I'll talk a bit more about these files and directories in the project pane later. 64 00:04:43,260 --> 00:04:50,060 The best advice I can give at the moment, is that if you didn't create a file or a directory, then don't mess with it. 65 00:04:50,060 --> 00:04:55,000 You'll get strange problems if you try and put anything in that .idea directory, for example. 66 00:04:55,000 --> 00:05:00,240 The only thing we're interested in at the moment, are the .py files that we create, 67 00:05:00,240 --> 00:05:04,240 and obviously helloworld.py is the one that we've created for this project. 68 00:05:04,240 --> 00:05:10,560 And for the moment they should all be created inside, directly inside, the HelloWorld project structure, 69 00:05:10,560 --> 00:05:12,280 and that's what we've done here. 70 00:05:12,280 --> 00:05:17,160 Alright, so in terms of the actual code for our first program, it's extremely simple. 71 00:05:17,160 --> 00:05:24,040 We're going to come up and start typing print left parenthesis, noting that a right one gets added for us automatically, 72 00:05:24,040 --> 00:05:28,300 single quote, noting that a second single quote gets added automatically, 73 00:05:28,300 --> 00:05:33,340 and if you're using another IDE or editor, you'll need to perhaps enter those manually yourself. 74 00:05:33,340 --> 00:05:38,680 We're going to type Hello, World and an exclamation mark, 75 00:05:38,680 --> 00:05:41,820 and that's literally it. That's our first Python program. 76 00:05:41,820 --> 00:05:47,780 To run the program, we want to right click anywhere here in the editor window, which is where we've typed our code, 77 00:05:47,780 --> 00:05:52,160 right click and click on Run Helloworld. 78 00:05:52,160 --> 00:05:55,620 You can see straight away, the output appears in the run window at the bottom, 79 00:05:55,620 --> 00:05:58,560 and that's initially configured to be at the bottom of the screen, 80 00:05:58,560 --> 00:06:01,200 and we can see the output, Hello World! 81 00:06:01,200 --> 00:06:03,760 And that's our first Python program. 82 00:06:03,760 --> 00:06:08,820 Although it's very simple, our Hello World program does include a few important basics. 83 00:06:08,820 --> 00:06:12,240 Firstly, we've used the Python function print. 84 00:06:12,240 --> 00:06:14,140 Python has many functions, 85 00:06:14,140 --> 00:06:19,260 such as mathematical functions like round, to round the number of digits after the decimal point 86 00:06:19,260 --> 00:06:25,740 and char, chr and ord, to convert characters to their numeric representations and vice-versa, 87 00:06:25,740 --> 00:06:27,240 as well as many more. 88 00:06:27,240 --> 00:06:30,580 You can also define your own functions, as we'll see later. 89 00:06:30,580 --> 00:06:34,640 In the next video, we'll see more ways to use the print function. 90 00:06:34,640 --> 00:06:37,520 See you in the next video. 10551

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.