How to Learn Python

This article was first published on DataCamp Community - python , and kindly contributed to python-bloggers. (You can report issue about the content on this page here)
Want to share your content on python-bloggers? click here.

Python is the most popular programming language today and is widely used across verticals from software and web development, game development, data science, machine learning, and more. Learning Python is imperative for aspiring data scientists, data analysts, data engineers, and machine learning scientists.

The good news is that a complete beginner can learn and start programming in Python in just a couple of weeks. Here’s how to get started.

Know your motivation before you begin

Python is a highly versatile programming language with many use cases. It’s important to have a specific motivation in mind as you embark on your Python learning journey. Targeting an area of interest will help you get started quicker and filter out learning resources that don’t fit your use case. My own Python learning journey began when I needed to use it for school for data science projects. I had no Python or programming experience and needed to get up to speed fast. Luckily, with a few online resources, I was able to become proficient in just a few months. Here’s a list of relevant areas where Python is helpful:

How to Learn Python

1. Data Science and Machine Learning

Python’s rise in popularity can be attributed to its rich set of packages and tools for data science and machine learning. Researchers use data analysis packages like pandas to analyze Covid data, practitioners can quickly apply machine learning with libraries like scikit-learn, Keras, and PyTorch to detect fraud, classify images, and produce product recommendations.

2. Desktop and Mobile Software Development

Whether building simple software applications like calculators, or more complex ones like document editors and social networks. Python offers a plethora of tools to prototype, develop, and run desktop or mobile applications such as wxWidgets and Kivy.

3. Web Development

Did you know that web applications like Uber, Netflix, and Spotify were built with Python? There are a variety of web frameworks on Python that simplify website development. Packages such as Flask, Django, Bottle, and Pyramid all offer tools to quickly prototype and build scalable web apps.

4. Game Development

This may come as a surprise, but games such as The Sims 4 and Civilization IV were built with Python. Python libraries such as PyGame and Turtle simplify prototyping and development of games.

5. Internet of Things (IoT)

The rise of embedded systems and the internet of things (IoT) has catalyzed innovation and business process improvement across domains. Python offers a set of packages that make it easy to design, create, and deploy an IoT device on Arduino, Raspberry Pi, and other IoT devices such as Alexa and Google Home.

6 steps for your Python learning journey

How to Learn Python

1. Spend as little time as possible on basic syntax

When learning any programming language, it’s very easy to get bogged down by learning syntax. Introductory courses often make learning a chore by focusing on pure Python syntax rather than how Python can solve a specific problem. Don’t get me wrong: Learning Python syntax is essential for any beginner Python learner, but as a rule of thumb, you should learn just enough syntax to get started working on simple projects. When I began my Python journey for data science, I learned just enough syntax to be able to use pandas for simple data analysis tasks. Here’s a list of syntax resources:

2. Set up your Python environment

Before working on projects, you need to have a Python environment set up on your machine. Being able to work on projects on your own machine is the best way to apply your new skills. To set up your environment for data science, I recommend installing an Anaconda distribution, which conveniently installs all relevant data science packages, and an integrated development environment for editing code in Python called Spyder.

For a primer on setting up your Python environment with an Anaconda, watch my hands-on training for a step-by-step tutorial. You can also follow beginner guides for installing Anaconda on Windows and Mac OS X.

How to Learn Python

An image of the Spyder Integrated Development Environment

3. Learn by doing

At DataCamp, we believe that learning by doing is the best way to learn and apply programming skills. No matter your focus area, working on projects will help you get out of your comfort zone, learn how to debug and read documentation, and showcase your skills to potential employers.

Data Science and Machine Learning

Data Science and Machine Learning is one of the fastest-growing focus areas today. There are many solutions for online data skills training:

  • DataCamp offers over 130 interactive Python courses and 39 projects across a wide range of data science and machine learning topics. You’ll build your skills from the ground up by coding directly in the browser, and apply your skills on a variety of datasets from Finance, Marketing, Sports, History and more.
  • The Python Data Science Handbook provides an excellent overview of the main data science packages and techniques in Python. Conveniently, all of the content is available on GitHub in the form of Jupyter notebooks.
  • The IBM Data Science Professional Certificate specialization on Coursera contains nine courses covering a range of techniques in data analysis, data visualization, machine learning, and more. The final course in the specialization is a capstone project combining these techniques on Foursquare data.
  • The Codeacademy Data Scientist Path offers a range of courses on data science and machine learning with Python, culminating in a final portfolio project.

Desktop and Mobile Software Development

Python offers a range of tools to prototype and develop desktop and mobile applications. Here’s a list of learning resources to get you started:

  • The ZetCode wxWidgets tutorial offers a step-by-step introduction to building graphical user interfaces with wxWidgets and shows learners how to build a simple Tetris game.
  • Kivy offers a range of tutorials on how to build simple mobile applications with Kivy on Python.

Web Development

The two main packages for Python web development are Flask and Django. While there is discussion on the pros and cons of each, here’s a list of learning resources for both packages:

  • The Flask tutorial page explains how to build a simple blog website. If you’re a visual learner, this YouTube video is an excellent introduction to building websites with Flask.
  • Learn to build web apps with the Django tutorial page. Real Python also explains this nicely, and includes a list of sample projects for a web developer portfolio.

Game Development

While modern game development is dominated by game engines like Unreal Engine and Unity where most developers use JavaScript, C#, C++ or Java, the following python packages are a great way to get into game development:

  • The PyGame tutorial page shows you how to build a range of different games with PyGame. Visual learners can follow this YouTube video to build a space invaders game with Python.
  • Real Python offers an excellent overview of the Turtle package for game development in Python, ending with a turtle race game as a final project.

Internet of Things (IoT)

IoT devices are everywhere around us, collecting data about our environment and are only expected to rise in numbers, here’s a list of resources covering how to program IoT devices with Python:

4. Learn how to debug code and ask for help

One of the most overlooked skills any aspiring programmer needs to hone is debugging. Every Python practitioner, regardless of skill level, faces errors and problems with their code. When you encounter with errors in your code, make sure to use these resources at your disposal:

  • Google is almost always the first place I go when faced with errors with my code. Almost always, the answer to my Python query will be in the first 10 search results.
  • Stack Overflow is the largest community of developers where practitioners can seek help with debugging code by asking and answering programming questions. Most of the time, your Python question has already been asked and answered. If you want to post a question yourself, make sure to follow their best practices when phrasing questions.
  • Documentation will always be your friend. Whether working with built-in Python functions or working with a downloaded package like pandas, you can always find documentation detailing functionality, possible errors, and tutorials on the website of the package you’re working with.

5. Expand your learning resources

Now that you’ve set up your Python environment, worked on guided projects, and learned how to debug, it’s time to expand your knowledge and continuously sharpen your skills. Here are a list of resources that will help you do that:

  • Blogs can help you keep up with the latest trends and techniques in Python. One of my favorites is Real Python, as it hosts primers and tutorials on packages I wouldn’t otherwise use. They also have a bit-sized newsletter with Python tips and tricks.
  • Reading other people’s code is immensely useful when sharpening your Python skills. For data science and machine learning, Kaggle is an excellent resource to see how experienced data scientists would solve a problem. You can also look at the source code of your favorite open-source packages on GitHub.
  • Attend conferences, meetups, and other community gatherings with more experienced practitioners. This will give you the opportunity to network and learn from more experienced Python programmers.

6. Build a portfolio of projects

Now you’re ready to start tackling complex open-ended projects and showcase them in a portfolio for future employers. When working on open-ended projects, it’s best to start simple and work on Python projects directly related to your work. If you’re looking for inspiration, this Edureka blog post contains a list of open-ended projects in game development, web development, data science and machine learning.

You can start building your portfolio by hosting your code on Github and writing blog posts about your projects. This gives you the ability to showcase your technical writing ability and teach beginners how you’ve developed your projects. You can write blog posts by developing your own website or by using a blog hosting service like Medium.

I hope you feel inspired by this blog post, and that these resources are useful to you. Mastering any programming language is a lifelong learning journey—one that I am still on myself. At DataCamp, Python is part of our core curriculum and we’re constantly improving and adding to our content. Lastly, I invite you to join thousands of learners in the DataCamp Slack Community to get support on your Python journey!

Adel Nehme is a Data Science Evangelist at DataCamp. He was previously a Content Developer where he collaborated with instructors on a range of Python courses, and created our course Cleaning Data in Python.

To leave a comment for the author, please follow the link and comment on their blog: DataCamp Community - python .

Want to share your content on python-bloggers? click here.