Learning Python Programming — Everything You Should Know

365 Data Science
365 Data Science
Published in
20 min readOct 10, 2019
credit: 365 Data Science

Everybody loves Python. Well, not literally everybody. Let’s face it — the baby-boomer generation will probably scream in terror, thinking it’s the self-indulgent predatory snake we have in mind. This little disclaimer aside, if you’re aiming to start a career in data science, we’re pretty sure Python already holds a special place in your heart. It’s intuitive and easy to run on any platform, and it has tons of amazing libraries and tools. Python also provides great support when it comes to deep learning algorithms in comparison with other programming languages. Plus, it has a huge community base of data scientists and developers that continuously improve the language. In fact, there’s so much more to say about Python programming — applications, job outlook, IDEs, libraries, frameworks, where to start, how to start…, that we actually had to dedicate an all-encompassing, in-depth article to it.

So, welcome to our complete overview of the Python programming language!

We split the article into two sections. The first one is for those of you who don’t know what Python is or wonder whether to start learning it. The second section contains information and practical tips you can apply once you’ve decided to start learning Python.

To navigate the guide, you can use the Contents below. You may decide to jump to the section of your interest or read the whole article through and through. Either way, you’ll gain some invaluable insights.

We hope you’ll find this Python guide helpful and that there will be something beneficial for everyone. Enjoy!

Contents

  1. Python Overview
  • What is Python
  • What are the applications of Python
  • Why learn Python
  • Python vs other languages
  • Is Python difficult to learn
  • Job outlook

2. Getting Started with Python

  • Which Python version to learn
  • How to install Python
  • Which are the best IDEs for Python development
  • Which are the top Python Libraries and Frameworks
  • Where to start
  • Practice makes perfect

1. Python Overview

In this section, we’re going to cover the origins of Python and what we use it for. We’ll also give you the main reasons why it is one of the best programming languages to learn.

1.1. What is Python?

Python is an open source, cross-platform, general purpose programming language. As far as programming languages are concerned, it’s neither new, nor it is too old. Its development started in the late 80s and it was first released to the public in 1991. The Python language creator, Guido van Rossum, had a clear vision for it: make it as simple to understand as plain English. In retrospect, this might have been a little too optimistic. Nonetheless, language aims to emphasize readability and the use of significant whitespace. In other words, it strives to be as close to the human language as possible. Now, what about the name Python?

You might think, as many do, that the name originates from the dietary-challenged snake. You’d be wrong. It turns out Rossum (Python’s creator) is a big fan of British comedy… and was reading scripts from Monty Python’s Flying Circus, while implementing Python. So, the name is a tribute to the great English comedy makers.

Now, if this isn’t motivational enough as to why you should like Python and its creator, this next section answers an important question: What are the applications of Python?

1.2. What are the Applications of Python?

Python has been growing in popularity over the last few years and is now widely used in all kinds of applications. It’s even often referred to as “the best programming language to learn”. Python is used to develop video players like YouTube, power apps like Instagram, test microchips at Intel, run a search engine at Google, and even power transactions on the New York Stock Exchange (NYSE). And you know a programming language is very powerful when it’s maintaining a stock exchange system. In fact, NASA also uses Python when they are programming their equipment and space machinery. Well, isn’t that something? Let’s review some of these applications further.

Python for Data Science

Python experienced a recent surge in popularity across various industries mainly because of its data science libraries.

Both in business and academia, Python finds a wide range of applications for data analysis. It is the language of choice for a large portion of the data science community. Why? Because of the various tools which make it easy to work with huge datasets and gain significant insights.

Python libraries, such as NumPy and Pandas are extensively used in the collection, processing, and cleansing of data sets, as well as in applying mathematical algorithms for the benefit of users. Another aspect that makes Python a great tool for data scientists is the robust visualizations that come with Matplotlib and Seaborn.

Python for Machine Learning

If you haven’t heard of Machine Learning (ML) before, here’s a quick introduction. ML refers to the ability of a computer to “learn” from training data (fitting a model to the input) in order to make predictions (such as, how likely it is for a customer to buy this product, based on data about their past purchases). It is widely employed in “smart” algorithms (where it uses large datasets) and by many companies.

Indeed, companies have plenty of good reasons for using Python.

Its libraries, such as Scikit-learn, TensorFlow, and NLTK are widely used for the prediction of trends like customer satisfaction, projected values of stocks, etc. Speaking оf libraries, TensorFlow, in particular, has a very interesting story. Google developed it for inhouse use, but they released it as an open-source library in 2015. But we’ll get back to it in section 2.4 where we talk more about Python libraries.

Given the growing importance of machine learning and artificial intelligence nowadays, this side of Python will definitely improve even more.

Python for Web development

HTTP programming (or, as we more commonly call it, web development) isn’t just done with JavaScript anymore. In fact, Python plays a major part in it, too. So, in this section, we’ll introduce you to a main Python framework called Django. In addition, we’ll see some of the major companies which are using Django for their web services.

Django is a full-stack web framework. Now, what does that mean exactly? Full-stack frameworks provide you with everything you need to build a complete web application. That includes web serving, database management, and even HTML generation. So, it’s no surprise that Django is the foundation for sites and services like The Guardian, New York Times, Instagram, and Pinterest. Looks like, if you’re building large and complex web applications, Django is the way to go.

But what if you want to create simple web applications?

Let us sneak in another option for creating web content using Python — Flask. Flask is a micro and lightweight web framework. This means it is more intuitive and easier to use. If you want to accomplish more complex tasks you might require a third-party framework. But consider this: in 2018, Flask surpassed Django by 2%, with 47% of users opting for Flask, and 45% for Django. This goes to show that the web development industry has been moving towards smaller frameworks, microservices, and “serverless” platforms. And it just might be the perfect time for you to consider joining in on the effort.

Python for game development

We won’t sugarcoat it, this is where Python is lacking with respect to the competition. Although it has libraries for game development, such as PyGame and PyOpenGL, they often prove insufficient to provide enough functionality. Although it’s generally good for creating 2D games, game developers consider it slow in comparison to compiled languages, such as C# and C++. Furthermore, it’s probably not the best choice graphics-wise, and it doesn’t offer rich development tools or an editor. That, coupled with the fact that Python is a high-level, interpreted language, makes it a not-so-attractive option for game developers.

Nevertheless, Python is extremely helpful in prototyping thanks to the fast speed of writing code in it. Essentially, when deciding whether to invest time and resources in developing a game, it’s useful to build a prototype — a proof of concept. And that’s where Python comes into play, as it’s able to produce a simple 2D working prototype much faster than other languages.

In addition, Python has an important role to play in the online gaming community. Notable examples of games developed with its help are Civilization IV (uses Python for logic and server controls), Eve Online (uses Stackless Python) and World of Tanks (uses Python for some of its internal logic and scripting). Finally, Snakeworlds — a 3D snake game that puts the famous game classic on spheres/ globes. It is written entirely with Python-Ogre.

1.3. Why learn Python?

Okay, this is where we really get in the thick of things. We’re about to start reviewing a lot of the core aspects of Python, discussing advantages and disadvantages, and comparing it to other programming languages. If you’re eager for some in-depth knowledge about Python features, you’ve come to the right section.

Before we start, let’s first take a look at an important, yet often misunderstood distinction: coding is not programming. Most people use these terms interchangeably and, frankly, it is convenient to do so. But explaining the concepts behind them can help create a more beneficial attitude of beginners towards programming.

So, the difference between coding and programming is, in simple terms, the same as the difference between coming up with a story for a novel and writing it down in a book. Let’s elaborate. If you want to write a novel, asking yourself how you would write it in English should not be the first step. Your focus should lie on creating the story with all its elements. Only then you can write it out neatly in whatever language you want.

The same principle applies to programming — it is a two-stage process.

First, you are presented with a problem (let’s say, you have to find the shortest path between cities).

Then you have to come up with steps that will take you to the right answer in every initial graph configuration of those cities (we call this an algorithm). This is the most important stage in programming, and it is (mostly) independent from the language in use. But once you have that down, you can start to communicate the instructions to the computer via a programming language. That is the coding stage. Learning to code in a specific language is not enough, by itself, to become a good programmer. When learning programming for the first time, you should concentrate on the techniques used to solve a problem, not on the language per se.

Having said that, different languages can definitely accelerate or slow down the learning process. We believe that Python is one of the best languages for a beginner to start programming in. Let’s see why:

Python is an open-source language, meaning it’s free to use and everyone can contribute to the writing and maintenance of its code and libraries. Indeed, a lot of people, and even companies, have dedicated time and effort to expand and perfect Python. And that’s a big part of what makes the language so attractive for the community.

Furthermore, Python is a high-level and general-purpose language. High-level implies it is far away from 0s and 1s and, therefore, closer to human language. So, it follows that you don’t have to worry about memory management, and deleting objects (among other issues). And that allows you to focus entirely on solving the programming problem. This makes Python ideal for people who’ve never studied programming before, as it can greatly improve their learning experience.

Finally, general purpose indicates that Python is very versatile. As we mentioned above, we can use it for web and software development, as well as for network programming. On top of that, data science and machine learning, in particular, are areas where it increasingly finds an application. So, it doesn’t come as a surprise that major companies such as Facebook, Quora, Twitter, Spotify, and Netflix use Python a lot. Now, while these websites and platforms are not written in Python, many supporting processes, especially those related to analytics, are performed with it.

Overall, Python has been steadily growing in popularity among developers. It really seems to be beloved by the community, both by front and back-end users. And with its wide variety of functionalities, it’s not just the major companies that are using it. Across the board, the IT industry is incorporating Python to develop various products.

What are the advantages and disadvantages of Python?

So, what are the key aspects of this programming language that make it so attractive?

Pros:

  • Easy to learn — few keywords, simple structure, and a clearly defined syntax. This allows the student to pick up the language quickly.
  • Easy to read — Python code is more clearly defined due to the extensive use of whitespace.
  • Productivity — Python code can be considerably faster to write.
  • Interactive mode — support for an interactive mode that allows interactive testing and debugging of snippets of code.
  • Broad standard library — Python is famous for being the “batteries are included” language. There are over 300 standard library modules that contain classes for a wide variety of programming tasks.
  • Cross-platform — Python works equally well on different OS platforms like Windows, Linux, Mac OSX, etc. Hence its applications can be easily ported across OS platforms.
  • Extendable — You can add low-level modules to the Python interpreter. These modules enable programmers to add to or customize their tools to be more efficient.
  • Embeddable — Python is embeddable as well. You can put your code in the source code of a different language, such as C++.
  • Extensive collection of support libraries — there are numerous libraries for Python that add a lot of functionality to the language.

Cons:

  • Speed limitations — Python is interpreted and that results in slow execution of the code. This, however, isn’t a problem, unless speed is the focal point of the project. In other words, unless high speed is a requirement, the benefits Python offers are enough to outweigh its limitations.
  • Weak on mobile — although it has made its presence on many desktop and server platforms, it is seen as a weak language for mobile computing. This is the reason why very few mobile applications use it.
  • Difficulty in using other languages — Python supporters become so accustomed to its features and its extensive libraries that they face problems in learning or working with other programming languages. Very often, Python experts may see the declaring of variable types and the syntactic requirements of adding curly braces or semicolons as an onerous task.

Static and dynamic typing

In explaining the characteristics of Python, we can’t forget to mention that it’s a dynamically typed language. In short, variables in Python don’t have a predefined type (such as an integer or a string of characters). Instead, the type of a variable is determined dynamically as the program is running. For instance, if at one point we assign the value 10 to the variable A, Python automatically determines that this variable is of the type int (integer). If, later, we update it to 10.0 it will now be a float (a real number).

In contrast, in a statically typed language, like C++, the type of variable is written in the code itself. So, if you want to use A as an integer, you write “int A”. Now, we can assign only integer values to A. If you try to assign a non-integer value to A, the program would return an error.

Of course, both concepts have their advantages and disadvantages. A dynamically typed language is easier to get into for a complete beginner. However, because no one knows the type of variables before runtime, you may get unexpected errors that are hard to track.

But let’s escape these somewhat abstract comparisons and see how Python measures against other popular programming languages.

1.4. Python vs other languages

In this section, we compare Python to other programming languages: R, C++, and Java. Once you’ve read it, you’ll be able to decide which programming language best suits your practical needs.

Python vs R

Python is a script language. It is very powerful, in the sense that, with just a few lines of code you can execute a wide range of actions. You can read, analyze, visualize and even predict on huge datasets, and all that would require just several lines of code.

As it happens, R is also a script language. So how do the two compare? While both have advantages and disadvantages, in the last few years, Python has been the dominant language programmers use. The reasons for that? Well, there are several.

First, although both languages are free and open source, we use R is mainly for statistical analysis (and was, in fact, developed by statisticians). Python, in contrast, is a general-purpose language ( that’s an important feature of the language and bears repeating).

General purpose implies that it is suitable for all types of needs; not only data science and machine learning, but also pre-processing, web programming, and just about anything you can think of.

Another advantage point for Python is that it is high-level. Loosely explained, it has an easy syntax which is close to logical human language, and which is later translated into lower-level languages (like C) or even 0s and 1s. For example, the NumPy package actually goes through the programming language C. That explains why it is so fast.

Let’s mention one final minor thing about R. The graphics in R aren’t the best. But this is an understatement. By a lot. In fact, the graphics are so bad, that R launched R shiny, which was specially designed to counter that problem. We like Shiny, it’s very pretty. That said, although the graphics in Python can be lacking in some instances as well, it recently made an improvement on that front. Seaborn, which is used on top of matplotlib, definitely made the graphics look better than before.

Python vs Java and C++

Now, we emphasized the fact that Python is a script language. While that is true, it doesn’t give us the full picture.

Although a lot of people mainly use Python to run scripts, it also has object-oriented capabilities like C++ and Java. That said, we find that learning programming with Python is considerably easier than with the other two.

Why, I hear the seasoned C++ programmer yell behind the screen? We know you learned programming the hard way and are super happy with it because everything runs super-fast and there aren’t as many memory leaks anymore. And, as long as you know exactly what you’re doing, the code is running, right? (Yep, the author of this article likes C++, too.)

Well, allow us to play devil’s advocate and consider that there might be an easier and more intuitive way to learn the basics of programming.

Consider first of all: Java. The first language for many programmers.

Java has objects and classes, which are concepts difficult to understand for beginners. From personal experience, it could involve a long summer of your dad shouting, “What is the difference between a class and an object?!”, and you trying to figure out what the right answer is. For the record, the answer is — an object is an instance of the class. Did that make things clearer? Yeah, that’s what we thought. It takes some time to understand these concepts. And writing and running your code in Java might take you a bit longer if you’re a beginner. So that’s Java in a nutshell (a very small nutshell indeed, but you get the idea).

How about C++, the ‘real’ programmers’ language?

Its motto is “you get what you pay for” (but maybe don’t quote us on that one). In C++ you’re responsible for handling the memory, i.e. the creation and removal of objects. What’s more, the way you access those objects in memory is through pointers, which can have their own pointers, which can, in turn, have their own… you get the point( er). C++ is also not very beginner-friendly.

Let’s compare these with Python programming. But, like, very simple programming. (Imagine) you’re a complete novice and want to write your first program. For every programmer, no matter what the language, this means writing your first “Hello, World”.

So, this is how the code looks in Java:

And here it is in C++ :

Now, let’s look at Python:

Once you’ve set up the environment and have opened a script file, writing “hello world” in Python requires just a simple print() function and your text. And in Python 2 you don’t even need the brackets! It really doesn’t get any simpler than that. This is the readability factor we talked about in the beginning. And it’s also the reason why we prefer Python to other programming languages. By the way, if you’re finding this analysis useful, consider sharing the article with your other coder friends. Python’s community is one of the reasons it’s awesome, so let’s help make it bigger.

1.5. Is Python difficult to learn?

The short answer: it depends. But this isn’t the answer you were hoping for, right? Don’t worry, we’ll explain everything you need to know before you begin learning Python. Starting with…

How long to learn Python?

For a complete novice learning how to program in Python well takes about 3 months of relatively consistent study (based on our own estimate).

However, if you are planning to use Python for data science, i.e., data analytics or machine learning, the timeline is actually shorter. Because data science requires very specific use of the language, it should take between a month and two to understand the fundamentals. Full disclosure, we’re basing this on the rate our students are completing our own data science training. The 365 Data Science Program takes about 200 hours to complete. Among other topics, it includes the fundamentals of mathematics, statistics, and Python. It also introduces more advanced topics, such as using sklearn, numpy and pandas for machine learning and covers deep learning with TensorFlow (versions 1 and 2) library for neural networks. So, if you’re truly committed and devote five hours of your day to learning, it should take you about 1 month to learn the main principles for data science analysis in Python.

That said, the time it will take you to become proficient in Python, or any programming language, depends on… well, you.

Different people learn at different rates. Your ability to learn Python will also depend on your background in programming. If you’re already skilled in a programming language, becoming acquainted with Python would involve mostly getting used to the different libraries.

But what if you’ve never programmed before? Well, this might actually be an advantage. In our opinion, it is considerably easier to learn the basics of programming with a language like Python.

1.6. Job Outlook

What’s the Python job outlook?

To say that the Python job outlook is positive will be an understatement. As its popularity is rising, the demand for Python as a preferred skill by employers is soaring sky-high.

In fact, the Institute of Electrical and Electronics Engineers ( IEEE — the world’s largest technical professional organization for the advancement of technology) deemed Python “the big Kahuna” of 2019, listing it at number 1 in its annual interactive ranking of the Top 10 Programming Languages.

But Python is more than just a fan favorite — it’s what CEOs want.

According to a StackOverFlow Developer Survey (taken by 90,000 developers worldwide), it is the fastest-growing major programming language in 2019. Python (41.7%) even edged out Java (41.1%) in the overall ranking and remains the most wanted language by developers (25.7%) for the third year in a row! The survey also reveals that developers using Python are paid more ($60,000-$70,000) compared to their counterparts using languages like C, C++, and Java ($50,000 — $60,000).

How does that translate into Python job opportunities?

Let’s dig into the numbers.

Are Python jobs high in demand?

Absolutely. Python is the language associated with the highest salaries worldwide with a median salary of $63,000. Moreover, The Data Science Jobs Report 2019 points out that general-purpose languages are extensively used in data science jobs. The report is based on data from the largest job site in the U.S. — Indeed.com. They counted the number of job postings that emphasize on certain software proficiency as a requirement and discovered that Python is firmly at the top with 27,374 jobs, followed by SQL with 25,877. For the record, Java and C are way down the list with jobs in the 17,000’s and 13,000’s, respectively. What about year-on-year growth? Python is, once again, the undisputed champion with 97% growth from 2017 to present (2019).

In terms of UK prospects, the job market is pretty healthy there, too.

As reported by ITJobsWatch summary statistics, there have been 16,004 permanent jobs citing Python for the past 6 months with a median annual salary of £61,242. And that marks an 11.16% pay rise compared to the same period in 2017.

But what do employers say themselves? According to the Data Science Skills Study 2019, Python is the number 1 programming language in organizations that use advanced analytics for their business and product development. The survey’s responses came from middle management, senior management, and executive-level management from 500 companies.

So, it seems that Python is very close to dominance in terms of what employers are searching for. That said, it’s high time we looked into the most coveted Python job roles out there.

Which are the career paths in Python you can take?

Proficiency in Python is one of the indispensable skills in the tech and data science career fields. Here are some of the most lucrative career paths for Python specialists to follow.

Python Developer

The most obvious choice for anyone who’s proficient in Python. Python developers use it for all sorts of tasks, ranging from building websites and optimizing data algorithms to finding data analytics solutions and carrying out security and data protection. Not to mention this programming language is perfect for writing testable, reusable, and incredibly efficient code.

Machine Learning Engineer

Expertise in Python is one of the key requirements for Machine Learning engineers. Machine learning involves continuous data processing and Python’s great library ecosystem is undoubtedly up for the challenge. No wonder Python libraries are preferred by Machine Learning engineers for accessing, and transforming data, as well as for handling basic ML algorithms like clustering, regressions, and classification.

Data Scientist

Python is hands-on the preferred language for statistical modeling. Around 68% of data scientists state that it is their favorite programing language (in comparison to 44% last year). And if you’ve been paying attention so far, Python is also essential when it comes to machine learning.

Data Analyst

Python is one of the best languages for handling huge amounts of data, cleaning it, and processing it for analysis, which is what the data analyst does a lot of. And Python helps them do all that fast, compared to other more complex tools. Data analysts also use Python and its packages to integrate their data analysis tasks with web apps or incorporate a statistics code into a production database.

Python is not an absolute must for BI analysts. However, it becomes more and more recommended in the business intelligence domain. BI analysts are multitaskers to the core. As such, they can use Python for various business intelligence tasks. They can use it to prepare the data by importing it into database programs, cleaning, and standardizing it. In addition, BI analysts can explore the data by creating a Pandas DataFrame from a query, making a data quality report, generating summary statistics, and creating charts. Finally, Python assists BI analysts with both data analysis and analytics, so they can visualize and report their insights to drive informed business decisions.

BI Analyst

Python is not an absolute must for BI analysts. However, it becomes more and more recommended in the business intelligence domain. BI analysts are multitaskers to the core. As such, they can use Python for various business intelligence tasks. They can use it to prepare the data by importing it into database programs, cleaning, and standardizing it. In addition, BI analysts can explore the data by creating a Pandas DataFrame from a query, making a data quality report, generating summary statistics, and creating charts. Finally, Python assists BI analysts with both data analysis and analytics, so they can visualize and report their insights to drive informed business decisions.

Data Engineer

Python’s rich libraries help data engineers access databases and storage technologies. Furthermore, data engineers use it to code an ETL framework, as well as for API interaction and automation. Overall, Python is a powerful and versatile tool that allows data engineers to solve problems quickly and efficiently.

Data Architect

Data architects develop advanced Python scripting to analyze, cleanse, and transform large data sets of data and prepare it for use in business intelligence, analytics, and financial modeling functions.

Author’s note: Python is crucial to land a job in data science. However, it’s just one of the skills you need to acquire if you want to make it in the field. That said if you want to learn what it takes to start a data science career, check out our Ultimate Data Science Career Guide.

What are the top industries that use Python?

Here are the top 10 Industries that use Python, according to ActiveState’s Top 10 Python Use Cases:

  • Insurance;
  • Retail banking;
  • Aerospace;
  • Finance;
  • Business services;
  • Hardware;
  • Healthcare;
  • Consulting services;
  • Infotech;
  • Software.

Now, if you have already decided to begin learning Python but don’t know where to start, then click here to continue reading.

And, in the spirit of the open-source programming language, if you liked this article and you found it helpful, take a second and share it, so that others can learn and progress, too!

Originally published at https://365datascience.com on October 10, 2019.

--

--

365 Data Science
365 Data Science

Become an in-demand #DataScience professional TODAY with the 365 Data Science Program -> https://365datascience.com