Python Tutorial for Absolute Beginners #1 - What Are Variables?
CS Dojo
YK is founder of CS Dojo and a former software developer at Google. This is a new
series python Tutorial for absolute beginners and this is my video number 1 : what
are variables ? So in this video i 'm going to go through a number of different
things First of all what is python and what can you , do with it. To install python
on your computer and then set up a development environment. We 're gon na use
something called jupyter notebook throughout this series and then explain how to
use the print function. In this series instead of using a traditional IDE i decided
to use something called jupyter notebook instead of a traditional one. Jupyt
notebook is an environment for writing and testing your program quickly and It 's
actually popular with the scientific community and for data analysis purposes but i
've decided to. use jupiter notebook throughout This series because it 's very
simple and easy to install Jupytter notebook through something called anaconda.
Your first program should be at the URL Localhost colon 8080 8th 8th or something
like that. Once this file is downloaded just open it and then click continue
continue continue. Select Install for me only or install on a specific disk it does
n't matter which one you choose. Then click install and this process will probably
take a while while for you. Once you're all set to launch jupyter you need to
launch Anaconda navigator.
The important thing to note here is that if you Do n't type in the exact set of
characters that you see on the screen it might Not go right so for example if you
forget to close the parentheses and run the Cell you 'll get an error. Instead of
using double quotes you can also use single quotes in python and then you can run
this. Cell and The string more string is printed so you can Also print not just a
string but also a number. A variable can refer to a string as well so if you write
c Equals hello , there has been printed. No double quotes or single quotes around
This character. A variable is more like a name tag than a string and this can
refer. to any value you Want and when you say a equals one you 're saying a refers
to the value one now. When you write b equals two you can assign the value 2 to the
variable b. It's totally possible for two or more variables in Python to point to
the same value in this case 2 and then it's Also possible for you to reassign an
existing variable to another value so if you write b equals 1 after executing this
line of code b equals 2 after this line b refers to two of course but after writing
b equals. After writing b refers to 1 the variable b now refers to The string The
string is The string. you 're , saying the variable c refers to the string. Hello
There once you master that basic concept you 'll be able to move on to a slightly
more advanced topic
A quick practice problem to work on in order to solidify your understanding of
variables and to do that Go , back to the previous tab of jupyter notebook the
navigation Menu and if you already , close the tab Just open localhost colon 8080
eight eight or just relaunched jupytter notebook. Change it to swapping two
variables to swap the values within. these two variables with Each other. V1 equals
v2 and then v2 equals v1 and we 're done but actually this solution is wrong. V1
refers to what v2 refers to of course , which is second string and then we 'll just
need to swap them together. So v1 will be equal to temp 2 , which refers to second
string so v1 now refers to temp 1 which of course first string. v2 will now refer
to first string after these lines of code. na create a. new variable called temp
which refers to whatever v1 refers to which Is first string. v1 at this point is
second string and then we 'll set v1 to be v2. i 'll then set v2 to whatever
Temporary first - which is first string - so we should be able to print second
string ? We do okay. download the. files i created throughout this video just go to
CS Dojo
YK is founder of CS Dojo and a former software developer at Google. This is a new
series python Tutorial for absolute beginners and this is my video number 1 : what
are variables ? So in this video i 'm going to go through a number of different
things First of all what is python and what can you , do with it. To install python
on your computer and then set up a development environment. We 're gon na use
something called jupyter notebook throughout this series and then explain how to
use the print function. In this series instead of using a traditional IDE i decided
to use something called jupyter notebook instead of a traditional one. Jupyt
notebook is an environment for writing and testing your program quickly and It 's
actually popular with the scientific community and for data analysis purposes but i
've decided to. use jupiter notebook throughout This series because it 's very
simple and easy to install Jupytter notebook through something called anaconda.
Your first program should be at the URL Localhost colon 8080 8th 8th or something
like that. Once this file is downloaded just open it and then click continue
continue continue. Select Install for me only or install on a specific disk it does
n't matter which one you choose. Then click install and this process will probably
take a while while for you. Once you're all set to launch jupyter you need to
launch Anaconda navigator.
The important thing to note here is that if you Do n't type in the exact set of
characters that you see on the screen it might Not go right so for example if you
forget to close the parentheses and run the Cell you 'll get an error. Instead of
using double quotes you can also use single quotes in python and then you can run
this. Cell and The string more string is printed so you can Also print not just a
string but also a number. A variable can refer to a string as well so if you write
c Equals hello , there has been printed. No double quotes or single quotes around
This character. A variable is more like a name tag than a string and this can
refer. to any value you Want and when you say a equals one you 're saying a refers
to the value one now. When you write b equals two you can assign the value 2 to the
variable b. It's totally possible for two or more variables in Python to point to
the same value in this case 2 and then it's Also possible for you to reassign an
existing variable to another value so if you write b equals 1 after executing this
line of code b equals 2 after this line b refers to two of course but after writing
b equals. After writing b refers to 1 the variable b now refers to The string The
string is The string. you 're , saying the variable c refers to the string. Hello
There once you master that basic concept you 'll be able to move on to a slightly
more advanced topic
A quick practice problem to work on in order to solidify your understanding of
variables and to do that Go , back to the previous tab of jupyter notebook the
navigation Menu and if you already , close the tab Just open localhost colon 8080
eight eight or just relaunched jupytter notebook. Change it to swapping two
variables to swap the values within. these two variables with Each other. V1 equals
v2 and then v2 equals v1 and we 're done but actually this solution is wrong. V1
refers to what v2 refers to of course , which is second string and then we 'll just
need to swap them together. So v1 will be equal to temp 2 , which refers to second
string so v1 now refers to temp 1 which of course first string. v2 will now refer
to first string after these lines of code. na create a. new variable called temp
which refers to whatever v1 refers to which Is first string. v1 at this point is
second string and then we 'll set v1 to be v2. i 'll then set v2 to whatever
Temporary first - which is first string - so we should be able to print second
string ? We do okay. download the. files i created throughout this video just go to