Python Tutorial for Beginners with VS Code 🐍
Summary
TLDRIn this video, Dave introduces Python as a great programming language for both beginners and those with experience in other languages like JavaScript. He highlights Python's simplicity, versatility, large community, and job market demand. The tutorial guides viewers through installing Python and Visual Studio Code, setting up a Python environment, and creating and running a simple Python script. Dave emphasizes the importance of progress over perfection and encourages viewers to continue learning and coding. He also provides various methods to run Python files and ensures that viewers are set up to start their Python programming journey.
Takeaways
- 🐍 Python is a great first or additional programming language to learn.
- 💻 Python is easy to learn and use with a simple and straightforward syntax.
- 🔧 Python is versatile, used in applications from web development to scientific computing and data analysis.
- 🌐 Python has a large and active community with many resources and support available.
- 🚀 Python is excellent for rapid prototyping due to its simplicity and ease of use.
- 💼 Python skills are in high demand in the job market.
- 📥 Download Python from python.org and choose the version appropriate for your operating system.
- 🛠 Install Visual Studio Code as your code editor and add the Python extension.
- ⚙️ Use the command palette in Visual Studio Code to select the Python interpreter and open a terminal.
- 📁 Create and save a Python file in Visual Studio Code, and use different methods to run Python commands or files.
Q & A
Why is Python a great first programming language to learn?
-Python is easy to learn and use due to its simple and straightforward syntax, making it an excellent language for beginners.
How is Python versatile in its applications?
-Python is used in a wide range of applications, from web development to scientific computing and data analysis.
What are the benefits of Python's large and active community?
-The large and active community provides extensive resources and support, making it easier for learners and developers to find help and information.
Why is Python good for rapid prototyping?
-Python's simplicity and ease of use make it an excellent choice for rapid prototyping, allowing developers to quickly test and iterate on their ideas.
What job opportunities are available for Python developers?
-Python is one of the most popular programming languages, leading to high demand in the job market for Python developers.
What are the first steps to set up Python on your computer?
-First, download and install Python from python.org. Then, install a code editor such as Visual Studio Code.
How do you install the Python extension in Visual Studio Code?
-In Visual Studio Code, go to the Extensions view by clicking the Extensions icon on the left, search for 'Python', and install the extension provided by Microsoft.
How do you open the command palette in Visual Studio Code?
-Press Ctrl+Shift+P (or Command+Shift+P on Mac) to open the command palette in Visual Studio Code.
How can you verify your Python installation in the terminal?
-On Windows, type `py -3 --version`. On Mac or Linux, type `python3 --version`.
What is the Python REPL and how do you access it?
-The Python REPL (Read-Eval-Print Loop) allows you to run Python commands interactively. You can access it by typing `py` (or `python3` on Mac/Linux) in the terminal and pressing enter.
How do you create and run a Python file in Visual Studio Code?
-Create a new file with a `.py` extension, write your Python code, save the file, and then run it by pressing the play button in the top right, using the terminal command `py filename.py`, or right-clicking the file in the file tree and selecting 'Run Python File in Terminal'.
Outlines
🐍 Introduction to Learning Python
Dave introduces Python as a versatile programming language, highlighting its benefits for both beginners and those who already know other languages like JavaScript. He shares his enthusiasm for teaching Python and mentions that all resources will be available in the video description. Dave also provides reasons to learn Python, such as its simplicity, versatility, large community, rapid prototyping capabilities, and high demand in the job market. He then instructs viewers to visit python.org to download and install Python, selecting the appropriate version for their operating system.
🔧 Setting Up Visual Studio Code
Dave guides viewers through installing Visual Studio Code, a recommended code editor for the Python course. He explains how to download and install Visual Studio Code from code.visualstudio.com, and then walks through the steps to open the editor. Dave shows how to install the Python extension in Visual Studio Code, which provides features like IntelliSense, linting, and debugging. He demonstrates how to create a new folder for the lesson, open the command palette to select the Python interpreter, and verifies the Python installation by checking the version.
💻 Running Python Commands and Writing Code
Dave explains how to open a terminal window in Visual Studio Code and use it to run Python commands. He details the differences in terminal commands for Windows, Mac, and Linux, and demonstrates basic Python operations in the REPL (Read-Evaluate-Print Loop) environment. Dave shows how to create a new Python file, write a simple 'Hello, World!' program, and save the file with a .py extension. He explains three different ways to run the Python file: using the play button in Visual Studio Code, typing the command in the terminal, and right-clicking the file in the file tree. Dave concludes by encouraging viewers to keep progressing and thanking them for their support.
Mindmap
Keywords
💡Python
💡Syntax
💡Visual Studio Code
💡Interpreter
💡REPL
💡Extensions
💡IntelliSense
💡Community
💡Terminal
💡Rapid Prototyping
Highlights
Python is a great first programming language to learn.
Python is also a valuable addition to your resume if you already know another programming language like JavaScript.
Python's simple and straightforward syntax makes it easy to learn and use.
Python is a versatile language used in a wide range of applications, from web development to scientific computing and data analysis.
Python has a large and active community, providing many resources and support for learners.
Python is excellent for rapid prototyping due to its simplicity and ease of use.
Python is in high demand in the job market, making it a valuable skill to have.
To start learning Python, download it from python.org, where the site will identify the correct version for your operating system.
Visual Studio Code is recommended as the code editor for following along with Python lessons.
After installing Visual Studio Code, install the Python extension to get features like IntelliSense, linting, and debugging.
Use the command palette in Visual Studio Code to select the Python interpreter and verify the Python installation.
Create a new Python file in Visual Studio Code to write and execute Python commands.
You can run Python files in Visual Studio Code using the play button, the command line, or right-clicking the file in the file tree.
Python's REPL environment allows for immediate execution of Python commands, useful for quick calculations and testing code snippets.
Python is a high-level language, making it more user-friendly to read and write compared to low-level machine-oriented languages.
Transcripts
python is a great first programming
language to learn but if you already
know another programming language like
JavaScript python is still a great
addition to your resume
[Music]
hello and welcome I'm Dave today we will
begin learning the Python programming
language and I'll provide links to all
resources in the description below
congratulations on your decision to
Learn Python it's a great first or
additional programming language to learn
but don't take my word for it I asked
chat GPT why anyone should learn Python
and here's what it had to say python is
easy to learn and use it has a simple
and straightforward syntax and it's an
excellent language for beginners
versatility python is a versatile
language and it's used in a wide range
of applications from web development to
Scientific Computing and data analysis a
large and active Community python has a
large and active community of users and
developers and there's a lot of
resources and support available for you
good for rapid prototyping Python's
Simplicity and ease of use make it an
excellent choice for rapid prototyping
and job opportunities as one of the most
popular programming languages Python's
in high demand in the job market top
five reasons essentially that python is
a good programming language to learn and
add to your resume and we need to start
with the right tools so go to python.org
which you should see here in my URL bar
and from there we can download python so
there is a downloads Tab and when you
Mouse over it should show you the
current download for your operating
system as you see I'm on Windows here
and it says we are currently at python
3.11 0.2 of course if you're watching
this in the future there may be a newer
version now if you're not on Windows you
can also choose Mac OS or other
platforms over here and note here it
says Windows note that python 3.9 plus
cannot be used on Windows 7 or earlier
so if you're using Windows 7 or earlier
maybe you need to go to this Windows
link and find an older version of python
to run which should still allow you to
complete this Python tutorial so for now
click on the download for your operating
system download and install Python and
then come back to the video now that
you've got python downloaded and
installed we're going to install a code
editor and there are many different ones
to choose from my choice is Visual
Studio code and I'm going to use it
throughout the following python lessons
as I build the course so to follow along
with me I recommend that you download
and install Visual Studio code for your
operating system again the website
should I identify which platform you're
on Windows Mac Linux Etc and I'm at
code.visualstudio.com and then download
the version for your operating system
and install that after you install go
ahead and open Visual Studio code and
then come back to the video and now with
Visual Studio code open on your machine
you should see some type of welcome
screen like I have here you can go ahead
and click the X to close that we won't
need that but afterwards we need to
install the python extension for visual
studio code now on the left hand we see
the activity bar and we need to click
the extensions icon right over here on
the left so I'm going to click that and
then I'm going to search for Python and
we should see python from Microsoft if
you click on that you can see python
intellisense linting debugging and other
things that are available now I've
already installed this extension so I
have uninstall and disable you will need
to go ahead and and click install that
should show up here where I have
uninstall and install this extension for
visual studio code it should not take
long at all after you do that you can go
ahead and close out of this you can
click the file Explorer icon over here
just to show the file tree again for
whatever folder that you currently have
Visual Studio code open in I should
mention that I created a folder you can
see I have lesson one as the name of my
folder and there are currently no files
in it whatsoever so my visual studio
code is empty my folder is empty over
here now in Visual Studio code we're
going to open the command palette and to
do that I'm going to press Ctrl shift
and the letter P if you're using a Mac
when I say control you probably need to
press command so either command shift in
the letter P or control shift in the
letter P that will open a command
palette and you can see my Top Choice
says python select interpreter that may
not be your Top Choice so you can just
start by typing the word Python and
seeing all of the different commands
that come up and you could type all of
this out or you could scroll through and
find the select interpreter once you do
that it's going to show the version of
python that you currently have installed
you can see I have python 3.11.2 64-bit
and I'm just going to select that once
I've made that selection I can then open
a terminal window and there's a terminal
menu here at the top when I click that
you can go to new terminal or you can
also just use the shortcut which is what
I usually do a new terminal is Ctrl
shift and the back tick or just control
backtick to open a terminal that may not
be new so if you already had it open say
I could type something here like my name
which won't really amount to anything if
I were to try to run my name for example
that wouldn't work but if I close it and
then press Ctrl and backtick it opens up
the same terminal not a new terminal so
that is the difference control and
backtick opens an existing terminal if
one exists and control shift back tick
opens a new terminal and you can have
more than one terminal if you click this
plus button here you can see now I've
got two terminals open mine says bash
because that is my default terminal
however you might have other choices on
Windows there's Powershell there's a
command prompt I'm using git bash if you
don't have that installed that's okay
you can use a command prompt and now I
have a command prompt terminal window
open and you can see the difference over
here one's named command and one's named
bash so either would work and on Mac or
Linux it could be different for you as
well but now we need to verify our
python installation so on Windows I'm
going to type Pi just P Y dash three and
then dash dash version now that's for
Windows if I'm on Mac or Linux I need to
type Python 3 then dash dash version and
that would work on Mac or Linux and then
you press enter so I'm going to go back
to what I need to type for Windows just
keep that in mind anytime you see me
type Pi on the command line like I am
now if you're on Mac or Linux you need
to type python3 so it could be just a
little different now I'm going to type
dash dash version and press enter and it
gives us the version of python that we
currently have installed I have python
3.11.2 now we can drag this window for a
little more room also so I'll drag this
up to make this command prompt or
terminal because I'm not really using a
command prompt I'm in git bash But
whichever terminal window you have open
you can make bigger by dragging it like
I just did now I'm just going to type Pi
once again on Mac and Linux type python3
instead but now I'll just press enter
with nothing after that and now you can
see we have something different here we
can actually run python commands right
here at this prompt you see the three
arrows this is the python reple and that
stands for read a value weight print
Loop and we can just put in a command
python for example can be a calculator
so I can press two plus two press enter
and it outputs 4. I can also do
something with a string like my name
which I had typed earlier but let's do
this I'll say name equals
Dave and now I'll press enter notice
there's nothing output currently but if
I type name
it's going to Output my name we assigned
the string Dave to a variable called
name and so then when we typed name it
output the string Dave now it's good to
know that we can run commands at the
prompt like this but this is not how
we're usually going to provide commands
to The Interpreter we are going to do
that with files and essentially creating
a file is a bunch of commands put into
one file that we tell python to execute
now python is not a low level language
in a low-level language is more machine
oriented instead Python's a high level
language and it uses an interpreter and
this allows us to write code which is
easier for people to read so in other
words python is more user friendly to
read and to write so for example when I
want to get out of this I'm just going
to type quit and I need to put
parentheses after and press enter and
now we have quit our repel environment
and we're just back to our normal prompt
here now there are several ways to close
this terminal window preview previously
you saw me click the x that works and
then if I wanted to reopen it and still
have this here I could do that with
control and backtick however I could
click the trash can and then that will
get rid of this window and if I were to
open it this stuff wouldn't be here any
longer so I'm just going to click X in
case I want to bring that back up so I
mentioned creating a file and we can do
that a couple of ways in Visual Studio
code one would be to go over here to
this file tree that we see on the left
and click the plus button by the file
icon that would create a new file and
then we could name it I can also just
press Ctrl n for a shortcut and that
starts a new file which is what I'm
going to do now and then I'm going to
say something like greeting
equals and I'll put
hello world because that's something
just traditional that you have to have
any time you're learning a new
programming language and after that then
I'm going to say print and then I'm
going to pass in that greeting variable
that we created above on the previous
line now notice this file is Untitled
and it has a DOT here meaning we haven't
saved this yet so I'm going to press
Ctrl S I could go to the file menu and
from there I could also choose save or
save as I'm just going to do control s
and it's still going to ask me what to
name the file and I'm going to save it
in my lesson one folder so I'm going to
name this hello and then I want it to
end with the dot py extension right now
it says save as type plain text that is
not what I want I want to find the
python extensions here inside of the
file types and make sure I'm saving as
type python which you can see it can
have different types I'm using the dot
py so I'll click save now I have saved
my python file type
hello.py and you can see Visual Studio
code now acknowledges this is a python
file type and it is color-coded part of
the code so the string has a different
color and the command here for print has
a different color the parentheses are
also in a different color so it makes it
a little easier to read the code and now
that we've created this file we can run
this command or commands whatever we
would have in the file we can tell
python to execute in three different
ways one is to go to this play button
that we see over here in the top right
of Visual Studio code now there's a
little carrot here that I'm going to
click it gives us a drop down I'm going
to choose run python file and when I do
that it opens up this terminal window
notice it's named python over here now
it's not the one we had previously named
bash so I just clicked the trash can to
get rid of that but here is what it ran
when we told it to run the file it put
this command and this said exactly where
the python executable is and then after
that we have this other long string here
that says exactly where the Hello dot Pi
file is and then we get the output from
that file that says hello world now when
we were to if we were to run this file
ourselves we would not have to type all
of this although we could copy and paste
this in we can use a shortcut or two for
this one we already know that we can
just call python in windows with py
again Mac and Linux type python3
after that a space and since we're
already in this lesson one directory
that I have or folder you could call I
said directory but it's the same thing
if you've created a folder with a
different name you would be in that
folder so if you're already in that
folder and you see your file over here I
can just type in hello Dot py and now
we're telling python to run that hello
file that will accomplish the same thing
that we saw executed above when we used
the play button up above so now I'm
going to press enter
and we get the same output hello world
also we could go to the file tree and
right click I believe in Mac that would
be a command click and then we scroll
down here and we find run current or run
python file in terminal so I'll select
that and it runs it again just like when
we did the play button so you see these
extra commands so three different ways
to run our python file so
congratulations again on getting started
with python you've created your first
file you've got it all set up on your
computer and we've got much more to
learn ahead remember to keep striving
for Progress over Perfection and a
little progress every day will go a very
long way please give this video a like
if it's helped you and thank you for
watching and subscribing you're helping
my channel grow have a great day and
let's write more code together very soon
関連動画をさらに表示
Какой язык программирования выбрать в 2024 году?
How to set up Python on Visual Studio Code
Tutorial 1- Anaconda Installation and Python Basics
Download and Install Python (3.10.6) and Pycharm | Python Tutorials for Beginners #lec3
Python Tutorial for Beginners 1: Install and Setup for Mac and Windows
#2 Python Tutorial for Beginners | Python Installation | PyCharm
5.0 / 5 (0 votes)