Free Python exercises

This page lists 28 Python exercises. You can use the menu on the left to show just exercises for a specific topic.

This page lists 28 Python exercises. You can use the menu above to show just exercises for a specific topic.

Software: Python
Version: Latest version
Topic: Basic coding
Level: Relatively easy
Course: Python programming
Exercise: Using the INPUT and PRINT functions, get and display the meaning of life.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Ranges and loops
Level: Relatively easy
Course: Python programming
Exercise: Use the range and format functions to loop down from 10 to 1 displaying a countdown message.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Functions
Level: Relatively easy
Course: Python programming
Exercise: Define a function to print out text with the correct length of underlining.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Sequences
Level: Relatively easy
Course: Python programming
Exercise: Use a list to store items in a shopping list, print them out and change one.

Go to exercise ...

Software: Python
Version: Latest version
Topic: CSV and Excel
Level: Relatively easy
Course: Python programming
Exercise: Use the openpyxl module to create a new workbook and add values/formulae to it.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Overview of NUMPY
Level: Relatively easy
Course: Python programming
Exercise: Create a NumPy array of the Tokyo Olympics medal table, then slice and sum it.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Sequences
Level: Relatively easy
Course: Python programming
Exercise: Use different slicing techniques to extract the names of animals from strings of text.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Sequences
Level: Relatively easy
Course: Python programming
Exercise: Loop over the items in a range which are divisible by one number but not another.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Files and folders
Level: Relatively easy
Course: Python programming
Exercise: Open a file for writing, write out your details then read them back in to check.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Ranges and loops
Level: Average difficulty
Course: Python programming
Exercise: Use the range function in an outer loop to find all the primes up to 100 using an inner loop.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Comprehensions
Level: Average difficulty
Course: Python programming
Exercise: Use text functions, loops and a comprehension to analyse word counts.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Dictionaries
Level: Average difficulty
Course: Python programming
Exercise: Use a dictionary to hold details of the tallest buildings in the world, then list its items.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Basic coding
Level: Average difficulty
Course: Python programming
Exercise: Use the input, str and int functions to get two numbers from a user and show their sum.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Sequences
Level: Average difficulty
Course: Python programming
Exercise: Create a tuple containing a list, a string and an integer, then list its contents.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Sequences
Level: Average difficulty
Course: Python programming
Exercise: Create a list of all of the words in a speech, and loop over it printing certain ones.

Go to exercise ...

Software: Python
Version: Latest version
Topic: CSV and Excel
Level: Average difficulty
Course: Python programming
Exercise: Open an Excel workbook and read down a list of plants finding the ones not in stock.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Sequences
Level: Average difficulty
Course: Python programming
Exercise: Practise slicing and looping on a list of the most common English words.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Files and folders
Level: Average difficulty
Course: Python programming
Exercise: Open a text file, read its lines and split each to give field details for a list of Muppets.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Overview of Pandas
Level: Average difficulty
Course: Python programming
Exercise: Read an Excel workbook into a Pandas dataframe, then perform various operations.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Working with sets
Level: Average difficulty
Course: Python programming
Exercise: Comapre two lists of grand prix races using sets to find any differences.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Scraping websites
Level: Average difficulty
Course: Python programming
Exercise: Use BeautifulSoup to compile a list of external links for any website.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Ranges and loops
Level: Average difficulty
Course: Python programming
Exercise: Use the range and format functions to list the square roots of the first 100 integers.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Functions
Level: Average difficulty
Course: Python programming
Exercise: Create functions to parse a quotation into a list of words and get some statistics about them.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Files and folders
Level: Harder than average
Course: Python programming
Exercise: Loop over the files in a folder, reading the shopping data from each.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Sequences
Level: Harder than average
Course: Python programming
Exercise: Create a list of numbers which can not be expressed as a sum of an integer and its sum of digits.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Basic coding
Level: Harder than average
Course: Python programming
Exercise: Use an if / elif / else block to return the Hogwarts house colours for an input house name.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Ranges and loops
Level: Harder than average
Course: Python programming
Exercise: Print out ever-more-accurate estimates of the value of pi using the Leibniz series.

Go to exercise ...

Software: Python
Version: Latest version
Topic: Functions
Level: Harder than average
Course: Python programming
Exercise: Write 3 functions to complete a system to extract countries from any given CSV file.

Go to exercise ...

You can search our full list of Python exercises here. Or why not learn to do them the right way on one of our classroom Python training courses in the UK, or on one of our live online Python courses wherever you are in the world?

This page has 0 threads Add post