benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 3fb15fe8-f31b-5b52-ac8f-6366d218e195

Problem

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

complete prompt

import urllib.request
import os
import zipfile

# Constants
TARGET_DIR = "downloaded_files"
TARGET_ZIP_FILE = "downloaded_files.zip"


def task_func(url):
    """
    Download and extract a zip file from a specified URL to a designated directory.

    Parameters:
    - url (str): The URL of the zip file.

    Returns:
    - str: The path of the directory where the contents of the zip file are extracted.

    Requirements:
      - urllib
      - os
      - zipfile

    Behavior:
    - If the target directory TARGET_DIR does not exist, it is created.
    - The zip file is downloaded from the given URL and saved locally as TARGET_ZIP_FILE.
    - The local zip file TARGET_ZIP_FILE is deleted after extraction.

    Error Handling:
    - The function does not explicitly handle errors that may occur during the download or extraction process.
      Errors such as a failed download, invalid URL, or corrupted zip file will result in an unhandled exception.

    Examples:
    >>> task_func("http://example.com/files.zip")
    'downloaded_files'
    """

instruct prompt

Download and extract a zip file from a specified URL to a designated directory. Behavior: - If the target directory TARGET_DIR does not exist, it is created. - The zip file is downloaded from the given URL and saved locally as TARGET_ZIP_FILE. - The local zip file TARGET_ZIP_FILE is deleted after extraction. Error Handling: - The function does not explicitly handle errors that may occur during the download or extraction process. Errors such as a failed download, invalid URL, or corrupted zip file will result in an unhandled exception.
The function should output with:
    str: The path of the directory where the contents of the zip file are extracted.
You should write self-contained code starting with:

Code

import urllib.request
import os
import zipfile
# Constants
TARGET_DIR = "downloaded_files"
TARGET_ZIP_FILE = "downloaded_files.zip"
def task_func(url):

code prompt

Code

import urllib.request
import os
import zipfile
# Constants
TARGET_DIR = "downloaded_files"
TARGET_ZIP_FILE = "downloaded_files.zip"
def task_func(url):

entry point

task_func

libs

  • urllib
  • 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