Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

How to Learn Python - The Ultimate Guide

Everything you need to learn Python online, from comprehensive courses to automation basics to building a portfolio and scoring your first R programming job.

Feb 1, 2023 • 3 Minute Read

So, you want to learn Python? You're not alone! According to the TIOBE index, Python is currently the most popular programming language in the world. We've crafted a guide that has something to offer everyone from absolute beginners to experienced programmers. 

It's easy to find introductory programming courses. This guide does more than that: it offers and end-to-end roadmap that will take you from Python basics to advanced Python applications to landing your first Python gig. You'll start with understanding Python in the real world, move into basic terms, discover a wide range of Python courses, and end with advanced applications and a strategy for your job hunt. Be sure to bookmark this page so you can come back to it as you move through your Python learning journey! 

Should you learn Python?

The process of learning a new programming language can be intimidating, so we are responding to some of the most common queries to put your mind at ease about the process.

What is Python?

Python is an object-oriented computer programming language that has become popular in recent years because it is easy to use and has a wide variety of applications, such as web and software development, data science, and automation. 

This guide explores in detail what Python can be used for and how to make the most of it. 

Why should I learn Python?

Python is highly versatile, so there are many reasons for studying it, such as wanting to

  • Learn programming for the first time.
  • Make replicable processes for data analysis.
  • Prepare data for machine learning.
  • Build dynamic web applications.
  • Crawl and scrape the web for data.
  • Automate business tasks.

Graph displaying number of stack overflow questions from 2009-2022

Stack Overflow Inquiries by Programming Language 2009-2022 
Source: Stack Overflow Trends

Is Python hard to learn?

Python is one of the more accessible programming languages for beginners, and it resembles natural language more closely than many other computer languages. The advantage of Python over other languages is that it is less verbose—meaning you need less code to get things done. 

If you dedicate a few hours daily to learning, you could be a beginner Python programmer in as little as five weeks. When you sign up for a Pluralsight account, you can set a weekly goal based on the time dedicated to learning. Setting up a weekly goal allows you to learn badges and helps keep you on track.

Should I learn JavaScript or Python?

Both JavaScript and Python have diverse use cases. If your primary goal is to develop websites and web applications, you probably want to familiarize yourself with JavaScript. For machine learning/AI and data science, Python has more versatility. But if you are focused on web development, why not learn both?

In terms of demand and earning potential, Stack Overflow's 2022 Developer Survey not only lists Python as one of the most popular programming languages, it's also one of the more highly compensated, with Python programmers making an average of $71,105 a year compared to JavaScript's $65,580. 

Key Python Terms

Here are five important terms that you should know as a Python developer:

Object-oriented programming

Object-oriented programming (OOP) is today's most popular programming paradigm (i.e., programming classification). Python and other well-known languages like Java and C++ fit under the OOP umbrella. OOP languages are structured around "classes" and "objects" code modules. The key here is that these modules are easy to repeat and customize.

OOPs give the programmer a lot of versatility while minimizing excessive repetition in scripts. Geeks for Geeks is an excellent resource for learning more about classes and objects.

Syntax

Syntax is the word for the rules that govern a programming language, and it's how the code must be written for it to work. As a coder, your adherence to syntax must be impeccable. Even the slightest typo will generate errors. 

While programmers want their languages to be as natural as possible, you'll notice when you start to learn programming for the first time that it's different from the kind of writing you've been asked to do. Don't worry! You'll get used to it.

Libraries (Programming)

Like a real-world library, programming libraries are collections of resources that are shared amongst programmers. Libraries are files that contain code, and each library performs specific tasks. Using a library saves time and effort when working with complicated functions and classes

The extensive and diverse types of libraries are part of what makes Python such an appealing language. Even on your first day of learning Python, you will likely encounter libraries and even be asked to import a few. 

Jupyter Notebooks

Jupyter notebooks, a product of Project Jupyter, is a web-based IDE that can be run in your browser. They're trendy because they are easy to access and ideal for sharing and collaboration. If you're working with Python, you'll probably hear a lot about Jupyter notebooks.

Integrated Development Environments (IDEs)

An Integrated Development Environment is software that helps you write programs. IDEs generally feature a text editor, a project editor, and an output viewer for running your program. They also offer advanced features like powerful debugging, code completion, syntax checkers, and bracket matching. They also simplify locating and installing libraries.

Code Editors v. IDEs

Code Editors IDEs
Text editor with special features for code editing. Text editor with special features for code editing, GUI testing, and more
Can be stand-alone or contained within an IDE. Contains a code editor and several other features
Syntax Highlighting, Previewing, and printing. All code editing features plus code completion, debugging, CLI, and more.
Sometimes contains IDE features Always contains a code editor and tools for testing, debugging, and running.
Sometimes more flexible and faster In some cases, may be harder to customize. 

What is Python Used for?

Python has many real-world uses, but some of the most common are machine learning, data science, web development, and automation. Importantly, these categories tend to overlap; for instance, data science feeds directly into machine learning and web development, which also work together.

Python for Data Science

Python is great for processing, preparing, visualizing, and sharing data. Several Python libraries like MatplotlibSeaborn, and Bokeh support the creation of data visuals. Netflix, Spotify, and YouTube use Python for data collection and analysis, including reports and user recommendations. 

Check out Pluralsight’s Data Wrangling with Python 3 course to learn more.

Python for Web Development

Another common application of Python is in web development. Google's famous web crawler, a bot that indexes websites, is built on Python. Instagram is constructed mainly on Python via the Django web development framework. Pluralsight’s Django: Getting Started course is a great place to learn more.

Python for Machine Learning

Machine learning is the process of training software to make predictions based on data. Machine learning programs collect user data and modulate their behaviors and outputs based on their observations. A few examples of popular programs built on machine learning with Python include Siri, Alexa, and Bosch's Intelligent Parking Systems.

Pluralsight offers a number of courses on machine learning, including Machine Learning with Python - Practical Application for beginners.

Python for Web Crawling

The web is a treasure trove of hidden information – if you know how to access it. Python offers several packages that can make it easy to gather info about websites, a process known as web crawling. Crawling the web helps with insights into different markets, your competitors’ digital strategy, the habits of social media users, and much more. 

Some Python libraries that are useful for web crawling include RequestsUrllibBeautifulSoupSelenium, and Scrapy.

Downloading Python & Python Packages

You've reviewed all the great reasons for learning Python, and you have a pretty good sense of how you might use it in the real-world. Now it's time to get started using it! You'll need a few things in order to begin your very first Python project, including the Python language itself, some type of coding environment, and to familiarize yourself with the popular Python package managers.

How do I download Python?

Start by installing the latest version of Python 3 directly on your computer from python.org. From the homepage, head to the download section and select the appropriate installer for your platform.

Unless you need an older version for a specific purpose, it’s usually best to choose the latest option available.

Don't worry – all the installs we're recommending are safe! Python is operating system independent, meaning that you can port examples that are non-Windows specific to other operating systems with few changes.

Once you have downloaded the installer, follow the installation instructions or steps, which consists of a few clicks using an intuitive setup wizard.

You can choose the default installation or upgrade option, or do a custom install, where you can select the location and what features to install. So, follow the steps, and you should be good to go.

download python
upgrade python

How do I create a Python script?

While you can write code directly in your terminal or command window, we recommend that beginners use a code editor or IDE for additional help writing, debugging, and running your scripts:

Pycharm is one of the most popular Python IDEs, and it’s a great place to start if you’re totally unsure about how to proceed. For a deeper dive into installation, check out "Installing and Starting Python" on Pluralsight while logged in. Building Your First Python Analytics Solution course also covers install options for Python IDEs and libraries.

If you want to use Jupyter notebooks or several other popular Python libraries, downloading the Anaconda Distribution is a good idea. The Anaconda distribution includes many popular libraries, including NumpyPandasConda, Jupyter, Bokeh, and much more.

What is PyPi?

PyPi, or the Python Package Index, is the official third-party software repository for the Python language. In other words, it's a place for developers to upload the libraries they've created to share them with others. PyPi utilizes the Pip package manager for installs.

What's the difference between Pip and Conda installs?

Pip and Conda are two Python package installers. The critical difference is that Pip only installs packages written in Python unless you use an interpreter. Conda installs, however, can use any programming language without an interpreter. Otherwise, there’s a lot of overlap, and both can install the same Python packages.

Are you ready to learn Python?

Pluralsight has a vast catalog of over 100 Python courses for everyone, from absolute beginners to seasoned experts. Our resources include video lectures, tutorials, and hands-on learning projects. Here are just a few of our course offerings available online:

Python Courses for Beginners

We recommend launching your Python education with Pluralsight's Python Core Language learning path. This path comprises 25 courses to help jumpstart your coding adventure. Depending on your focus, you may also want to try the Python for Data Analysts path. You can also check some of our beginner courses:

Advanced Python Courses

For those who already have some experience coding in Python. Browse our online course library for more:

Hands-On Python Tutorials at Pluralsight

If you're a hands-on learner, try one of these interactive courses on beginner Python topics from Pluralsight:

Get a Feel for Python

Python has a built-in standard library that provides many functions for working with files, possibly one of Python's most used aspects. Let's take a look at how to use Python to find, delete, archive, and take on others tasks for specific files within a folder. Our course on Working with Files in Python3 explores the topics below in much more detail.

Finding Files with Python

The following Python script will search for all CSV files (*.csv) within a specific folder (fld)—in our case, the name of the directory is "./files".

      import os, fnmatch

def match(fld, search):
    for fn in os.listdir(fld):
        if fnmatch.fnmatch(fn, search):
            print(fn)

match('./files', '*.csv')
    

So, how does this script work? We begin by importing the os and fnmatch modules from the Python standard library. Then, we create the match function, where the magic happens.

The call to the listdir method returns an array (list) of all the files contained within the folder (fld) being inspected, in this example, the "./files" folder.

The match function then iterates through all the files found within the folder, and the fnmatch method is invoked, for each file, checking whether the file name of the current file (fn) matches the search criteria, in this case, "*.csv".

Writing a function that finds files within a folder using specific search criteria in just a few lines of code is possible.

Copying Files in Python

Perhaps, one of the frequent operations in any daily or business context is copying files. With Python, copying files and folders is incredibly straightforward. We start by importing the shutil module, which contains the Python methods for copying files (copy) and folders (copytree). So, we'll define two Python functions for those purposes, copy_file, and copy_folder.

      import shutil

def copy_file(src, dst):
    shutil.copy(src, dst)

def copy_folder(src, dst):
    shutil.copytree(src, dst)

copy_folder('./files', './files/subfolder')
copy_file('./files/text1.txt', './files/subfolder')
    

The way file copying works in Python is that the origin file (src) is copied to a destination folder (dst). 

On the other hand, a folder is copied in its entirety (the complete folder structure), meaning that all files and subfolders present within the origin folder (src) are copied to the destination folder (dst).

In the above example (when copy_folder is invoked), the contents of the root of the ./files folder is copied to the ./files/subfolder folder.

When the copy_file function is invoked, the ./files/text1.txt file is copied to the ./files/subfolder folder.

So, as you have seen, entire folders are easily copied with a few lines of code.

Deleting Files with Python

Another critical operation that Python makes easy is deleting files. In this example, we begin by importing the os module. After, we create a function called remove_file, which, as its name implies, will be used for deleting a specific file.

      import os

def remove_file(f):
    if os.path.isfile(f):
        try:
            os.remove(f)
        except OSError as e:
            print(f'Error: {f} : {e.strerror}')
    else:
        print(f'Error: {f} not a valid file')

remove_file('./files/test1.txt')
    

In the example above, ./files/test1.txt is the deleted file's name. Before deleting the file (f), we need to verify that the file exists—this is done by invoking the isfile method and passing the file name (f) as a parameter. 

The deletion is done by executing the remove method. The deletion operation is enclosed within a try statement, meaning that the code found within the except statement runs if an error or exception occurs when deleting the file.

Creating an Archive

Another typical operation when handling files with Python is to create archives, mostly ZIP files. In the example that follows, we have a list of file names (to_zip) within the ./files and ./files/subfolder folders that we want to archive into a ZIP file.

      import zipfile

to_zip = ['./files/subfolder/01_file_test.csv', 
    './files/subfolder/01_file_test.txt', 
    './files/subfolder/01_test_file.csv', 
    './files/subfolder/01_test_file.txt',
    './files/01_file_test.csv',
    './files/01_file_test.txt']

def create_zip(zipf, files, opt):
    with zipfile.ZipFile(zipf, opt, allowZip64=True) as archive:
        for f in files:
            archive.write(f)

create_zip('./files.zip', to_zip, 'w')
    

We define the create_zip function, to which we pass the name of the resulting zip file we want to create (zipf), the list of files to compress and archive (files), and the archiving options (opt).

The creation of the ZIP file happens when the ZipFile method is invoked. Setting the allowZip64 option to True tells Python to create ZIP files that use the ZIP64 extensions, allowing ZIP files larger than 4 GiB.

Then, for each file (f) found within the list of files (files), each file (f) is added to the ZIP file (archive).

When invoking the create_zip function, ./files.zip will be the name of the resultant ZIP file, whereas to_zip indicates the names of the files to be zipped and means w that the create_zip function will write to the ./files.zip file.

Reading & Writing Text Files

Reading and writing text files is also part of many daily operations, and Python makes these processes easy as well. In this example, we have four functions, two that allow us to read text files and two that will enable us to write to text files.

      def read_txt(fn):
    with open(fn) as f:
        print(f.read())

def read_txt_by_line(fn):
    with open(fn) as f:
        lines = f.readlines()
        for line in lines:
            print(line, end='')
            line = f.readline()

def write_new_txt(fn, str):
    with open(fn, 'w', encoding='utf-8') as f:
        f.write(str)

def append_line_txt(fn, str):
    with open(fn, 'a', encoding='utf-8') as f:
        f.write('\n')
        f.write(str)

read_txt('files_to_read/backup.py')
read_txt_by_line('files_to_read/backup.py')
write_new_txt('files_to_read/example.txt', 'this is a test...')
append_line_txt('files_to_read/example.txt', 'this is an extra line')
    

The read_txt function opens (open) and then reads (read) in one go, the file's contents (fn) passed as a parameter. Below is how the function is invoked.

read_txt('files_to_read/backup.py')

The read_txt_by_line function, on the other hand, opens (open) and then reads (read) the file's contents (fn) passed as a parameter. This happens line-by-line, by first reading all the lines (readlines), and then looping through each line at a time (for line in lines). Here’s an example of that: 

read_txt_by_line('files_to_read/backup.py')

The write_new_txt function, as its name implies, creates and opens (open) a new file (fn) in write-mode (w) using utf-8 encoding and writes a line (str) to the file:

write_new_txt('files_to_read/example.txt', 'this is a test...')

The append_line_txt function, on the other hand, opens (open) an existing file (fn) in append-mode (a) using utf-8 encoding and adds a line (str) at the end of the file's existing content:

append_line_txt('files_to_read/example.txt', 'this is an extra line')

As you have seen, Python is highly versatile, can be used in typical business scenarios, and is great for automation.

Business Automation with Python

One of the fundamental challenges of business process automation is efficiently extracting data from semi-structured or unstructured sources, such as PDF files, and using that data to instantly perform data entry on other systems, with barely any human assistance. 

Say, for instance, we have a pile of hundreds or thousands of PDF documents. Someone has to open each PDF file, copy each field manually from each PDF, and paste the value of each field from each PDF into an equivalent web form (like Salesforce or any other CRM or ERP system).

With hundreds or thousands of PDF documents, each containing many fields, you can start to see that this is a tedious, daunting, and exhausting task for any person (or even a group of people) to execute without mistakes.

But what if we could write a Python script that could do the heavy lifting? The Python script would read the content of hundreds or thousands of PDF documents, extract the data for each field within those documents, and then place each piece of data into a browser-based script that would fill in each web form automatically.

A case like the one just described is a great example where Python shines by giving us an edge to quickly solve a problem of this complexity thanks to its flexibility, ease of use, and simple syntax. 

All across the globe, organizations are facing challenges about becoming more efficient by increasing productivity with existing resources or less. Business Process or Robotic Process Automation (also known as RPA) is a technology that can augment workers' productivity by eliminating repetitive tasks that can be performed faster and more accurately by a computer. 

In the course Business Automation with Python 3: Getting Started, basic Robotic Process Automation concepts are applied to explain how Python can be used to automate complex scenarios with ease.

Next Steps for Advanced Python

Before you apply for a job in Python, you will need to have a couple projects under your belt, as well as a sense of how your programming skills stack up against others in your field. Check out these resources for deepening your understanding of Python before moving on to what you need to do to land your first Python gig! 

Measure Your Python Skill IQ

If you've done a little Python in the past, and want to know how your skills stack up against other programmers, try measuring your Python Skill IQ. You'll get two tries if you don't like your first score. This feature is for Pluralsight subscribers, so consider starting a trial if you want to access it.

Pick up some popular Python blogs

Knowing what other Python developers are searching for online can be a great way to expand your Python knowledge, even as a beginner—giving you a head start in identifying the language's more advanced and valuable applications. Here are a few of Pluralsight's most accessed guides on popular Python topics:

Python memory usage

"One of the ways Python makes development fast (not to mention easier than languages like C  and C++ ) is Python memory management. In Python, it's simply because the language handles memory management for you…."

How to Profile Python Memory Usage | Pluralsight

Install Python in Ubuntu

"Ubuntu makes starting easy, as it comes with a command line version pre-installed. The Ubuntu community develops many of its scripts and tools under Python. You can begin the process with either the command line version or the graphical Interactive Development Environment (IDLE)...."

How to Use Python Programming in Ubuntu Linux | Pluralsight

Scala vs. Python for Spark

"Spark is one of the most active open source Big Data projects with many contributors. This is surprising, given that it's a younger project. Unlike Hadoop, the original and de facto parallel processing framework, Spark is evolving faster pace…."

Developing Apache Spark applications: Scala vs. Python

Raspberry Pi countdown clock with Python

"To mark the days until Pluralsight LIVE 2017, I decided to build a dedicated clock. To embrace the maker and IoT spirit that Pluralsight LIVE celebrates, I realized a Raspberry Pi would be the perfect realization of my idea…."

Building a countdown clock with Raspberry Pi and Python | Pluralsight

Meet Other Python Developers

Please don't be shy when it comes to joining the programming community. Connecting with other developers can be a great way to find helpful problem-solving resources. Here are a few places where developers can meet each other:

Don’t forget about Twitter, Instagram, TikTok, or YouTube. Influencers can be a fantastic source of inspiration and information.

Keep leveling up your Python skills

It's your turn to transorm your desire to learn more about Python into actionable results. 

The key is to stay curious and don't put too much pressure on yourself to achieve results immediately, but take baby steps and learn one aspect of Python at a time. 

Learn the basics and how to work with files, folders, and the standard library before learning any more complex aspects of Python.

Whether you're that lucky person sitting next to a pile of hundreds of PDF documents to migrate to Salesforce or a data analyst who needs to crunch through data contained within Excel files, Python can help you become more productive.

Land a job as a Python programmer

Before you begin your professional journey into Python, take a moment to congratulate yourself! It's not easy to learn new skills or to branch into totally new territory. As you start down this new path, don't be intimidated by other professionals. You don't need to have mastered everything in order to find fulfilling and lucrative work. 

Build your Python portfolio

Building a portfolio for the first time is a daunting task, but luckily, you don't need to rely on professional or commissioned work to create a great portfolio. Instead, just make sure that your body of work

  • Contains at least 3 projects
  • Demonstrates your ability to use Python to answer real-world questions or solve real problems
  • Showcases the specialization you've chosen (data analysis, machine learning, etc.)
  • Proves your proficiency in packages related to your specialization
  • Evidences your creativity, flexibility, and troubleshooting skills

If you need some inspiration to jumpstart your project ideas, there's a wealth of example portfolio projects available online to help you. Here's a great list from RealPython.com of 13 portfolio projects for intermediate Python programmers. 

Add Python to your resume

We suggest working on your portfolio first so that you can be as specific (and knowledgeable) as possible about the skills you list in your resume. Once you feel confident in the skills you've mastered, you can select which ones you want to highlight in your resume. Keep in mind the following tips:

  • List your specialization (machine learning, data visualization, etc.) alongside Python in the skill section
  • Don't forget about soft skills! Presentation skills, communication, storytelling, and problem-solving are a few examples of soft skills common to Python programmers.
  • Don't list technical skills you aren't very confident in. Your resume is a place to showcase your best skills. Let interviewers ask questions about skills related to a specific job, and be ready to be honest about your experience while redirecting to your willingness to learn and related strengths you possess.
  • Have a public Github profile to showcase your projects, and make sure it's easy to find your Github by linking it on your website or social media accounts.
  • Don't worry about listing specific Python packages in your skills. In fact, it's better to focus on project management or computational software you have experience with that are popular (Excel, Tableau, SharePoint, etc.)
  • That being said, if you are able to learn a popular framework like Django (for web app building), you may want to include that on your skills since employers often seek out programmers with that kind of knowledge.

Search for jobs by programming language

If you want Python to be the main focus of your work, many job boards offer the option of searching by programming language. Here are a few to help you get started:

Search for jobs by specialization

Knowing Python opens a lot of different doors, and you may want to cast a net by looking into specializations that like to hire Python programmers. Here are just a few of the jobs that you can do with Python:

  • Python developer
  • Software engineer
  • Software systems engineer
  • Data architecht
  • Data engineer
  • Web developer
  • Full stack developer

Co-author

Eduardo Freitas

Eduardo is a technology enthusiast, software architect and customer success advocate. He's designed enterprise .NT solutions that extract, validate and automate critical business processes such as Accounts Payable and Mailroom solutions for all types of organizations.

He's designed and supported production systems for global names such as Coca Cola, Enel, Pirelli, Fiat-Chrysler, Xerox and many others. He's a well-known specialist in the Enterprise Content Management market segment, specifically focusing on data capture & extraction and document process automation. He designed a supplier invoice processing system for Agfa that achieved 50% straight-through processing (50% of invoices extracted from paper, validated and exported into SAP without any human validation). He's also loves to write about cutting-edge technologies. He loves helping customers succeed. In his free time, he enjoys spending time with his family and being outdoors. He loves running and sports.

Eduardo is also a course author here on Pluralsight, and has written on topics like Python, automation, cloud computing, working with databases, and more. 

Dr. Katherine Blake

Dr. Katherine Blake

Dr. Kate Blake is a writer with a penchant for technical material, including computer programming and the history of science and technology. Though she has been coding since she was twelve, her professional background is in academia, and she recieved her PhD from Indiana University in English in 2017 and worked as an English Professor for several years while publishing research on a variety of topics, Since leaving academia, she now works in technology education. She is currently employed at Pluralsight as an SEO analyst, where she's able to combine her love of programming languages with her background in writing and education.

More about this author