All language subtitles for 2. Our First Python Program

af Afrikaans
ak Akan
sq Albanian
am Amharic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

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.