benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 4d04af7c-e456-581a-8cfb-d203f6cb3da5

Problem

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

complete prompt

import json
import os

def task_func(file_path):
    """
    Check that the data in a JSON file is a list of dictionaries (objects in JavaScript).
    
    Parameters:
    file_path (str): The path to the JSON file.
    
    Returns:
    bool: True if the data is a list of dictionaries, False otherwise.
    
    Requirements:
    - json
    - os
    
    Example:
    >>> import tempfile
    >>> import json
    >>> temp_dir = tempfile.mkdtemp()
    >>> file_path = os.path.join(temp_dir, 'data.json')
    >>> with open(file_path, 'w') as f:
    ...     json.dump([{'name': 'Alice', 'age': 30}, {'name': 'Bob', 'age': 25}], f)
    >>> task_func(file_path)
    True
    >>> task_func('./invalid_data.json') # File does not exist
    False
    """

instruct prompt

Check that the data in a JSON file is a list of dictionaries (objects in JavaScript).
The function should output with:
    bool: True if the data is a list of dictionaries, False otherwise.
You should write self-contained code starting with:

Code

import json
import os
def task_func(file_path):

code prompt

Code

import json
import os
def task_func(file_path):

entry point

task_func

libs

  • json
  • os

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