benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 74637686-f0d0-5a5a-8a9d-0fa15e8a7a5d

Problem

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

complete prompt

import os
import glob
import zipfile

def task_func(directory):
    """
    Zips all files (not including subdirectories) located in the specified directory and returns the path to the created zip file.
    
    Parameters:
    directory (str): The directory path containing the files to be zipped.
    
    Returns:
    str: The path to the generated zip file. Returns None if the directory does not contain any files.
    
    Raises:
    FileNotFoundError: if the specified directory does not exist

    Requirements:
    - os
    - glob
    - zipfile
    
    Notes:
    - The zip name is always 'files.zip'

    Example:
    >>> path = task_func('/path/to/files')
    >>> isinstance(path, str)
    True
    """

instruct prompt

Zips all files (not including subdirectories) located in the specified directory and returns the path to the created zip file.
Note that: Notes: The zip name is always 'files.zip'
The function should raise the exception for: FileNotFoundError: if the specified directory does not exist
The function should output with:
    str: The path to the generated zip file. Returns None if the directory does not contain any files.
You should write self-contained code starting with:

Code

import os
import glob
import zipfile
def task_func(directory):

code prompt

Code

import os
import glob
import zipfile
def task_func(directory):

entry point

task_func

libs

  • glob
  • zipfile
  • 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