benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 8fc259c5-e1f8-5f97-b533-9e243b4c41f8

Problem

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

complete prompt

import inspect
import types
import math

def task_func(f):
    """
    Analyzes a given function 'f' and returns a dictionary containing its name, the square root of
    the number of arguments, and the count of lambda functions present in its default values.
    This function demonstrates introspection of Python functions and the use of mathematical
    operations on the introspected data.

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

    Returns:
    dict: A dictionary containing the function's name, the square root of the number of arguments,
          and the count of lambda functions in default values.

    Requirements:
    - inspect
    - types
    - math

    Examples:
    >>> def sample_function(x, y=2): return x + y
    >>> result = task_func(sample_function)
    >>> 'sample_function' == result['function_name'] and result['sqrt_args'] == math.sqrt(2)
    True
    >>> lambda_func = lambda x: x * 2
    >>> task_func(lambda_func)['lambda_in_defaults'] == 0
    True
    """

instruct prompt

Analyzes a given function 'f' and returns a dictionary containing its name, the square root of the number of arguments, and the count of lambda functions present in its default values. This function demonstrates introspection of Python functions and the use of mathematical operations on the introspected data.
The function should output with:
    dict: A dictionary containing the function's name, the square root of the number of arguments,
    and the count of lambda functions in default values.
You should write self-contained code starting with:

Code

import inspect
import types
import math
def task_func(f):

code prompt

Code

import inspect
import types
import math
def task_func(f):

entry point

task_func

libs

  • types
  • math
  • 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