Read a chapter of the book
before you start each set.

A Smarter Way to Learn Python

A Smarter Way to Learn Python Practice Exercises

Click to select a chapter to practice.

  1. print
  2. Variables for Strings
  3. Variables for Numbers
  4. Math expressions: Familiar operators
  5. Variable Names Legal and Illegal
  6. Math expressions: Unfamiliar operators
  7. Math expressions: Eliminating ambiguity
  8. Concatenating text strings
  9. if statements
  10. Comparison operators
  11. else and elif statements
  12. Testing sets of conditions
  13. if statements nested
  15. Lists
  16. Lists: Adding and changing elements
  17. Lists: Taking slices out of them
  18. Lists: Deleting and removing elements
  19. Lists: popping elements
  20. Tuples
  21. for loops
  22. for loops nested
  23. Getting information from the user and converting strings and numbers
  24. Changing case
  25. Dictionaries: What they are
  26. Dictionaries: How to code one
  27. Dictionaries: How to pick information out of them
  28. Dictionaries: The versatility of keys and values
  29. Dictionaries: Adding items
  30. Dictionaries: Removing and changing items
  31. Dictionaries: Looping through values
  32. Dictionaries: Looping through keys
  33. Dictionaries: Looping through key-value pairs
  34. Creating a list of dictionaries
  35. How to pick information out of a list of dictionaries
  36. How to append a new dictionary to a list of dictionaries
  37. Creating a dictionary that contains lists
  38. How to get information out of a list within a dictionary
  39. Creating a dictionary that contains a dictionary
  40. How to get information out of a dictionary within another dictionary
  41. Functions
  42. Functions: Passing them information
  43. Functions: Passing information to them a different way
  44. Functions: Assigning a default value to a parameter
  45. Functions: Mixing positional and keyword arguments
  46. Functions: Dealing with an unknown number of arguments
  47. Functions: Passing information back from them
  48. Using functions as variables (which is what they really are)
  49. Functions: Local vs. global variables
  50. Functions within functions
  51. While loops
  52. While loops: Setting a flag
  53. Classes
  54. Classes: Starting to build the structure
  55. Classes: A bit of housekeeping
  56. Classes: Creating an instance
  57. Classes: A little more complexity
  58. Classes: Getting info out of instances
  59. Classes: Building functions into them
  60. Classes: Coding a method
  61. Classes: Changing an attribute's value
  62. Data files
  63. Data files: Storing data
  64. Data files: Retrieving data
  65. Data files: Appending data
  66. Modules
  67. CSV files
  68. CSV files: Reading them
  69. CSV files: Picking information out of them
  70. CSV files: Loading information into them. Part 1
  71. CSV files: Loading information into them. Part 2
  72. CSV files: Loading information into them. Part 3
  73. CSV files: Appending rows to them
  74. How to save a Python list or dictionary in a file: JSON
  75. How to retrieve a Python list or dictionary from a JSON file
  76. Planning for things to go wrong
  77. A more practical example of exception handling