benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf 03f3fdb3-1b8a-5826-bcb5-18fd63197eb2
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import pandas as pd
import numpy as np
from random import randint
# Constants
STUDENTS = ['Joe', 'Amy', 'Mark', 'Sara', 'John', 'Emily', 'Zoe', 'Matt']
COURSES = ['Math', 'Physics', 'Chemistry', 'Biology', 'English', 'History', 'Geography', 'Computer Science']
def task_func():
"""
Generates a DataFrame containing random grades for a predefined list of students across a set of courses.
Each student will have one grade per course and an average grade calculated across all courses.
Returns:
DataFrame: A pandas DataFrame with columns for each student's name, their grades for each course,
and their average grade across all courses.
Requirements:
- pandas
- numpy
- random
Note:
The grades are randomly generated for each course using a uniform distribution between 0 and 100.
Example:
>>> random.seed(0)
>>> grades = task_func()
>>> print(grades[['Name', 'Average Grade']].to_string(index=False))
Name Average Grade
Joe 51.875
Amy 53.250
Mark 53.750
Sara 47.125
John 55.250
Emily 48.625
Zoe 63.750
Matt 54.750
"""
instruct prompt
Generates a DataFrame containing random grades for a predefined list of students across a set of courses. Each student will have one grade per course and an average grade calculated across all courses.
Note that: The grades are randomly generated for each course using a uniform distribution between 0 and 100.
The function should output with:
DataFrame: A pandas DataFrame with columns for each student's name, their grades for each course,
and their average grade across all courses.
You should write self-contained code starting with:
Code
import pandas as pd
import numpy as np
from random import randint
# Constants
STUDENTS = ['Joe', 'Amy', 'Mark', 'Sara', 'John', 'Emily', 'Zoe', 'Matt']
COURSES = ['Math', 'Physics', 'Chemistry', 'Biology', 'English', 'History', 'Geography', 'Computer Science']
def task_func():
code prompt
Code
import pandas as pd
import numpy as np
from random import randint
# Constants
STUDENTS = ['Joe', 'Amy', 'Mark', 'Sara', 'John', 'Emily', 'Zoe', 'Matt']
COURSES = ['Math', 'Physics', 'Chemistry', 'Biology', 'English', 'History', 'Geography', 'Computer Science']
def task_func():
entry point
task_func
libs
- pandas
- numpy
- 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