Code Examples

    Browse by category

    Clean, runnable snippets in Python, C, and PHP, organized by topic. Filter by language or level, then load any example straight into the Playground.

    34 categories

    PythonBeginner

    Basics

    Learn Python fundamentals: variables, print statements, data types, arithmetic operations, and type conversion for beginners.

    5 examples
    PythonBeginner

    Loops

    Master Python loops: for loops, while loops, range function, break and continue statements with practical examples.

    5 examples
    PythonIntermediate

    Functions

    Learn Python functions: define functions, function arguments, return statements, lambda functions, and recursion with examples.

    6 examples
    PythonBeginner

    Lists

    Python lists tutorial: create lists, indexing, slicing, list methods, list comprehension, sorting, and filtering data.

    5 examples
    PythonBeginner

    Strings

    Master Python strings: string methods, slicing, formatting with f-strings, searching, and string manipulation techniques.

    5 examples
    PythonIntermediate

    Dictionaries

    Python dictionaries guide: create dictionaries, key-value pairs, access values, iteration, dictionary comprehension, and manipulation.

    5 examples
    PythonAdvanced

    OOP

    Object-oriented programming in Python: classes, inheritance, encapsulation, special methods, static and class methods.

    5 examples
    PythonIntermediate

    Tuples & Sets

    Python tuples and sets: immutable sequences, set operations, unpacking, removing duplicates, and collection techniques.

    4 examples
    PythonIntermediate

    Files & Errors

    Python file handling and error handling: read/write files, try-except-finally, exception handling, and error management.

    4 examples
    PythonBeginner

    Conditionals

    Python conditional statements: if, elif, else, ternary expressions, comparison operators, and the match statement for control flow.

    5 examples
    PythonIntermediate

    Comprehensions

    Python comprehensions: list, dictionary, set, and generator expressions for concise and readable data transformation.

    5 examples
    PythonAdvanced

    Lambda & Functional

    Functional programming in Python: lambda functions, map, filter, reduce, and sorted with custom keys for clean data processing.

    4 examples
    PythonIntermediate

    Enumerate & Zip

    Python enumerate and zip functions: loop with indexes, pair multiple iterables, and build dictionaries from parallel lists.

    4 examples
    PythonAdvanced

    Decorators

    Python decorators explained: wrap functions, add behavior, build decorators with arguments, and preserve metadata with functools.wraps.

    3 examples
    PythonAdvanced

    Generators

    Python generators and iterators: yield values lazily, build memory-efficient sequences, and use next to control iteration.

    4 examples
    PythonIntermediate

    Modules & Imports

    Python modules and imports: import standard library modules, use from imports, create aliases, and work with math and random.

    4 examples
    PythonAdvanced

    Collections Module

    Python collections module: Counter, defaultdict, namedtuple, and deque for powerful and efficient data structures.

    5 examples
    PythonAdvanced

    Regular Expressions

    Python regular expressions with the re module: search, findall, sub, and split to match and transform text patterns.

    4 examples
    PythonIntermediate

    Dates & Times

    Python datetime module: create dates, format with strftime, add timedeltas, parse strings, and calculate differences between dates.

    4 examples
    PythonIntermediate

    JSON Data

    Work with JSON in Python: parse strings with json.loads, serialize with json.dumps, format output, and access nested data.

    4 examples
    PythonAdvanced

    Type Hints

    Python type hints and annotations: annotate function parameters, return types, variables, and use Optional and typing generics.

    4 examples
    PythonAdvanced

    Recursion

    Recursion in Python: solve problems by calling a function within itself, with factorial, Fibonacci, list sums, and power examples.

    4 examples
    PythonAdvanced

    Context Managers

    Python context managers and the with statement: manage resources safely, build custom managers, and use contextlib decorators.

    3 examples
    PythonAdvanced

    Itertools

    Python itertools module: count, cycle, islice, chain, combinations, and permutations for efficient iterator building blocks.

    5 examples
    CBeginner

    C Basics

    Learn C fundamentals: printf output, variables, data types, arithmetic operators, and constants for absolute beginners.

    4 examples
    CBeginner

    C Control Flow

    Master control flow in C: if and else statements, the switch statement, for loops, and while loops with clear examples.

    4 examples
    CIntermediate

    C Functions

    Write functions in C: define and call functions, return values, recursion, and passing arguments by reference with pointers.

    4 examples
    CIntermediate

    C Arrays & Strings

    Work with arrays and strings in C: declare arrays, loop over elements, measure string length, and compare strings with string.h.

    4 examples
    CAdvanced

    C Pointers

    Understand pointers in C: read a value through a pointer, modify memory by reference, and swap two variables using pointers.

    3 examples
    PHPBeginner

    PHP Basics

    Learn PHP fundamentals: echo output, variables, data types, arithmetic, and string interpolation for beginners.

    4 examples
    PHPBeginner

    PHP Strings

    Master PHP string functions: measure length, change case, concatenate, replace, find, split, and join text.

    4 examples
    PHPIntermediate

    PHP Arrays

    Work with PHP arrays: indexed arrays, associative arrays, looping with foreach, and helpful array functions like sort and array_sum.

    4 examples
    PHPBeginner

    PHP Control Flow

    Control program flow in PHP: if, elseif, and else, for loops, while loops, and the modern match expression.

    4 examples
    PHPIntermediate

    PHP Functions

    Define functions in PHP: parameters and return values, default arguments, arrow functions, and recursion with examples.

    4 examples