Afrikaans
Akan
Albanian
Amharic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
1
So it's a tradition, when learning any new programming language,
2
that the first program you write should print out the text Hello World,
3
and we're going to do just that in this video.
4
So start Intellij DEA, as I have, and choose Create New Project from the Main menu.
5
Now if you're using a different IDE or editor, use its command for creating a new Python project.
6
So we want to select Python, on the left hand side, as I've done here,
7
and also make sure you've got a valid Python SDK selected at the top right, and click on Next.
8
Once you get to this screen, you can type in the project name.
9
So I'm just going type in there, Hello World.
10
Now I don't like using spaces in the names of things, as that can cause problems.
11
To make the name more readable, I've used Pascal case.
12
I've used a capital H for the word Hello, and W for the word World.
13
Now you can change the location if you want, but make sure you don't put one project inside another project directory
14
So what I'm going to do, and I'll fix up that spelling first,
15
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
Then come to the folder.
17
That's my main folder where I've got all my different programming languages.
18
I'm going to create a new project.
19
I need folder, rather, and I'm going to call
20
this one python-masterclass-remaster-shared, and this is just a format that I've used on my computer.
21
Alright, so scrolling up here, i'm gonna do the same thing that I've done for my java masterclass.
22
I'm gonna create a subfolder called current Java masterclass remaster, but we're going to obviously call that Python.
23
And this is just the way that I've set things up:
24
python-masterclass-remaster, and I think I called it current at the start, so I'll put that current,
25
and that's where all my projects are going to go, in that folder.
26
Now the first time you do that, you create a new folder. If we look at the end of this project location,
27
note that it hasn't got the project name there.
28
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
Subsequent times that you create new projects, it'll automatically find this project location,
30
and put the project name after it.
31
Alright, so at this point now that I've done that, I'm going to click on Finish.
32
You're prompted now, do we want to create that folder?
33
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
You would choose whichever folder you wanted to, and make sure that was valid and then click OK.
35
At this point, IntelliJ is setting up the project.
36
Now it won't take long but it's a good idea not to do anything until it's finished.
37
So you can see the messages down there in the status bar, at the bottom of the screen.
38
Wait for these to disappear, and you'll see IntelliJ uploading skeletons, whatever that means, and indexing the project,
39
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
Alright, so you can see now the project pane open. There's no more,
41
well actually there is a bit, there's the updating skeletons message you can see down the bottom there.
42
So we'll just give that a moment to finish.
43
Once it's done that, we can get started.
44
Alright, so you can see now it's finally finished. There's now no more working messages appearing in the status bar.
45
So what we want to do is create a new file for our program.
46
So you want to make sure the project pane is open and you can see it is there.
47
If it wasn't, by the way, you can come over here and click on project,
48
and that will open and close the project tab. So make sure that's open.
49
So at the top of the project pane in bold, is the name of our project.
50
That's Hello World in this case.
51
So make sure that you click on this, which I'm doing now,
52
before we do the next step, and once we do that the file menu changes, depending on what you've got selected.
53
So after clicking on the Hello World project, which I've just done,
54
I can either right click and select New, Python File.
55
Alternatively, I could come up here after selecting that and click on File, New, Python File.
56
Either way will do the same thing. Okay, I'm going to call this one helloworld.
57
Then note that I've typed it all in lowercase with no spaces.
58
IntelliJ will automatically add the dot py extension to the file, which is what Python files typically have as their source file,
59
but if your IDE or editor doesn't do that, then you would type in the full name, helloworld.py
60
I'm gonna click on OK
61
and we can see there in the project pane to the left, that it has been named with helloworld.py.
62
So at this point we've now got a new Python file open in the editor.
63
I'll talk a bit more about these files and directories in the project pane later.
64
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
You'll get strange problems if you try and put anything in that .idea directory, for example.
66
The only thing we're interested in at the moment, are the .py files that we create,
67
and obviously helloworld.py is the one that we've created for this project.
68
And for the moment they should all be created inside, directly inside, the HelloWorld project structure,
69
and that's what we've done here.
70
Alright, so in terms of the actual code for our first program, it's extremely simple.
71
We're going to come up and start typing print left parenthesis, noting that a right one gets added for us automatically,
72
single quote, noting that a second single quote gets added automatically,
73
and if you're using another IDE or editor, you'll need to perhaps enter those manually yourself.
74
We're going to type Hello, World and an exclamation mark,
75
and that's literally it. That's our first Python program.
76
To run the program, we want to right click anywhere here in the editor window, which is where we've typed our code,
77
right click and click on Run Helloworld.
78
You can see straight away, the output appears in the run window at the bottom,
79
and that's initially configured to be at the bottom of the screen,
80
and we can see the output, Hello World!
81
And that's our first Python program.
82
Although it's very simple, our Hello World program does include a few important basics.
83
Firstly, we've used the Python function print.
84
Python has many functions,
85
such as mathematical functions like round, to round the number of digits after the decimal point
86
and char, chr and ord, to convert characters to their numeric representations and vice-versa,
87
as well as many more.
88
You can also define your own functions, as we'll see later.
89
In the next video, we'll see more ways to use the print function.
90
See you in the next video.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.