Learn to Code Special! | 30% off ALL ACCESS to One Month ๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰


What is Python? | Python 2 vs Python 3

Week 1: A Brief Introduction to Python ยท Lesson 4 ยท

We look at the history of Python and explore the differences between Python 2 and Python 3. For the course, we use (and recommend) Python 3. Python 2 is legacy, Python 3 is the future and so we recommend learning the latter. The two versions share similarities, so if you learn Python 3, you will still be able to read and understand any legacy Python 2 code you might come upon.

Python 2 vs. Python 3

In this class, we're going to use Python 3. In short, Python 2 is a legacy language (meaning its old!), and Python 3 is the future.

Read "Python 2 vs Python 3" to learn the difference. 

- So what is Python?
And this is the last thing I wanna talk about
before we actually dive into coding,
so bear with me for a few more minutes.
This is worthy to know.
Python was created in 1991
by this dude named Guido Van Rossum.
Now we see Guido is wearing a Google shirt
because actually Google hired him
after he developed Python
and they basically decided that they wanted
to have a monopoly on Python a little bit.
So they hired some of the best Python developers,
almost all of them in the early days,
and as a result anyone who wanted to learn Python
and wanted to learn it with the best developers,
they would go to Google.
So that was a pretty clever strategy
that Google came up with.
He left them recently, I believe he joined Dropbox
and he's been, you know, working
on a lot of stuff since then.
In the Python community,
Guido is known as the Benevolent Dictator for Life
because he is so awesome.
And it's actually named after Monty Python, not the snake,
as, you know, some people erroneously believe.
Now if you wonder what kind of companies use Python?
The answer is all of them, like, literally.
It's almost ridiculous to create a slide about this
because it's almost every company out there.
Dropbox, Google, Pinterest, Washington Post.
These are some of the companies
that heavily use Python,
but the reason why almost all of them use Python
is because regardless of what your actual application
is built in, that could be Ruby,
that could be C, or whatever,
Python has so many uses,
especially around analytics and data,
that if there's anyone in your company
who does data science or analytics
or regressions, or things like that,
they're most likely using Python,
and most of these companies use Python all over the place,
so it's a very, very useful language to know.
Now in this class, we're gonna be using Python 3.
Python 3 came out in 2008.
Yeah, that's nine years ago or more even.
But for some reason,
a lot of people still use Python 2.
It's just crazy, and why is that?
It's because once you build something in a language,
and a lot of companies built things in Python 2,
well, when Python upgraded to Python 3,
it wasn't so easy to upgrade all your code
from Python 2 to Python 3,
and that upgrade kinda broke some stuff,
so a lot of companies just stuck with Python 2 for a while
until it made sense to upgrade.
For example, if you look into the forums of Codecademy,
if you see what version of Python they use,
you'll see they teach Python 2.7,
so it's a version of Python 2,
even though it's like nine years old.
There's even this website called Python 3 Readiness,
or py3readiness.org,
often you'll see Python abbreviated to py,
and it shows you the 360 most popular packages.
So these are libraries
and bits of code that other people have written in Python
that you can download,
we'll go more into packages later,
but they can be very popular.
Some people write packages for data science
and for image recognition and for machine learning
and for building web applications
and all of these things,
one of the things that makes Python so convenient
is all of these packages people have already written
that make you be able to be a lot faster
when you're building something.
And this website shows that by this point,
most of the popular packages have been upgraded
from Python 2 to Python 3.
So we're getting there,
and almost everyone these days,
when they're starting a new project, use Python 3.
Now about the only difference you really need to know
about Python 2 versus 3 is this one little change.
If you were printing Winter is coming in Python 2,
you would use the thing on the left.
On Python 3, use the one on the right.
And yeah, if you're, you know, paying attention,
you'll notice that the difference
is that Python 3 uses parentheses.
Now in fact, Python 2, you can use parentheses,
it's optional, whereas in Python 3, it's mandatory.
And this is a major breaking change
'cause the code in Python 2 would leave them out
and then when you upgraded to 3, it wouldn't work,
and so a lot of people didn't upgrade for a while.
Notice a few other small subtle differences,
but honestly, as far as we're concerned in this class,
none of those really matter for us.
And, you know, I may point out here or there
specifically when there's a difference for you,
but, just so that you know
what the difference between 2 and 3 is,
and why some people still use 2,
I think at this point it's pretty safe to bet
if you're gonna be starting out,
you might as well start with the latest, the greatest,
and you'll have access to the most modern,
up-to-date stuff by learning with Python 3.
So be aware that when you're looking at code samples online,
while you're working with some libraries,
it's always possible that it was originally written
for Python 2.
And one of the biggest ways you can check this
is if you try to do the print without the parentheses,
you'll get an error.
And that's really all I have to say about that.
It gives us a little bit of a background of the Python.
And now I think that we should do some basic set up,
get our computers installed with Python,
I'll walk you through that process,
and then go into our first Python script.
Are you ready?