Premium Only Content
Creating and Executing a Python Program on Mac | Celestial Warrior
External Link:~ https://www.windowscentral.com/how-add-open-command-prompt-window-here-back-context-menu-windows-10
Frequently Asked Questions: file:///C:/Users/Taha%20Umar%20Farooq/Videos/FOLDER/[Tutsgalaxy.com]%20-%20The%20Python%20Mega%20Course%20Build%2010%20Real%20World%20Applications/01%20Getting%20Started/009%20Installation%20FAQs.html
1
00:00:00,000 --> 00:00:04,859
Hey welcome to this new lecture and in
this lecture I'm going to show you how
3
00:00:04,859 --> 00:00:12,059
to create and execute a Python program
on a Mac computer, so if you are a
5
00:00:12,059 --> 00:00:17,520
Windows user please skip this lecture.
And so in the previous lecture I showed
7
00:00:17,520 --> 00:00:25,080
you how to install Python 3 and also how
to launch a Python 3 interactive
9
00:00:25,080 --> 00:00:33,809
Session, so which is good for executing
and testing out code so like that line.
11
00:00:33,809 --> 00:00:43,410
Like my line, but if you quit the terminal
you're going to lose that code, so you
13
00:00:43,410 --> 00:00:49,800
want to find out a way to save that code
in a file so that you can develop your
15
00:00:49,800 --> 00:00:56,010
program step by step, so you can go back
to your code, add the code, modify it, and
17
00:00:56,010 --> 00:01:01,379
most importantly you can execute
multiple lines at once instead of
19
00:01:01,379 --> 00:01:06,659
executing line by line interactively.
So let's go ahead and do that.
21
00:01:06,659 --> 00:01:11,700
Normally you need to figure out,
to create a directory where you want to
23
00:01:11,700 --> 00:01:17,850
save your program, so I'm going to create
this folder in here and this is empty
25
00:01:17,850 --> 00:01:25,590
for now, so I'm going to create a
file there. There may be different ways
27
00:01:25,590 --> 00:01:32,189
of creating a Python file all but I prefer
to do it via the terminal.
29
00:01:32,189 --> 00:01:37,560
So currently you do PWD, that will print
out the current directory of the terminal,
31
00:01:37,560 --> 00:01:43,049
so the terminal is an app and it is
opened in the current directory, in a certain
33
00:01:43,049 --> 00:01:50,399
directory which is this on for the
moment. If you do ls you will see the
35
00:01:50,399 --> 00:01:56,939
directories and files or the current
Directory, so users admin has this
37
00:01:56,939 --> 00:02:03,090
directors, has these folders so if you
want to go to the desktop folder,
39
00:02:03,090 --> 00:02:08,080
you'd want to do
desktop or you can use the Tab for auto
41
00:02:08,080 --> 00:02:16,360
Completion, so the tab key and then Un Tab.
That will take you to the
43
00:02:16,360 --> 00:02:24,250
untitled folder. Execute and I'll see
that your current folder is the untitled
45
00:02:24,250 --> 00:02:32,020
folder and that means you can go ahead
and create a file now. Let's say touch my
47
00:02:32,020 --> 00:02:42,070
program dot py, so you can give it
any name that you want. Execute and that
49
00:02:42,070 --> 00:02:49,420
will create an empty file which for now
you can go ahead and edit it with text
51
00:02:49,420 --> 00:02:54,160
edit for example. Later on we're going
to install Atom editor which is much
53
00:02:54,160 --> 00:02:59,709
more advanced than this simple editor
but for now this should be enough to
55
00:02:59,709 --> 00:03:06,580
just get you started to get you the
idea on how to execute a Python program
57
00:03:06,580 --> 00:03:12,340
so let create code for the program.
This program will simply
59
00:03:12,340 --> 00:03:20,230
print out the hello text so you need, you
use this print keyword and then you use
61
00:03:20,230 --> 00:03:28,600
double quotes and then the text hello and
then another double quote to close the
63
00:03:28,600 --> 00:03:32,760
text and then a closing bracket.
65
00:03:46,470 --> 00:03:56,520
CTRL S to save, exit text edit and then
go back to the terminal and what you do
67
00:03:56,520 --> 00:04:00,930
here now to execute your program, the
program that you just created, you use the
69
00:04:00,930 --> 00:04:07,200
Python 3 command and then my, you can
type my program dot py or you can use
71
00:04:07,200 --> 00:04:14,760
tab to autocomplete the name, enter to
execute and you get the output of the program.
73
00:04:14,760 --> 00:04:20,040
Print it out in the terminal so in this
case the output is hello and yeah that's how
75
00:04:20,040 --> 00:04:24,570
you create and execute a program on Mac
and similarly you can go ahead and
77
00:04:24,570 --> 00:04:31,050
create other Python programs in here just
as we did with my program dot py. I can also
79
00:04:31,050 --> 00:04:35,730
show you a quick way to actually open
the terminal in this current directory
81
00:04:35,730 --> 00:04:42,690
without having to do CD and try the
path name, so let's do that.
83
00:04:42,690 --> 00:04:50,460
You go here, system preferences, so this is a
one time configuration. Go to keyboard.
85
00:04:50,460 --> 00:05:03,150
Shortcuts and then in the shortcuts tab
you go to services, scroll down and see
87
00:05:03,150 --> 00:05:08,070
you probably have this option
unchecked, so you want to make sure you
89
00:05:08,070 --> 00:05:13,590
have checked the new terminal at folder
option just like I have it here, so make
91
00:05:13,590 --> 00:05:20,490
sure make sure that is checked. Close
this and then what you do is to open the
93
00:05:20,490 --> 00:05:25,350
terminal in a current folder, in a
specific folder you right click on
95
00:05:25,350 --> 00:05:34,110
folder and then go to New Terminal at
Folder and now what you do is Python 3
97
00:05:34,110 --> 00:05:39,390
Myprogram.py, execute and you get the
Output, so that's a quick way to open
99
00:05:39,390 --> 00:05:44,100
the terminal in a specific folder and
yeah that's about this lecture.
101
00:05:44,100 --> 00:05:50,210
I hope everything went smoothly and I'll
talk to you later. Thanks.
-
2:03:57
Megyn Kelly
2 days agoNew Trump Derangement Syndrome, and How CNN Smeared a Navy Veteran, w/ Piers Morgan & Zachary Young
91.4K163 -
10:05
DIY Wife
3 years agoHow We Flip Old Furniture For Profit!
45.5K57 -
2:14:54
TheSaltyCracker
5 hours agoTrump Goes Gangster ReeEEeE Stream 01-26-25
112K246 -
4:42:13
Due Dissidence
14 hours agoTrump Calls To "CLEAN OUT" Gaza, Swiss ARREST Pro-Palestine Journalist, MAGA's Hollywood Makeover?
50.2K72 -
2:02:20
Nerdrotic
7 hours ago $15.86 earnedDECLASSIFIED: JFK, MLK UFO Immaculate Constellation Doc | Forbidden Frontier #089
72.9K15 -
3:00:14
vivafrei
14 hours agoEp. 248: "Bitcoin Jesus" Begs Trump! Rekieta Gets Plea Deal! Pardons, Deportations, Bird Flu & MORE!
161K179 -
3:44:06
Rising Rhino
13 hours ago $12.55 earnedWashington Commanders Vs Philadelphia Eagles: NFL NFC Championship LIVE Watch Party
74.4K4 -
13:00
Exploring With Nug
8 hours ago $5.55 earnedHe Went To Get A Haircut And Vanished WIthout a Trace!
59.3K2 -
18:53
DeVory Darkins
2 days ago $30.25 earnedTrump JUST ENDED Mayor Karen Bass During HEATED Meeting
91.3K218 -
21:06
Russell Brand
11 hours agoIT'S COMING
148K486