Skip to content
Guest
Learn Python · Course Syllabus Show lessons
Pythonic Patterns · 8 min read · Beginner

Comprehensions & Built-In Functions

Write expressive Pythonic one-liners with list comprehensions, sum(), min(), max(), sorted(), and set deduplication.

What you'll learn

  • Transform and filter lists cleanly using list comprehensions
  • Summarize data quickly with sum(), len(), min(), max(), and sorted()

List comprehensions are one of Python’s signature superpowers. They replace multi-line for + .append() loops with one clear expression:

scores = [65, 88, 92, 74, 95]
passing = [s for s in scores if s >= 80]
# [88, 92, 95]

Fill-in-the-Blank Exercise

Python List Comprehension

Build a list of doubled numbers for every n in nums that is greater than 0.

doubled = [n * 2  n in nums  n > 0]

Try It Yourself

PythonComprehensions & Built-Ins
Python Output (WebAssembly / Pyodide)

Click Run Python to execute real Python 3 right in your browser.

Check Your Understanding

Score: 0 / 1

1. What does `[x * 2 for x in [1, 2, 3]]` evaluate to?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind