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
English
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
Hey welcome to this new lecture and in
this lecture I'm going to show you how
3
to create and execute a Python program
on a Mac computer, so if you are a
5
Windows user please skip this lecture.
And so in the previous lecture I showed
7
you how to install Python 3 and also how
to launch a Python 3 interactive
9
Session, so which is good for executing
and testing out code so like that line.
11
Like my line, but if you quit the terminal
you're going to lose that code, so you
13
want to find out a way to save that code
in a file so that you can develop your
15
program step by step, so you can go back
to your code, add the code, modify it, and
17
most importantly you can execute
multiple lines at once instead of
19
executing line by line interactively.
So let's go ahead and do that.
21
Normally you need to figure out,
to create a directory where you want to
23
save your program, so I'm going to create
this folder in here and this is empty
25
for now, so I'm going to create a
file there. There may be different ways
27
of creating a Python file all but I prefer
to do it via the terminal.
29
So currently you do PWD, that will print
out the current directory of the terminal,
31
so the terminal is an app and it is
opened in the current directory, in a certain
33
directory which is this on for the
moment. If you do ls you will see the
35
directories and files or the current
Directory, so users admin has this
37
directors, has these folders so if you
want to go to the desktop folder,
39
you'd want to do
desktop or you can use the Tab for auto
41
Completion, so the tab key and then Un Tab.
That will take you to the
43
untitled folder. Execute and I'll see
that your current folder is the untitled
45
folder and that means you can go ahead
and create a file now. Let's say touch my
47
program dot py, so you can give it
any name that you want. Execute and that
49
will create an empty file which for now
you can go ahead and edit it with text
51
edit for example. Later on we're going
to install Atom editor which is much
53
more advanced than this simple editor
but for now this should be enough to
55
just get you started to get you the
idea on how to execute a Python program
57
so let create code for the program.
This program will simply
59
print out the hello text so you need, you
use this print keyword and then you use
61
double quotes and then the text hello and
then another double quote to close the
63
text and then a closing bracket.
65
CTRL S to save, exit text edit and then
go back to the terminal and what you do
67
here now to execute your program, the
program that you just created, you use the
69
Python 3 command and then my, you can
type my program dot py or you can use
71
tab to autocomplete the name, enter to
execute and you get the output of the program.
73
Print it out in the terminal so in this
case the output is hello and yeah that's how
75
you create and execute a program on Mac
and similarly you can go ahead and
77
create other Python programs in here just
as we did with my program dot py. I can also
79
show you a quick way to actually open
the terminal in this current directory
81
without having to do CD and try the
path name, so let's do that.
83
You go here, system preferences, so this is a
one time configuration. Go to keyboard.
85
Shortcuts and then in the shortcuts tab
you go to services, scroll down and see
87
you probably have this option
unchecked, so you want to make sure you
89
have checked the new terminal at folder
option just like I have it here, so make
91
sure make sure that is checked. Close
this and then what you do is to open the
93
terminal in a current folder, in a
specific folder you right click on
95
folder and then go to New Terminal at
Folder and now what you do is Python 3
97
Myprogram.py, execute and you get the
Output, so that's a quick way to open
99
the terminal in a specific folder and
yeah that's about this lecture.
101
I hope everything went smoothly and I'll
talk to you later. Thanks.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.