benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf d23c2695-8443-5027-a7c4-3dab98f792f7
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import numpy as np
import itertools
import random
import statistics
def task_func(T1, RANGE=100):
"""
Convert elements in 'T1' to integers and create a list of random integers.
The size of the list is the sum of the integers in `T1`. Calculate and
return the mean, median, and mode of the list.
Parameters:
T1 (tuple of tuples): Each tuple contains string representations of integers which are converted to integers.
RANGE (int, optional): The upper limit for generating random integers. Default is 100.
Returns:
tuple: A tuple containing the mean, median, and mode of the generated list of random integers.
The mean and median are floats, and the mode is an integer. The calculations use the generated
list whose size is determined by the sum of converted integers from `T1`.
Requirements:
- numpy
- itertools
- random
- statistics
Raises:
statistics.StatisticsError if T1 is empty
Example:
>>> import random
>>> random.seed(42)
>>> T1 = (('13', '17', '18', '21', '32'), ('07', '11', '13', '14', '28'), ('01', '05', '06', '08', '15', '16'))
>>> stats = task_func(T1)
>>> print(stats)
(49.88, 48.0, 20)
>>> stats = task_func(T1, RANGE=50)
>>> print(stats)
(23.773333333333333, 25.0, 15)
"""
instruct prompt
Convert elements in 'T1' to integers and create a list of random integers. The size of the list is the sum of the integers in `T1`. Calculate and return the mean, median, and mode of the list.
The function should raise the exception for: statistics.StatisticsError if T1 is empty
The function should output with:
tuple: A tuple containing the mean, median, and mode of the generated list of random integers.
The mean and median are floats, and the mode is an integer. The calculations use the generated
list whose size is determined by the sum of converted integers from `T1`.
You should write self-contained code starting with:
Code
import numpy as np
import itertools
import random
import statistics
def task_func(T1, RANGE=100):
code prompt
Code
import numpy as np
import itertools
import random
import statistics
def task_func(T1, RANGE=100):
entry point
task_func
libs
- statistics
- numpy
- itertools
- random
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
initial import