benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 37b6a21a-a7bd-5747-8b66-963eeddd6d39

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import inspect
import types

def task_func(f):
    """
    Inspects a given function 'f' and returns its specifications, including the function's name,
    whether it is a lambda function, its arguments, defaults, and annotations. This method
    utilizes the inspect and types modules to introspect function properties.

    Parameters:
    f (function): The function to inspect.

    Returns:
    dict: A dictionary containing details about the function, such as its name, if it's a lambda function,
          arguments, default values, and annotations.

    Requirements:
    - inspect
    - types

    Examples:
    >>> def sample_function(x, y=5): return x + y
    >>> result = task_func(sample_function)
    >>> 'sample_function' == result['function_name'] and len(result['args']) == 2
    True
    >>> lambda_func = lambda x: x * 2
    >>> task_func(lambda_func)['is_lambda']
    True
    """

instruct prompt

Inspects a given function 'f' and returns its specifications, including the function's name, whether it is a lambda function, its arguments, defaults, and annotations. This method utilizes the inspect and types modules to introspect function properties.
The function should output with:
    dict: A dictionary containing details about the function, such as its name, if it's a lambda function,
    arguments, default values, and annotations.
You should write self-contained code starting with:

Code

import inspect
import types
def task_func(f):

code prompt

Code

import inspect
import types
def task_func(f):

entry point

task_func

libs

  • types
  • inspect

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import