benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf cfba5c46-b291-58fb-aec1-6b36fe93a163

Problem

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

complete prompt

import numpy as np
import matplotlib.pyplot as plt

def task_func():
    """
    Draws the linear equation y = 2x + 1 on a 2D plot for x values ranging from -10 to 10, and marks the solution for x = 2 with a green 'o' (circle) marker.

    The plot includes:
    - A red line representing the equation y = 2x + 1, labeled as 'y=2x+1', for x in [-10, 10].
    - A green circle marker indicating the solution at x = 2, y = 5.
    - Title: 'Solution of the equation y=2x+1 at x=2'
    - X-axis labeled as 'x', with a range from -10 to 10.
    - Y-axis labeled as 'y', with a range automatically adjusted based on the equation.
    - A legend indicating labels for the equation and the solution point.

    Returns:
        matplotlib.axes.Axes: An object representing the plot with specified features and ranges.

    Requirements:
        - numpy
        - matplotlib.pyplot
    
    Example:
    >>> ax = task_func()
    >>> ax.get_title()
    'Solution of the equation y=2x+1 at x=2'
    """

instruct prompt

Draws the linear equation y = 2x + 1 on a 2D plot for x values ranging from -10 to 10, and marks the solution for x = 2 with a green 'o' (circle) marker. The plot includes: - A red line representing the equation y = 2x + 1, labeled as 'y=2x+1', for x in [-10, 10]. - A green circle marker indicating the solution at x = 2, y = 5. - Title: 'Solution of the equation y=2x+1 at x=2' - X-axis labeled as 'x', with a range from -10 to 10. - Y-axis labeled as 'y', with a range automatically adjusted based on the equation. - A legend indicating labels for the equation and the solution point.
The function should output with:
    matplotlib.axes.Axes: An object representing the plot with specified features and ranges.
You should write self-contained code starting with:

Code

import numpy as np
import matplotlib.pyplot as plt
def task_func():

code prompt

Code

import numpy as np
import matplotlib.pyplot as plt
def task_func():

entry point

task_func

libs

  • numpy
  • matplotlib

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