Skip to content
← All Python tracks

Pattern Matching, f-Strings and Newer Syntax

Python

Format text with f-strings and your own format codes, branch on the shape of data with match and case, and use := and keyword-only parameters where they make code clearer. The track ends with the syntax new in Python 3.14 and 3.15.

This track uses Python. You can make it your practice mode to browse related content across the site.

15 exercises

8 articles

Explore freely. Sign in to keep your progress.

Your learning sequence

  1. 1 Not solved yet. Show Values with repr and str in f-Strings Practice · Easy
  2. 2 Not solved yet. Line Up Receipt Columns with f-Strings Practice · Easy
  3. 3 Not solved yet. Give a Class Its Own Format Codes Practice · Medium
  4. 4 Not solved yet. Format Table Rows and Money Amounts Practice · Easy
  5. 5 Not solved yet. Render a Text Table with Python 3.12 f-Strings Practice · Medium
  6. 6 When Not to Use an f-String Read
  7. 7 Branch on a Value with match and case Read
  8. 8 Not solved yet. Answer Chat Commands with match and case Practice · Easy
  9. 9 Not solved yet. Turn Status Codes into Labels with match Practice · Medium
  10. 10 Not solved yet. Match Lists and Dictionaries by Their Shape Practice · Medium
  11. 11 Not solved yet. Simplify Arithmetic Expressions with Class Patterns Practice · Medium
  12. 12 Not solved yet. Build an Event Router with Guards Practice · Medium
  13. 13 Not solved yet. Let mypy Catch a Missing Case with assert_never Practice · Hard
  14. 14 When to Use match Instead of if and elif Read
  15. 15 Not solved yet. Reuse a Computed Value with the Walrus Operator Practice · Medium
  16. 16 Not solved yet. Make Arguments Positional-Only or Keyword-Only Practice · Medium
  17. 17 Not solved yet. Decode a Config File with the Right Encoding Practice · Hard
  18. 18 Catch Several Exceptions Without Parentheses Read
  19. 19 Not solved yet. Escape HTML and Build SQL Parameters with t-Strings Practice · Hard
  20. 20 Flatten and Merge with Unpacking in Comprehensions Read
  21. 21 Speed Up Startup with Lazy Imports Read
  22. 22 Bring Old Python Code Up to Date Read
  23. 23 Write Code That Runs on Several Python Versions Read

Check yourself

5 questions · not saved while you're signed out

Use these questions to check your understanding and compare explanations. Your score does not affect track completion.

0 / 5 correct

What does this print?

Choose one answer to reveal the explanations. Answers are kept only while this page is open.

n = 42
print(f"{n=}")
Question 1 of 5