May 9, 2024

Python Practice: 93 Unique Online Coding Exercises

Whether you're just starting your learning journey or looking to brush up before a job interview, getting the right kind of Python practice can make a big difference.

Research shows that hands-on practice is the most effective way to learn,* and luckily there are so many different ways to practice that you're bound to find one that works best for you.

In this post, we'll share 93 ways to practice Python online by writing actual code, broken down into different practice methods.

Table of Contents

  • Exercises
  • Courses
  • Projects
  • Tutorials
  • Frequently Asked Questions
  • Practice with Free Python Coding Exercises

    Exercises are a great way to practice a specific topic with targeted efficiency. For example, do you have an upcoming job interview where you know you'll be asked about Python dictionaries? Completing exercises about dictionaries will help refresh your skills and ensure you can confidently speak to this Pythonic datatype.

    An animated gif of two Python list variables that are converted to numpy arrays and then concatenated together.

    Core Python Programming (Great for Beginners)

    Intermediate Python Programming

    Data Handling and Manipulation with NumPy

    Data Handling and Manipulation with pandas

    Data Analysis

    Complexity and Algorithms

    Explore our full library of Python practice problems to continue improving your skills.

    Practice with Online Python Courses

    If you're looking for more structure, then practicing with Python courses online may resonate with you. Courses guide you through a topic, so if you want to gain a new skill or you're rusty on an old one, completing a course is an excellent way to go.

    Throughout these courses, you'll be given questions and assignments to test your skills. Additionally, some of these courses contain a guided project that allows you to apply everything you've learned.

    An animated gif showing numpy appending, concatenating, and slicing of a dataset called "taxi".

    See below for some recommended courses.

    Python Introduction (Great for Beginners)

    • Introduction to Python — Write code using Python syntax; work with different types of data; and perform basic Python operations such as working with variables, processing numerical and text data, and manipulating lists.
    • Basic Operators and Data Structures in Python — Learn the fundamentals of Python for loops, dictionaries, and conditional logic (if-else).
    • Python Functions and Jupyter Notebook — Write Python functions, build functions that employ multiple return statements and return multiple variables, and install and use Jupyter Notebook.
    • Python for Data Science: Intermediate — Manipulate text, clean messy data, work with object-oriented programming concepts, and use dates and times in Python.

    Data Analysis and Visualization

    Data Cleaning

    Machine Learning

    • Intro to Supervised Machine Learning — Build a supervised machine learning model in Python, and train and improve it for better performance and accuracy.
    • Intro to Unsupervised Machine Learning — Learn about unsupervised machine learning models in Python, when to apply them, and what differentiates them from supervised machine learning models.
    • Linear Regression Modeling — Build, evaluate, and interpret the results of a linear regression model, as well as using linear regression models for inference and prediction.
    • Gradient Descent Modeling — Learn the fundamentals of gradient descent and how to implement this algorithm in Python.
    • Logistic Regression Modeling — Build and evaluate logistic regression models, both from scratch and using scikit-learn.
    • Decision Tree and Random Forest Modeling — Learn the foundations of Decision Trees including identifying the key components of trees, interpreting them, classifying new observations using decision trees and calculating optimal thresholds for both classification and regression trees.
    • Optimizing Machine Learning Models — Explore the most common methods and techniques that will enable you to optimize your machine learning models for better efficiency.

    AI and Deep Learning

    • APIs for AI Applications — Use Python for retrieving, analyzing, and manipulating real-world data from various sources including the World Development Indicators database.
    • Prompting Large Language Models (LLMs) — Create an AI-powered chatbot using Python, that incorporates key concepts like prompt engineering, managing conversation histories, and efficiently regulating token usage within an AI framework.
    • Intro to Deep Learning in Tensorflow — Learn the fundamentals of deep learning, as well as how to build, train, and evaluate models using the TensorFlow framework.

    Probability and Statistics

    • Introduction to Statistics in Python — Work with techniques for sampling data, concepts such as discrete variables and random variables, and the different types of charts and graphs you might use to visualize frequency distributions.
    • Intermediate Statistics in Python — Summarize distributions using mean, median, and mode. You’ll also learn to measure variability using variance or standard deviation and how to locate and compare values using z-scores.
    • Introduction to Probability in Python — Estimate probabilities, work with the addition and multiplication rules, and define permutations and combinations.
    • Introduction to Conditional Probability in Python — Assign probabilities to events based on certain conditions, evaluate whether they are in a relationship of statistical independence or not, and on prior knowledge by using Bayes’s theorem.
    • Hypothesis Testing in Python — Learn advanced statistical concepts like significance testing and multi-category chi-square testing,

    These courses are a great way to practice Python online, and they're all free to start. If you're looking for more courses, you can find them on Dataquest's course page.

    Practice with Python Projects

    One of the most effective ways to practice Python online is with projects. When I was learning Python, it was easy to forget newly acquired skills. When I discovered that I could do projects to practice my newfound knowledge, it helped me remember new syntax. Additionally, I built a great portfolio of work to show potential employers.

    An animated GIF showing a Python Jupyter notebook cell with a "while" game loop for a word guessing game project.

    Here are a few projects you can use to start practicing right now.

    Beginner Projects

    Data Analysis Projects

    • Investigating Fandango Movie Ratings (free) — Step into the role of a data journalist to analyze movie ratings data and determine if there’s evidence of bias in Fandango’s rating system.
    • Exploring Hacker News Posts (free) — Analyze a dataset from Hacker News and apply your Python skills in string handling, object-oriented programming, and data management to uncover trends in user submissions.
    • Exploring eBay Car Sales Data — Use Python to work with a scraped dataset of used cars from eBay Kleinanzeigen, a classifieds section of the German eBay website.
    • Finding Heavy Traffic Indicators on I-94 — Explore how using the pandas plotting functionality along with the Jupyter Notebook interface allows us to explore data quickly using visualizations.
    • Storytelling Data Visualization on Exchange Rates — Quickly create multiple subsetted plots using one or more conditions.
    • Clean and Analyze Employee Exit Surveys — Work with exit surveys from employees of the Department of Education in Queensland, Australia. Play the role of a data analyst and pretend the stakeholders want answers to important data questions.
    • Analyzing NYC High School Data — Discover the SAT performance of different demographics using scatter plots and maps.

    Data Engineering Projects

    • Building Fast Queries on a CSV (free) — Act as a Python developer to build an inventory system for a laptop store. You’ll apply efficient data structures and algorithms to enable fast queries.
    • Analyzing Wikipedia Pages (free) — Process over 54 MB of Wikipedia articles to find specific text matches. Using Python and MapReduce, you’ll build a parallel solution to search the dataset and return match details efficiently.
    • Building a database for crime reports — Use PostgreSQL to build a database with proper schemas, tables, and user roles to store and manage crime report data efficiently.

    Machine Learning and AI Projects

    • Predicting Heart Disease (free) — Act as a data scientist at a healthcare solutions company to build a model that predicts a patient’s risk of developing heart disease based on their medical data.
    • Predicting Insurance Costs — Use linear regession modeling to predict insurance costs.
    • Developing a Dynamic AI Chatbot — Create an AI chatbot that can take on different personas and keep track of conversation history.

    If these didn't spark your interest, here are plenty of other online Python projects you can try.

    Practice with Online Python Tutorials

    If online practice exercises, courses, and projects don't appeal to you, here are a few blog-style tutorials to help you learn Python. I like to use this type of resource when I'm on my phone to get some productive reading done, even when I can't code on my computer!

    Core Python Concepts (Great for Beginners)

    • Python strings — See how to declare the string data type, the relationship between the string data type and the ASCII table, the properties of the string data type, and some important string methods and operations.
    • Python dictionaries — Learn how to create a Python dictionary, how to use its methods, and dictionary comprehension.
    • Python data structures — Read about what data structures exist in Python, when to apply them, and their pros and cons.
    • Python classes — Learn how to create and work with Python classes. See what Python classes are, why we use them, what types of classes exist, how to define a class in Python and declare/adjust class objects,
    • Python lists — Read how to define, create, and slice lists, as well as how to add/remove items and use a for loop to iterate over a list.
    • If statements — Use conditional logic with if, elif, and else to streamline your code's efficiency.

    Intermediate Techniques

    • Python datetime — Learn the uses of the datetime module, extract dates, and work with timestamps.
    • Python ternary — Understand what a Python ternary operator is and when it's useful.
    • Python subprocess — See how to use the subprocess module in Python to run different subprocesses during the course of a regular python script.
    • Python math module — Read about the common constants and functions implemented in the math module — and how to use them.
    • Read files in Python — Learn how to open files, use the with context manager, read text, CSV, and JSON files, and understand different file modes.
    • Lambda functions — Define lambda functions in Python and explore the advantages and limitations of employing them.

    Data Analysis and Data Science

    • Reset index in pandas — Discusses the reset_index() pandas method, why we may need to reset the index of a DataFrame in pandas, and how we can apply and tune this method.
    • GroupBy in pandas — Explore how to create a GroupBy object in pandas library of Python and how this object works.
    • Getting Started with APIs — Understand how to retrieve data for AI and data science projects using APIs (Application Programming Interfaces).
    • Introduction to Keras — Learn how to install and start using Keras; the Sequential API; and the steps for building, compiling, and training a model..
    • Implement Support Vector Machines (SVMs) — Read about support vector machines, one of the most popular classification algorithms. Learn how to implement SVMs for a classification task in Python.

    The web is also full of thousands of other beginner Python tutorials. As long as you've got a solid foundation in the Python basics, you can find great practice through many of them.

    Frequently Asked Questions

    Where can I practice Python programming?

    1. has dozens of free interactive practice questions, as well as free interactive lessons, project ideas and walkthroughs, tutorials, and more.

    2. HackerRank is a great site for practice that’s also interactive.

    3. CodingGame is a fun platform for practice that supports Python.

    4. Edabit has Python challenges that can be good for practicing or self-testing.

    You can also practice Python using all of the interactive lessons listed above

    How can I practice Python at home?

    1. Install Python on your machine. You can download it directly here, or download a program like Anaconda Individual Edition that makes the process easier. Or you can find an interactive online platform like Dataquest and write code in your browser without installing anything.

    2. Find a good Python project or some practice problems to work on.

    3. Make detailed plans. Scheduling your practice sessions will make you more likely to follow through.

    4. Join an online community. It's always great to get help from a real person. Reddit has great Python communities, and Dataquest's community is great if you're learning Python data skills.

    Can I learn Python in 30 days?

    In 30 days, you can definitely learn enough Python to be able to build some cool things. You won't be able to master Python that quickly, but you could learn to complete a specific project or do things like automate some aspects of your job.

    Read more about how long it takes to learn Python.

    Can I practice Python on mobile?

    Yes, there are many apps that allow you to practice Python on both iOS and Android. However, this shouldn't be your primary form of practice if you aspire to use Python in your career— it's good to practice installing and working with Python on desktops and laptops since that's how most professional programming work is done.

    How quickly can I learn Python?

    You can learn the fundamentals of Python in a weekend. If you're diligent, you can learn enough to complete small projects and genuinely impact your work within a month or so. Mastering Python takes much longer, but you don't need to become a master to get things done!

    Read more about how long it takes to learn Python.

    AI is advancing so quickly - should I still learn Python?

    Absolutely, Python remains essential in the AI field. It's foundational for developing AI technologies and continuously updated to integrate with the latest AI advancements. Python libraries like TensorFlow and Keras facilitate efficient building and training of complex AI models. Learning Python also ensures you understand the underlying mechanisms of AI tools, making you a more proficient developer.

Charlie Custer

About the author

Charlie Custer

Charlie is a student of data science, and also a content marketer at Dataquest. In his free time, he's learning to mountain bike and making videos about it.