in this python tutorial you're going to learn everything you need to know to
start programming in python if you want to learn python programming for
data science machine learning or web development this python tutorial is the
perfect place to learn python you don't need any prior knowledge in python
or programming in general i'm going to teach you everything from scratch
i'm mosh hamadani and i've taught millions of people how to code through
this channel if you're new here make sure to subscribe as i upload new
videos every
week now let's jump in and get started all right before we get started let me
give you some ideas about what you can do with python that's a very
common question python is a multi-purpose programming language so you
can use it for a variety of different tasks you can use python for machine
learning and ai in fact python is the number one language for machine
learning and data science projects python is also very popular in web
development using python and a framework called django you can build
amazing websites here are five
websites powered with python and django youtube instagram spotify
dropbox and pinterest you can also use python in automation with python
you can save your time and increase your productivity by automating
repetitive tasks so why are you learning python are you learning it for
automation for data science or web development let me know in the
comment section below all right the first thing i want you to do is to head
over to python.org to download the latest version of python so you go to
downloads and select the
latest version of python here in your downloads folder you should see this
package simply double click it you're going to see this python installer if
you're on windows you will see this checkbox over here add python to path
make sure to check it it's really important otherwise you're not going to be
able to follow this tutorial simply click on continue again one more time i
agree with the terms and install the latest version of python now here you
need to enter the username password of your computer
,so let's do that real quick next you need to install a code editor we use a
code editor to write our code and execute it the most popular code editor for
python is pycharm you can get it from jetbrains.com pycharm so on this
page click on download you should see two different editions one is the
professional edition which is commercial and we also have this community
edition which is free and open source so we're going to download the
community edition now in your downloads folder you should have this
package let's double click it
if you're on windows you're going to see an installation wizard so simply click
on the next button until you install pycharm if you're on a mac you need to
drag this pycharm and drop it onto the applications folder now let's open it
the first time you open pycharm you have to configure a few settings we
don't want to spend time on this so over here we're going to click on skip
remaining and set defaults now let's create a new project over here we can
specify the location and the name of our python project so
let's append hello world to this path this is where our python project is going
to be saved so let's click on create in this window you can see the content of
our project so here's our hello world project currently we have only one folder
inside this project that is vn which is short for virtual environment we'll talk
about virtual environments in the future so currently we don't have any
python files inside this project a real application can consist of tens or
hundreds or even thousands of python
files so let's right click on the project name and go to new python file we're
going to call this file up now we can collapse this project window by clicking
on this icon so now we have more space let's write our first python code
we're going to write print all in lowercase then add parentheses then add
quotes either single quotes or double quotes and inside this code we're going
to write hello world so this is what we call a string a string means a string or
sequence of characters in simple words that means
textual data so in python and in many other programming languages
whenever we're dealing with textual data we should always surround our text
with quotes in python we can use single or double quotes now this print you
, see here is a function built into python and we can use it to print a message
on our application window so let me show you how to run this code on the
top we go to the run menu and then select run note that there is a shortcut
associated with this command i always use shortcuts because they increase
my productivity so
let's click on this now select app and over here you can see this little window
this is what we call the terminal window and it shows the output of our
program so here's the hello world message printed in the terminal window
now as you learn more python you will learn how to build applications that
have a graphical user interface that's an advanced topic so for now let's not
worry about it alright now let's talk about variables we use variables to
temporarily store data in a computer's memory for example
we can store the price of a product or someone's name their email their age
and so on let me show you so to declare a variable we start by typing a
name for that variable let's say age then we add an equal sign and then we
type a value let's say 20. so with this we're storing the number 20
somewhere in our computer's memory and we're attaching this age as a
label for that memory location so now we can read the value at this memory
location and print it on the terminal so instead of printing hello world we
want to print
the value of the age variable so i'm going to delete what we have inside
parenthesis and type age note that i'm not adding quotes because if i run
this program we'll see the text h on the terminal we don't want that we want
the value of the age variable so let's remove the quote and print the value of
the age variable now here on the toolbar you can click on this play icon to
run your program or you can use the shortcut that i showed you in the last
video so the shortcut is over here on a mac that's ctrl shift and
r so there you go now you can see the value of the age variable now we can
also change the value of a variable for example on line 2 we can set 8 to 30.
now when we run our program we see 30. so as you can see our program
gets executed from top to bottom so this is how we can declare and use a
variable now let's look at a few more examples so i'm going to declare
start programming in python if you want to learn python programming for
data science machine learning or web development this python tutorial is the
perfect place to learn python you don't need any prior knowledge in python
or programming in general i'm going to teach you everything from scratch
i'm mosh hamadani and i've taught millions of people how to code through
this channel if you're new here make sure to subscribe as i upload new
videos every
week now let's jump in and get started all right before we get started let me
give you some ideas about what you can do with python that's a very
common question python is a multi-purpose programming language so you
can use it for a variety of different tasks you can use python for machine
learning and ai in fact python is the number one language for machine
learning and data science projects python is also very popular in web
development using python and a framework called django you can build
amazing websites here are five
websites powered with python and django youtube instagram spotify
dropbox and pinterest you can also use python in automation with python
you can save your time and increase your productivity by automating
repetitive tasks so why are you learning python are you learning it for
automation for data science or web development let me know in the
comment section below all right the first thing i want you to do is to head
over to python.org to download the latest version of python so you go to
downloads and select the
latest version of python here in your downloads folder you should see this
package simply double click it you're going to see this python installer if
you're on windows you will see this checkbox over here add python to path
make sure to check it it's really important otherwise you're not going to be
able to follow this tutorial simply click on continue again one more time i
agree with the terms and install the latest version of python now here you
need to enter the username password of your computer
,so let's do that real quick next you need to install a code editor we use a
code editor to write our code and execute it the most popular code editor for
python is pycharm you can get it from jetbrains.com pycharm so on this
page click on download you should see two different editions one is the
professional edition which is commercial and we also have this community
edition which is free and open source so we're going to download the
community edition now in your downloads folder you should have this
package let's double click it
if you're on windows you're going to see an installation wizard so simply click
on the next button until you install pycharm if you're on a mac you need to
drag this pycharm and drop it onto the applications folder now let's open it
the first time you open pycharm you have to configure a few settings we
don't want to spend time on this so over here we're going to click on skip
remaining and set defaults now let's create a new project over here we can
specify the location and the name of our python project so
let's append hello world to this path this is where our python project is going
to be saved so let's click on create in this window you can see the content of
our project so here's our hello world project currently we have only one folder
inside this project that is vn which is short for virtual environment we'll talk
about virtual environments in the future so currently we don't have any
python files inside this project a real application can consist of tens or
hundreds or even thousands of python
files so let's right click on the project name and go to new python file we're
going to call this file up now we can collapse this project window by clicking
on this icon so now we have more space let's write our first python code
we're going to write print all in lowercase then add parentheses then add
quotes either single quotes or double quotes and inside this code we're going
to write hello world so this is what we call a string a string means a string or
sequence of characters in simple words that means
textual data so in python and in many other programming languages
whenever we're dealing with textual data we should always surround our text
with quotes in python we can use single or double quotes now this print you
, see here is a function built into python and we can use it to print a message
on our application window so let me show you how to run this code on the
top we go to the run menu and then select run note that there is a shortcut
associated with this command i always use shortcuts because they increase
my productivity so
let's click on this now select app and over here you can see this little window
this is what we call the terminal window and it shows the output of our
program so here's the hello world message printed in the terminal window
now as you learn more python you will learn how to build applications that
have a graphical user interface that's an advanced topic so for now let's not
worry about it alright now let's talk about variables we use variables to
temporarily store data in a computer's memory for example
we can store the price of a product or someone's name their email their age
and so on let me show you so to declare a variable we start by typing a
name for that variable let's say age then we add an equal sign and then we
type a value let's say 20. so with this we're storing the number 20
somewhere in our computer's memory and we're attaching this age as a
label for that memory location so now we can read the value at this memory
location and print it on the terminal so instead of printing hello world we
want to print
the value of the age variable so i'm going to delete what we have inside
parenthesis and type age note that i'm not adding quotes because if i run
this program we'll see the text h on the terminal we don't want that we want
the value of the age variable so let's remove the quote and print the value of
the age variable now here on the toolbar you can click on this play icon to
run your program or you can use the shortcut that i showed you in the last
video so the shortcut is over here on a mac that's ctrl shift and
r so there you go now you can see the value of the age variable now we can
also change the value of a variable for example on line 2 we can set 8 to 30.
now when we run our program we see 30. so as you can see our program
gets executed from top to bottom so this is how we can declare and use a
variable now let's look at a few more examples so i'm going to declare