benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf e73b1ab7-9c02-5895-a097-e2e3a71b38ae
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import re
from urllib import request
import json
# Constants
IP_REGEX = r'[0-9]+(?:\.[0-9]+){3}'
def task_func(ip_address):
"""
Get the public IP address from a JSON response containing the IP address.
Parameters:
ip_address (str): JSON-formatted string containing the IP address.
Returns:
str: The public IP address.
Note:
- The function needs to check whether the provided IP address is valid.
If the IP address is not valid, the function will return 'Invalid IP address received'.
Requirements:
- re
- urllib.request
- json
Example:
>>> ip_address = '{"ip": "192.168.1.1"}'
>>> task_func(ip_address)
'192.168.1.1'
"""
instruct prompt
Get the public IP address from a JSON response containing the IP address.
Note that: The function needs to check whether the provided IP address is valid. If the IP address is not valid, the function will return 'Invalid IP address received'.
The function should output with:
str: The public IP address.
You should write self-contained code starting with:
Code
import re
from urllib import request
import json
# Constants
IP_REGEX = r'[0-9]+(?:\.[0-9]+){3}'
def task_func(ip_address):
code prompt
Code
import re
from urllib import request
import json
# Constants
IP_REGEX = r'[0-9]+(?:\.[0-9]+){3}'
def task_func(ip_address):
entry point
task_func
libs
- re
- json
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