1. Introduction
  2. Simple Types
  3. Lists
  4. Sorting
  5. Dicts
  6. Files
  7. Fetching Data from the Internet
  8. Simple Data Analysis
  9. Exercises
    1. Basic exercises
    2. OS Names API
    3. Life expectancy tables
    4. Copy special
    5. Log puzzle

Basic Python Exercises

There are 3 exercises that go with the first sections of Google’s Python class. They are located in the “basic” directory within the google-python-exercises directory. Download the google-python-exercises.zip if you have not already (see the Set-Up page for details).

In all of the following you can see how you are doing by running the file, e.g. python3 string1.py - the manin method will run some tests and print out if your code produces the right answer. Look for the string # +++your code here+++ and replace it with your code, save the file and run it again to see if you are getting closer.

string1.py – complete the string functions in string1.py, based on the material in the Python Strings section (additional exercises available in string2.py)

list1.py – complete the list functions in list1.py, based on the material in the Python Lists and Python Sorting sections (additional exercises available in list2.py)

wordcount.py – this larger, summary exercise in wordcount.py combines all the basic Python material in the above sections plus Python Dicts and Files (a second exercise is available in mimic.py)

With all the exercises, you can take a look at our solution code inside the solution subdirectory.


Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License, and code samples are licensed under the Apache 2.0 License. For details, see our [Site Policies](https://developers.google.com/terms/site-policies.