Dataset Viewer
Auto-converted to Parquet Duplicate
text
stringlengths
0
106k
Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
Create a function to calculate the sum of a sequence of integers.
### Input:
[1, 2, 3, 4, 5]
### Output:
# Python code
def sum_sequence(sequence):
sum = 0
for num in sequence:
sum += num
return sum
Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
Generate a Python code for crawling a website for a specific type of data.
### Input:
website: www.example.com
data to crawl: phone numbers
### Output:
import requests
import re
def crawl_website_for_phone_numbers(website):
response = requests.get(website)
phone_numbers = re.findall('\d{3}-\d{3}-\d{4}', response.text)
return phone_numbers
if __name__ == '__main__':
print(crawl_website_for_phone_numbers('www.example.com'))
Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
Create a Python list comprehension to get the squared values of a list [1, 2, 3, 5, 8, 13].
### Input:
### Output:
[x*x for x in [1, 2, 3, 5, 8, 13]]
Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
Generate a python script to perform this action.
### Input:
Given a string, remove all the consecutive duplicates from the string.
Input: "AAABBCCCD"
### Output:
def remove_duplicates(string):
result = ""
prev = ''
for char in string:
if char != prev:
result += char
prev = char
return result
result = remove_duplicates("AAABBCCCD")
print(result)
Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
Write a python script to generates random numbers between 0 and 9 that are divisible by 3.
### Input:
### Output:
def generate_random_divisible_number():
import random
while True:
# Generate a random number
process = random.randint(0, 9)
# Check if the number is divisible by 3
if process % 3 == 0:
# If it is divisible, return it
return process
Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
Write a Python code to get the third largest element in a given row.
### Input:
[12, 13, 13, 45, 22, 99]
### Output:
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
49