benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 57a34e4f-c51d-54a2-9396-986df5ce8b45

Problem

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

complete prompt

import sqlite3
from random import choice, seed
import os


def task_func(db_name, table_name, num_entries, random_seed=None):
    """
    Create an SQLite3 table and fill it with random data using the provided database and table names.

    The function populates the table with columns 'name', 'age', 'height' using random data from the
    following constants:
    - NAMES: List of names ['John', 'Jane', 'Steve', 'Emma', 'Liam', 'Olivia']
    - AGES: Range of ages from 18 to 65.
    - HEIGHTS: Range of heights from 150cm to 200cm.

    Parameters:
    db_name (str): The name of the SQLite3 database.
    table_name (str): The name of the table to create and populate.
    num_entries (int): The number of entries to insert. Must not be negative.
    random_seed (int, optional): The seed for generating random values. Default is None.

    Returns:
    str: The absolute path of the SQLite3 database file.

    Raises:
    ValueError: If num_entries is negative.
    
    Requirements:
    - sqlite3
    - random.choice
    - random.seed
    - os

    Example:
    >>> db_path = task_func('test.db', 'People', 100, random_seed=42)
    >>> print(db_path)
    '/absolute/path/to/test.db'
    """

instruct prompt

Create an SQLite3 table and fill it with random data using the provided database and table names. The function populates the table with columns 'name', 'age', 'height' using random data from the following constants: - NAMES: List of names ['John', 'Jane', 'Steve', 'Emma', 'Liam', 'Olivia'] - AGES: Range of ages from 18 to 65. - HEIGHTS: Range of heights from 150cm to 200cm.
The function should raise the exception for: ValueError: If num_entries is negative.
The function should output with:
    str: The absolute path of the SQLite3 database file.
You should write self-contained code starting with:

Code

import sqlite3
from random import choice, seed
import os
def task_func(db_name, table_name, num_entries, random_seed=None):

code prompt

Code

import sqlite3
from random import choice, seed
import os
def task_func(db_name, table_name, num_entries, random_seed=None):

entry point

task_func

libs

  • sqlite3
  • random
  • 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