Which One Should I Learn As A Beginner: Python 2 Or Python 3?

In the past, there was a bit of a debate in the coding community about which Python version was the best one to learn: Python 2 vs Python 3 (or, specifically, Python 2.7 vs 3.5).

Now, in 2018, it's more of a no-brainer: Python 3 is the clear winner for new learners or those wanting to update tudemheir skills. Here, we'll cover why Python 3 is better, and why companies have been moving from Python 2 to 3 en masse.

That said, there are still some situations where picking up Python 2 might be advantageous. Or you may just want to learn a little of the history and the differences between Python 2 and 3 for curiosity's sake.

So, without further ado, let's take a look at some of the major differences between Python 2 vs Python 3-plus where to learn Python 3 programming as a beginner.

TABLE OF CONTENTS

History of Python 2 vs 3

What are the main Python 2 vs 3 2018 differences?

Why companies are moving from Python 2 to 3?

As a beginner, should I learn Python 2 or 3 in 2018?

When it makes sense to learn Python 2?

Where to start learning Python 3?

Conclusion

A LITTLE HISTORY OF PYTHON 2 VS 3

Let's begin with a brief timeline of Python 2 vs 3 usages.

Python 2.0 was first released in 2000. Its latest version, 2.7, was released in 2010.

Python 3.0 was released in 2008. Its newest version, 3.6, was released in 2016, and version 3.7 is currently in development.

Although Python 2.7 is still widely used, Python 3 adoption is growing quickly. In 2016, 71.9% of projects used Python 2.7, but by 2017, it had fallen to 63.7%. This signals that the programming community is turning to Python 3-albeit gradually-when developing real-world applications.

In Python 2, if you write a number without any digits after the decimal point, it rounds your calculation down to the nearest whole number.

For example, if you're trying to perform the calculation 5 divided by 2, and you type 5 / 2, the result will be 2 due to rounding. You would have to write it as 5.0 / 2.0 to get the exact answer of 2.5.

However, in Python 3, the expression 5 / 2 will return the expected result of 2.5 without having to worry about adding those extra zeroes.

This is one example of how Python 3 syntax can be more intuitive, making it easier for newcomers to learn Python programming.

5. THE TWO VERSIONS HAVE DIFFERENT PRINT STATEMENT SYNTAXES

This is only a syntactical difference-and some may consider it trivial-so it doesn't affect the functionality of Python. That said, it is still a big and visible difference you should know about.

Each newer version of Python continues to get faster runtime. Meanwhile, nobody's currently working to make Python 2.7 work faster.

Community support is better with Python 3.

FACEBOOK

Facebook is currently in the process of upgrading their infrastructure and handlers from Python 2 to Python 3.4.

Why they use it:

According to RealPython, "The ease of using Python libraries means that the production engineers don't have to write or maintain as much code, allowing them to focus on getting improvements live. It also ensures that the infrastructure of Facebook is able to scale efficiently."

Some of the changes made in Python 3 have actually made it easier for beginners to understand, so it's the best way to learn Python for the first time.

This is the best way to future-proof yourself as more and more programmers pursue Python 3 adoption. Keep in mind that Python 2.7 will no longer be supported after 2020, so dedicating effort to learning it at this point won't make sense for most folks. I say "most" because there are a few types of people who might need it.

WHEN IT MAKES SENSE TO LEARN PYTHON 2

Here are some situations where you might need to know Python 2:

If you want to become a DevOps engineer and work with configuration management tools like Fabric or Ansible, you might have to work with both Python 2 and 3 (because parts of these libraries don't have full Python 3 support).

If your company has legacy code written in Python 2, you'll need to learn to work with that.

If you have a project that depends on certain third-party software or libraries that can't be ported to Python 3, you'll have no choice but to use Python 2 for it.

Luckily, whichever version you start with, it will be fairly easy to transfer your knowledge to the other if needed.

WHERE TO START LEARNING PYTHON 3?

So, if you've decided to learn Python 3, the next question is "Where do I learn python for beginners?" Here are three Python course options to consider.

What the course covers: Covers core programming tools such as functions and loops, as well as variables to store, retrieve, and calculate information.

Why pick this particular course: 4.8-star rating (out of 38K+ reviews); this course is part of a Coursera specialization so you can continue on to more advanced topics if you want

Course facts:

Course Name: Programming for Everybody (Getting Started with Python)

Platform: Coursera

Course URL: https://learntocodewith.me/getting-started-with-python

Instructed by: Charles Severance

Price: 7-day free trial (and then $49 per month)

Skill level: Beginner

EDX: INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING USING PYTHON

What the course covers: Python syntax, simple algorithms, how to think computationally, data structures, and more

Course facts:

Course Name: Introduction to Computer Science and Programming Using Python

Platform: edX

Course URL: https://learntocodewith.me/introduction-to-python

Instructed by: John Guttag, Eric Grimson, and Ana Bell

Price: Free

Skill level: Beginner

Why pick this particular course: Taught by MIT professors; "designed to help people with no prior exposure to computer science or programming learn to think computationally and write programs to tackle useful problems"

CONCLUSION

When it comes to Python 2 vs 3 in 2018, Python 3 is the clear winner. Since Python 2 is being phased out by 2020, mass Python 3 adoption is the clear direction of the future.

For beginners, starting out with Python and especially Python 3-is a great way to learn to programme quickly. It's a diverse and intuitive language and tons of awesome companies like Google, NASA, Facebook, and Spotify are using it!

Plus, the average yearly salary for Python developers comes in at $92,000 per year, so if you learn Python 3, you might find your career prospects looking brighter than ever.

Try out one of the online Python courses above to start learning Python programming today!