# chalarangelo/30-seconds-of-python

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/chalarangelo-30-seconds-of-python).**

8,826 stars · 1,249 forks · Python · CC-BY-4.0 · archived

## Links

- GitHub: https://github.com/Chalarangelo/30-seconds-of-python
- Homepage: https://www.30secondsofcode.org/python/p/1
- awesome-repositories: https://awesome-repositories.com/repository/chalarangelo-30-seconds-of-python.md

## Topics

`education` `learn-to-code` `learning-resources` `programming` `python3` `snippets` `snippets-collection` `snippets-library`

## Description

30 Seconds of Python is a curated collection of short, reusable Python code snippets designed for quick reference and immediate reuse. It provides an interactive browser that lets you explore snippets organized by tags, search across names and descriptions, and copy code to your clipboard with a single click.

The collection covers a broad range of common programming tasks, including list and dictionary operations, string formatting and manipulation, date and time calculations, and color format conversion. It also includes utilities for data transformation, such as converting between case styles, mapping values between ranges, and creating URL-friendly slugs.

The snippets are stored as individual Markdown files with YAML front matter, and the entire collection is pre-built into static HTML pages for instant loading. The browser interface displays each snippet as a self-contained card with a copy button and tag labels, and supports real-time filtering as you type.

## Tags

### Part of an Awesome List

- [Code Snippets and Examples](https://awesome-repositories.com/f/awesome-lists/learning/code-snippets-and-examples.md) — A curated collection of short, reusable Python code snippets for common programming tasks.
- [Named Tuples](https://awesome-repositories.com/f/awesome-lists/devtools/immutable-data-structures/named-tuples.md) — Provides a snippet to create lightweight, immutable data records with named field access. ([source](https://www.30secondsofcode.org/python/s/named-tuples))
- [List Element Structural Matching](https://awesome-repositories.com/f/awesome-lists/devtools/pattern-matching/variable-length-segment-matching/fixed-length-segment-matches/literal-element-sequence-matches/list-element-structural-matching.md) — Provides functions to locate list elements matching a test condition, returning first, last, or all matches. ([source](https://www.30secondsofcode.org/python/s/find-matches-list-dictionary))
- [Code Snippet Cards](https://awesome-repositories.com/f/awesome-lists/devtools/card-ui/code-snippet-cards.md) — Displays each code example as a self-contained card with a copy button and tag labels for quick scanning.

### Artificial Intelligence & ML

- [Code Snippets](https://awesome-repositories.com/f/artificial-intelligence-ml/code-snippets.md) — A curated library of short, reusable Python code snippets for common programming tasks.

### Data & Databases

- [Unique Value Filtering](https://awesome-repositories.com/f/data-databases/grouped-value-aggregations/unique-value-filtering.md) — Provides a function to remove duplicate entries from a list while preserving original order. ([source](https://www.30secondsofcode.org/python/s/filter-unique))
- [Emptiness Checks](https://awesome-repositories.com/f/data-databases/immutable-array-updates/array-element-modifiers/array-element-accessors/emptiness-checks.md) — Provides a function to check if a list contains no elements using the `not` operator. ([source](https://www.30secondsofcode.org/python/s/empty-list))
- [Sorting and Filtering Operations](https://awesome-repositories.com/f/data-databases/key-value-pair-managers/nested-dictionary-utilities/composable-dictionary-operations/sorting-and-filtering-operations.md) — Provides a wide range of list and dictionary operations including sorting, filtering, and conversion.
- [List-to-Dictionary Mappings](https://awesome-repositories.com/f/data-databases/key-value-stores/structured-object-mappings/object-linked-key-value-mappings/map-value-transformers/list-to-dictionary-mappings.md) — Provides a function to map list elements through a function and store results in a dictionary. ([source](https://www.30secondsofcode.org/python/s/dictionary-to-list))
- [Dictionary Inversion](https://awesome-repositories.com/f/data-databases/multi-value-dictionaries/dictionary-inversion.md) — Provides a function to invert a dictionary, grouping keys by their values. ([source](https://www.30secondsofcode.org/python/s/collect-dictionary))
- [Key Lookups by Value](https://awesome-repositories.com/f/data-databases/multi-value-dictionaries/key-lookups-by-value.md) — Provides a function to find dictionary keys that map to a given value. ([source](https://www.30secondsofcode.org/python/s/find-matches-list-dictionary))
- [List and Dictionary Initializers](https://awesome-repositories.com/f/data-databases/tuple-data-structures/named-tuple-structs/named-field-initializers/list-and-dictionary-initializers.md) — Provides utilities for initializing lists with values, ranges, and dates, and for creating named tuples.
- [Multi-Key Sorting](https://awesome-repositories.com/f/data-databases/user-defined-functions/sorting-key-functions/multi-key-sorting.md) — Provides a snippet to sort a list of dictionaries by multiple keys using a tuple. ([source](https://www.30secondsofcode.org/python/s/sort-dictionary-tuple-key))
- [Map Value Transformers](https://awesome-repositories.com/f/data-databases/key-value-stores/structured-object-mappings/object-linked-key-value-mappings/map-value-transformers.md) — Includes a utility that applies a transformation function to every value in a dictionary. ([source](https://www.30secondsofcode.org/python/p/2))
- [List Chunking Utilities](https://awesome-repositories.com/f/data-databases/list-chunking-utilities.md) — Splits a list into a specified number of smaller lists, distributing elements as evenly as possible. ([source](https://www.30secondsofcode.org/python/s/chunk-list))
- [Search-As-You-Type Filters](https://awesome-repositories.com/f/data-databases/search-result-filtering/search-as-you-type-filters.md) — Filters the visible snippet list in real time as the user types, matching keywords against names and tags.
- [Tag-Based Search](https://awesome-repositories.com/f/data-databases/tag-based-search.md) — Organizes snippets by user-defined tags, enabling filtered discovery without a full-text search engine.

### Development Tools & Productivity

- [Snippet Search](https://awesome-repositories.com/f/development-tools-productivity/command-options/snippet-search.md) — Provides a searchable collection of Python code snippets across names, tags, and descriptions. ([source](https://cdn.jsdelivr.net/gh/chalarangelo/30-seconds-of-python@master/README.md))
- [Date and Time Utilities](https://awesome-repositories.com/f/development-tools-productivity/date-and-time-utilities.md) — Provides functions for date difference, day addition/subtraction, and weekday detection.
- [Tag-Organized Snippet Browsers](https://awesome-repositories.com/f/development-tools-productivity/snippet-collection-loading/tag-organized-snippet-browsers.md) — Provides an interactive browser for exploring a curated collection of Python snippets organized by tags. ([source](https://cdn.jsdelivr.net/gh/chalarangelo/30-seconds-of-python@master/README.md))
- [Clipboard Copying](https://awesome-repositories.com/f/development-tools-productivity/clipboard-management/clipboard-copying.md) — Provides a one-click copy-to-clipboard utility for Python code snippets.
- [Date Arithmetic Logic](https://awesome-repositories.com/f/development-tools-productivity/date-and-time-utilities/component-based-date-time-specifications/date-period-arithmetic/date-arithmetic-logic.md) — Provides a function to add or subtract a specified number of days from a given date. ([source](https://www.30secondsofcode.org/python/p/2))
- [Date Difference Calculators](https://awesome-repositories.com/f/development-tools-productivity/duration-formatters/duration-interval-calculators/date-difference-calculators.md) — Provides a function to compute the interval between two dates in days, months, or years. ([source](https://www.30secondsofcode.org/python/p/2))
- [String Case Transformers](https://awesome-repositories.com/f/development-tools-productivity/string-case-transformers.md) — Ships utilities for converting strings between camelCase, snake_case, and kebab-case. ([source](https://www.30secondsofcode.org/python/p/1))

### Programming Languages & Runtimes

- [Date Range Iterators](https://awesome-repositories.com/f/programming-languages-runtimes/date-range-iterators.md) — Provides a function to generate a list of date objects between two dates using timedelta. ([source](https://www.30secondsofcode.org/python/s/initialize-list-with-range-value-daterange))
- [Dictionary Construction From Sequences](https://awesome-repositories.com/f/programming-languages-runtimes/dictionary-iteration/dictionary-construction-from-sequences.md) — Provides a function to combine two lists into a dictionary by pairing keys and values. ([source](https://www.30secondsofcode.org/python/s/dictionary-to-list))
- [Dictionary-to-List Conversions](https://awesome-repositories.com/f/programming-languages-runtimes/dictionary-iteration/dictionary-construction-from-sequences/dictionary-to-list-conversions.md) — Provides functions to convert between dictionaries and lists of key-value tuples. ([source](https://www.30secondsofcode.org/python/s/collect-dictionary))
- [Multi-Dimensional](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/language-features/core-conceptual-frameworks/programming-language-concepts/collection-frameworks/list-data-structures/list-comprehensions/multi-dimensional.md) — Provides a snippet to initialize a 2D list using nested list comprehensions. ([source](https://www.30secondsofcode.org/python/s/initialize-list-with-range-value-daterange))
- [Array Element Finding](https://awesome-repositories.com/f/programming-languages-runtimes/programming-utilities/data-structure-type-helpers/data-type-utilities/array-element-finding.md) — Provides functions to locate elements, indices, or keys in lists and dictionaries by condition. ([source](https://www.30secondsofcode.org/python/p/1))
- [Extremum Finding](https://awesome-repositories.com/f/programming-languages-runtimes/programming-utilities/data-structure-type-helpers/data-type-utilities/array-element-finding/extremum-finding.md) — Ships a utility to find the index of the smallest or largest element in a list. ([source](https://www.30secondsofcode.org/python/p/1))
- [Inline Expression Interpolation](https://awesome-repositories.com/f/programming-languages-runtimes/string-literal-processing/string-literal-formatting/inline-expression-interpolation.md) — Demonstrates embedding variables and expressions directly inside string literals using f-strings. ([source](https://www.30secondsofcode.org/python/s/fstrings-str-format))

### Software Engineering & Architecture

- [String Manipulation](https://awesome-repositories.com/f/software-engineering-architecture/string-validation-and-normalization/string-encodings/string-manipulation.md) — Provides string formatting with f-strings, case conversion, and prefix stripping utilities.

### User Interface & Experience

- [Numeric Range Generators](https://awesome-repositories.com/f/user-interface-experience/range-sliders/time-range-selections/numeric-range-sliders/numeric-range-generators.md) — Provides a function to generate a list of numbers within a given range. ([source](https://www.30secondsofcode.org/python/s/initialize-list-with-range-value-daterange))
- [Tag-Based Snippet Browsers](https://awesome-repositories.com/f/user-interface-experience/menu-components/command-line-browsers/command-snippet-browsers/tag-based-snippet-browsers.md) — Provides an interactive browser for exploring and searching Python code snippets by tags and descriptions.

### Web Development

- [List Initializers](https://awesome-repositories.com/f/web-development/form-field-state-management/value-initializers/list-initializers.md) — Provides snippets to initialize lists with values, numeric ranges, or date sequences. ([source](https://www.30secondsofcode.org/python/p/1))
- [Slug Generators](https://awesome-repositories.com/f/web-development/url-generators/slug-generators.md) — Provides a utility to transform any string into a URL-safe, search-engine-friendly slug. ([source](https://www.30secondsofcode.org/python/p/2))

### Content Management & Publishing

- [Code Block Copy and Download Controls](https://awesome-repositories.com/f/content-management-publishing/documentation-knowledge-management/code-display-snippets/interactive-snippet-controls/code-block-copy-and-download-controls.md) — Copies a snippet's code to the clipboard with a single click for immediate reuse. ([source](https://cdn.jsdelivr.net/gh/chalarangelo/30-seconds-of-python@master/README.md))
- [String Substitutions](https://awesome-repositories.com/f/content-management-publishing/text-placeholder-replacements/string-substitutions.md) — Demonstrates substituting values into template strings using positional arguments. ([source](https://www.30secondsofcode.org/python/s/fstrings-str-format))

### Graphics & Multimedia

- [Color Space Conversions](https://awesome-repositories.com/f/graphics-multimedia/graphics-engines-rendering/lighting-systems/lighting-control-systems/rgb-color-controllers/color-space-conversions.md) — Provides functions for converting between hexadecimal color codes and RGB component tuples.

### Scientific & Mathematical Computing

- [Numerical Range Scaling](https://awesome-repositories.com/f/scientific-mathematical-computing/numerical-range-scaling.md) — Ships a function for proportionally scaling a numeric value from one interval to another. ([source](https://www.30secondsofcode.org/python/s/num-to-range))
