Python Tutorial for Beginners 1: Install and Setup for Mac and Windows
Summary
TLDRThis tutorial series offers a beginner-friendly introduction to Python programming, covering essential topics such as installation, setting up the development environment, and the basics of Python syntax. The instructor guides viewers through installing Python on both Mac and Windows, using the terminal or command prompt, and demonstrates creating and running a simple 'Hello World' script. The video also touches on using different text editors and IDEs for Python development, with a focus on Sublime Text, Atom, and PyCharm, providing a foundation for further learning in the series.
Takeaways
- π The video series aims to cover the basics of Python programming for beginners or those coming from another language.
- π οΈ The tutorial will guide viewers on how to install Python and set up a development environment on both Mac and Windows systems.
- π It's recommended to install Python 3, as Python 2 is outdated and most users are transitioning to Python 3.
- π The script explains how to check if Python is pre-installed on a Mac and how to install the latest version from python.org if it's not.
- π For Windows users, the video provides a step-by-step guide to install Python and includes adding Python to the system path for easy access.
- π» The video mentions using the IDLE application that comes with Python for writing and running scripts.
- π The importance of creating a Python file for multi-line scripts is highlighted, as opposed to using the interactive prompt for testing single lines of code.
- π The script demonstrates how to write and run a simple 'Hello World' program in Python using both the IDLE application and a command line.
- βοΈ Comments in Python, denoted by the '#' symbol, are used for developer notes and do not affect the script execution.
- π Alternative text editors and IDEs such as Sublime Text, Atom, and PyCharm are suggested for a better coding experience beyond the IDLE application.
- π Links to more detailed videos and timestamps for different parts of the installation process are provided in the video description for easy navigation.
Q & A
What is the purpose of this series of Python programming videos?
-The purpose of this series is to provide a beginner's overview of Python, covering basics such as installation, data types, conditionals, loops, functions, modules, and the standard library, to help those new to programming or transitioning from another language.
Why is Python 3 preferred over Python 2 for new learners?
-Python 3 is preferred because it is the newer and more modern version, with almost all current development and support focused on it. Python 2 is no longer maintained, making Python 3 the better choice for new learners.
How can one check if Python is already installed on a Mac?
-On a Mac, one can check if Python is pre-installed by opening the terminal and typing 'python --version'. This will display the version of Python if it is installed.
What is the recommended way to install the latest version of Python 3 on a Mac?
-The recommended way is to visit python.org, go to the downloads section, select the latest version of Python 3, download the .pkg file, and follow the installation instructions.
How can the 'Python' command be made to default to Python 3 instead of Python 2 on a Mac?
-This can be achieved by creating an alias in the .bash_profile file that points the 'Python' command to 'Python3'. Adding the line 'alias python=python3' and saving the file will make this change.
What is the difference between the Python interactive prompt and a Python script file?
-The Python interactive prompt allows for one-line commands to be entered and executed immediately. A Python script file, on the other hand, contains multiple lines of code that can be saved and executed as a whole.
How can a Python file be executed from the terminal or command prompt?
-To execute a Python file, navigate to the directory containing the file in the terminal or command prompt and type 'python filename.py', replacing 'filename.py' with the actual file name.
What is IDLE and how is it used in the context of this tutorial?
-IDLE is a basic Python Integrated Development Environment (IDE) that comes with Python. It can be used to write and run Python scripts. In the tutorial, it is used to create and execute the first Python script.
What are some alternative text editors or IDEs to IDLE for writing Python code?
-Some popular alternatives to IDLE include Sublime Text, Atom, and PyCharm. These editors offer additional functionality such as syntax highlighting, code completion, and debugging tools.
How can Python scripts be run from within an alternative text editor like Sublime Text?
-In Sublime Text, Python scripts can be run directly from the editor using the 'Tools' menu and selecting 'Build', or by using a keyboard shortcut configured for running the build.
What is the significance of comments in Python code?
-Comments in Python, marked by the '#' symbol, are used to describe what the code is doing. They are ignored by the Python interpreter and serve as documentation for developers, helping to explain the purpose and functionality of the code.
Outlines
π Introduction to Python Programming Series
The video script introduces a series focused on the basics of Python programming, aimed at beginners or those transitioning from other languages. The speaker plans to cover installation, data types, conditionals, loops, functions, modules, and the standard library. They mention that some topics will be briefly covered with references to more detailed videos for further exploration. The script also addresses the installation process for Python on both Mac and Windows operating systems, emphasizing the use of Python 3.6 as the version of choice.
π» Installing Python and Setting Up the Development Environment
This section of the script provides a step-by-step guide on installing Python for Mac users, including checking for pre-installed Python, downloading the latest version from python.org, and installing it. It explains how to create an alias to use the 'python' command for Python 3. The script then shifts to Windows installation, detailing the process of checking for Python, downloading it from the official site, and ensuring it's added to the system path. The speaker also discusses using the IDLE application that comes with Python for writing and running scripts.
βοΈ Writing and Running the First Python Script
The script moves on to writing the first Python script using the IDLE application. It demonstrates how to create a new file, write a 'Hello World' print statement, and save the script. The process of running the script from the terminal or command prompt is explained. The video also touches on the use of comments in Python scripts for developer reference. The speaker suggests that while IDLE is sufficient for beginners, more advanced programmers might prefer other text editors or IDEs like Sublime Text, Atom, or PyCharm, which offer additional features.
π Conclusion and Call to Action
The final paragraph wraps up the video by summarizing the content covered, which includes installing Python on Mac and Windows, running Python interactively, and creating and executing a Python script. The speaker previews the next topic of the series, which will be about variables and data types, specifically strings. They encourage viewers to ask questions in the comments and offer support by liking, sharing, or contributing through Patreon. A reminder to subscribe for future videos concludes the script.
Mindmap
Keywords
π‘Python programming
π‘Development environment
π‘Data types
π‘Conditionals
π‘Loops and iterations
π‘Functions
π‘Modules
π‘Standard library
π‘IDLE
π‘Text editors
π‘IDE (Integrated Development Environment)
π‘Command prompt
π‘Terminal
π‘Comment
Highlights
Introduction to a series of videos covering the basics of Python programming.
Addressing the need for a beginner's overview of Python for those starting out or coming from another language.
Coverage of setting up Python, working with data types, conditionals, loops, functions, modules, and the standard library.
Reference to more detailed videos for certain topics already covered.
Instructions on installing Python and setting up the development environment on both Mac and Windows.
Checking if Python is pre-installed on a Mac and how to check the Python version.
The recommendation to use Python 3 over Python 2 for new learners.
Downloading and installing the latest version of Python 3 from the official website.
Creating an alias to make 'Python' command default to Python 3.
Instructions for installing Python 3 on Windows, including adding Python to the system path.
How to verify the Python installation by checking the version in the command prompt.
Using IDLE, the Python editor that comes with the Python download, to write and run Python scripts.
Writing a 'Hello World' script in Python and running it from the terminal or command prompt.
Demonstration of how to write and run a Python script using a plain text editor.
Explanation of Python's inline comments and their usage in scripts.
Recommendations for alternative text editors and IDEs for Python development.
How to run Python scripts directly from an advanced text editor like Sublime Text.
Invitation for viewers to ask questions and support the tutorial series.
Transcripts
hey there how's it going everybody in
this series of videos we'll be going
over the basics of Python programming
now I get a lot of messages from people
who say that they enjoy my Python videos
but that they're either just getting
started out in programming or coming
from another language and would like a
beginner's overview of Python so that
they can better understand the more
advanced topics and that's what we're
going to do here we're going to cover
how to get up and running with Python
how to work with the different data
types how to work with conditionals and
loops and iterations how to create
functions also importing modules and
working with the standard library so
basically everything that you need to
know in order to have a firm
understanding of the Python fundamentals
now one thing I do want to point out is
that throughout these tutorials I'm
going to go over a few topics that I've
already made eat more detailed videos
about and anytime that happens I'll
touch on the basics of that topic but
then reference the more detailed video
if you'd like to see more examples and
that will allow us to move along at a
good pace so let's go ahead and get
started so first we're going to learn
how to install Python and set up our
development environment and we're going
to look at how to do this on both Mac
and Windows and this is pretty
straightforward process
so first we'll look at how to do this on
a Mac but if you're on a Windows machine
then you can look in the description
section below and I'll put a link to the
time stamp where we start the
installation for Windows and that way
you can skip ahead if you want or if you
already have Python installed for your
operating system and I also put a link
to the time stamp or both of these
installations are complete so that you
can skip to where we're ready to write
some code so for a Mac Python usually
comes pre-installed the check if Python
is pre-installed then we can just open
up our terminal and within our terminal
we can say Python - - version now we can
see here that the default Python is
Python - 7 now it used to be more
controversial as to which version you
want to use but almost everyone is
moving over to Python 3 and if you're
learning Python then you're definitely
going to want to go with Python 3 unless
you have a really good reason to do
otherwise so let's go ahead and install
the latest version of Python 3 so to do
this we're just going to pull up an
internet browser and we're going to go
to the Python website which is here at
python.org and from here we can go to
downloads and we can see that it already
detected that we're on a Mac and has
offered up either python 3 or python 2
and
you want to go with the latest version
Python 3.6 so that's going to download a
pkg file and we will click on this to go
ahead and start the installation now
this is a pretty standard walkthrough
here if you've installed software before
then all a lot of this will look
familiar so we're just going to agree to
some terms you can change the install
location if you want I'm just going to
leave that as default and you may need
to put in your password to install this
now once that's finished installing it
will place a Python 3:6 directory in
your Applications folder and if we open
up our Applications folder and scroll
down here a bit and you can see I have
an old version of Python 3 5 here but it
installed this Python 3 6 and if we open
this up and look inside here and we can
see that we have this ID or Idol
application and we'll come back to that
in just a second so now that we have
python 3 6 installed let's go back to
our terminal and check our python
version again so if i run that actually
let me close down the terminal and open
this back up just so that we're sure
that we're starting with a fresh slate
so now if I run that python version
again then most likely you're going to
see that it still says python 2 7 now
the reason is because when we installed
Python 3 it actually uses this Python 3
command instead so if I instead use this
Python 3 command and check that version
and we can see that we get python 3 6
that we just installed now if we want
the Python command to use Python 3 then
one way we can do this is to create an
alias now to do this we can add a line
to this dot bash profile file and if you
don't know what that is then don't worry
about it too much this is just going to
allow us to associate the Python command
with python 3 so you can use any editor
to edit this file but since I'm already
in the terminal I'm just going to go
ahead and use nano and nano is pretty
easy for beginners so I will say Nano
now this is in your home directory so a
tilde means your home directory and then
a slash now this file is called bash
underscore profile so now let's go ahead
and open that up now within this file
you might realize that I have some more
content here than you do and these are
just some personal customizations that I
have but
don't worry about any of this if I go to
the bottom here and let me like make
this just a little bit larger here now
you should see that whenever you install
the Python 3 that it actually added a
few lines here at the bottom and you
should have these lines also now setting
this path variable like it's doing here
is what allows the Python 3 command to
work so we'll move down here below to
the bottom and add an alias not to do
this all we have to do is say alias
Python equals Python 3 and you want to
make sure it looks exactly like this no
space between the equals or anything
like that so now to save this we can
just hit ctrl X to close hit Y that to
say that we want to save it and then hit
enter to keep that same filename so now
if we quit out of our terminal and open
this back up and now let's check that
python version again so I'm going to do
Python - - version and now we can see
that it's using Python 3 6 now I
probably should have mentioned this
earlier but you do not have to create
that Python alias if you wanted to you
could just use that Python 3 command to
run all of your scripts but I like to
use this Python command so that's why I
personally like to create the alias okay
so now let's walk through how we install
Python 3 for Windows now if you're on a
Mac and want to skip through this part
and you can click on the timestamp in
the description below that skips forward
when both of these installations are
complete but this install for Windows
actually doesn't take very long at all
ok so to check if python is already
installed we can open up our command
prompt by going down here to start and
then search for CMD and let's open up
that and I'm going to make this font a
little bit bigger so that we can see
here I think I can click on properties
and font and we'll go with something a
little bit larger there okay now to see
if we have access to Python we can just
type in Python - - version and most
likely you'll see that this is not yet
installed and get this Python is not
recognized err so to install this we can
just open up an internet browser and go
to the Python web site which is Python
dot
and from here we can click on downloads
and from this page you can see that it's
already detected that we are on Windows
and has offered up either Python 3 or
python 2 now if you're learning Python
then you're definitely going to want to
go with Python 3 unless you have a
really good reason to do otherwise so
let's go ahead and go with this download
of python 3.6 so let's go ahead and run
this download and we should get this
pop-up so i'm going to go ahead and run
that now this is an important step here
one thing that you're going to want to
do is click this option to add python 3
6 to your path this will allow us to get
by without going into the advanced
system settings and setting this path
manually and adding that to your path
will allow the Python command to work
within the command prompt so with that
selected now let's go ahead and just
click through this installation and it
says that setup was successful so now
that python is installed let's come down
here to our command prompt and open it
back up actually let's close this one
down and start from scratch so we'll
open this back up type in CMD and open
up that command prompt again and now we
can make sure that that installed by
typing in Python and then - - version
you can see here that it says that we're
working with Python 3 6 so that's good
now if we come down here and click on
start and all programs and we'll see
that we have this Python 3 6 folder here
that was installed with python within
this folder we can see that we have a
program called idle and I'm going to
come back to this idle program in just a
second so when I mention this program
then just remember that you can find it
here within this Python 3 6 folder so
that is how we install Python for
Windows now I'm going to switch back to
my native operating system on the Mac
but from this point on python is going
to work the same for both operating
systems so everyone is going to be able
to follow along ok so now I'm just going
to go ahead and minimize that ok so now
that we have Python installed now we can
begin and go ahead and write our first
bit of code by opening up either our
terminal or our command prompt and I'll
just close this installation window down
in the back here and Center this ok so
now within the terminal or command
prompt if
just type in Python and this will open
what's called an interactive prompt and
we can see that it shows that we're
using Python 3 6
now the interactive prompt allows us to
write one line of Python at a time so
for example for a hello world
application then we could simply write
print hello world and we can see that it
prints that out and we can also set
variables so I could say X is equal to
equal to 10 and if I print out X then we
can see that we get 10 now this
interactive prompt is OK for testing
Python commands but we really want to
have a Python file where we can write
multiple lines and run an entire script
so let's exit this interactive prompt
and we can do that by typing exit and
then opening closed parenthesis so to
create a Python file we're going to need
some kind of plain text editor when we
downloaded Python it came with an editor
called idle so let's open up that idle
program so again on windows that's in
the Python 3 6 folder that we opened up
earlier and on the Mac it's just down
here and our applications and we can go
ahead and open this up so I'm going to
go ahead and make the font a little bit
bigger here by going to my preferences
just so that everyone can see and I'll
bump this up to 18 or so okay I think
that's good now by default when we open
up idle this is just another interactive
prompt where we can write one line at a
time and you can usually tell when
you're at an interactive prompt because
of these three arrows here so to create
an actual file we can click on file and
new file now this will create a new file
where we can write multiple lines of
Python and actually make a script so for
our first script let's just print out
hello world like we did before we can do
that by calling the print function and
then these opening and closing
parenthesis and then either single or
double quotes and then typing in hello
world now we're going to want to save
this file so we can save this by
clicking on file and then save and I'm
going to call this intro dot pi and I'm
just going to save this to my desktop so
now I'll go ahead and save that so now
to run the python file that we just
created we can go back to our terminal
or our command prompt and from here we
can type in Python and then we want to
type in the name of the file that we
want to run now this is relative to the
directory that we're currently in so if
we're in our home folder and when you
saved it to your desktop then that
should be in desktop and then the name
of that file is intro dot pi so if we
run that and you can see that it printed
out hello world so we just ran our first
Python program now I still have this
Python file up over here and real quick
let me show you how to do a single
inline comment and Python because I'll
be using these inline comments
throughout these tutorials and don't
want them to throw you off so in my
script here if I wanted to write a
description of what's going on then I
could add a comment and to do this we
can just start up here at the top line
and I'm going to go ahead and write a
comment of what we're doing so what it
starts with the pound sign and then our
comment so I'll just say print a welcome
message now if I go ahead and save that
file and then run this again from my
desktop then you can see that it didn't
do anything to our script that still
just prints out hello world so when we
actually run our Python programs these
comments are ignored it's only there for
the developer and the programmer to
actually see what's going on now you
don't need anything fancy to run these
Python scripts so if you wanted to then
you could follow through all of my
videos using this idle application like
we have running here and then running
the script from the command line but if
you plan on doing a lot of Python
programming then you'll likely want to
upgrade to a better editor now you can
use any kind of plain text text editor
that you want you can even use some
command line editors like vim or Emacs
if you'd like some of the most popular
editors and I have some of these pulled
up and the browser here so one very
popular editor is sublime text and
that's at sublime text calm another
popular text editor is atom and that's
at atom IO and a very popular IDE is the
JetBrains
pycharm ide so sublime text and atom are
text editors but with a lot of extra
functionality built in and PyCharm is a
full
loan ide and that will give you a lot of
extra features that you might not find
and other editors like the ability to
debug a running application and things
like that now in this series of videos
i'm going to be using sublime text now i
have a full video on how i set up and
customize my sublime text and i also
have a full video on how to set up and
customize atom so if you want to use
either of those editors and i highly
recommend watching those videos and i'll
leave links to those in the description
section below now one nice thing about
using one of these editors is that you
can run Python from directly within the
editor so I have the same intro PI file
that we just created pulled up here in
sublime text and I can run this by going
to tools and build or we could have just
used that keyboard shortcut but you can
see that if we run that and we get the
same hello world output that we got when
we ran at this file from our command
line so to follow along with these
videos you can use the idle application
and use the command line to run those
scripts or you can set up one of these
other text editors the choice is
completely up to you okay so I think
that is going to do it for this video in
this video we walk through how to
install Python on both Mac and Windows
we looked at how to run Python
interactively within the terminal or
command line and we also have saw how to
create a Python file and execute that
script so in the next video we'll start
learning about variables and datatypes
and specifically we're going to look at
the string datatype and everything that
we can do with those but if anyone has
any questions about what we covered in
this video then feel free to ask in the
comment section below and I'll do my
best to answer those now if you enjoy
these tutorials and would like to
support them there are several ways you
can do that the easiest ways to simply
like the video and give it a thumbs up
and also it's a huge help to share these
videos with anyone who you think would
find them useful and if you have the
means you can contribute through patreon
and there's a link to that page in the
description section below be sure to
subscribe for future videos and thank
you all for watching
worried
you
Browse More Related Video
#2 Python Tutorial for Beginners | Python Installation | PyCharm
Download and Install Python (3.10.6) and Pycharm | Python Tutorials for Beginners #lec3
Writing First Python Program | Printing to Console in Python | Python Tutorials for Beginners #lec4
Python Tutorial for Beginners with VS Code π
How to set up Python on Visual Studio Code
Tutorial 1- Anaconda Installation and Python Basics
5.0 / 5 (0 votes)