benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf ebdcd1b9-58ba-589b-9c85-c598d618b415

Problem

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

complete prompt

import json
import math


def task_func(decimal_value, precision=2):
    """
    Calculate the square root of the given decimal value to a certain precision and then encode the result as a JSON string.
    
    Parameters:
    utc_datetime (datetime): The datetime in UTC.
    precision (int, Optional): The number of decimal places to round the square root to. Defaults to 2.
    
    Returns:
    str: The square root of the decimal value encoded as a JSON string.
    
    Requirements:
    - json
    - math
    
    Example:
    >>> from decimal import Decimal
    >>> decimal_value = Decimal('3.9')
    >>> json_str = task_func(decimal_value, decimal_value)
    >>> print(json_str)
    "1.97"
    """

instruct prompt

Calculate the square root of the given decimal value to a certain precision and then encode the result as a JSON string.
The function should output with:
    str: The square root of the decimal value encoded as a JSON string.
You should write self-contained code starting with:

Code

import json
import math
def task_func(decimal_value, precision=2):

code prompt

Code

import json
import math
def task_func(decimal_value, precision=2):

entry point

task_func

libs

  • math
  • json

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