[output] | This is a regression problem because it is trying to predict a continuous, numerical value (the future value of a stock). [instruction] | Classify this problem as either a classification or a regression problem. [input] | Predict the future value of a stock based on past data.
[output] | SELECT customers.customer_name, SUM(orders.order_amount) AS total_orders FROM customers LEFT JOIN orders ON customers.customer_id = orders.customer_id GROUP BY customers.customer_id [instruction] | Generate a correct SQL query to return all customers' names and their total orders. [input] | Table Name: customers Table Structure: customer_id, customer_name, customer_address Table Name: orders Table Structure: customer_id, order_id, order_amount
[output] | SELECT * FROM Student st INNER JOIN School sc ON st.schoolID = sc.schoolID [instruction] | Correct the error in the given SQL query. [input] | SELECT * FROM Student st INNERJOIN School sc ON st.schoolID = sc.student
[output] | class Student: def __init__(self, name, age): self.name = name self.age = age self.grade = None [instruction] | Add a class attribute to the given Python class. [input] | class Student: def __init__(self, name, age): self.name = name self.age = age
[output] | [[0, 0], [0, 0], [0, 0]] [instruction] | Generate a matrix with specific number of row and columns [input] | Number of rows = 3, number of columns = 2
[output] | def empty_func(x): pass [instruction] | Create an empty function that takes input as a string [input] |
[output] | 7.5 [instruction] | Using a given dataframe, find out the largest value in the column 'A' [input] | A B 3.2 4.9 7.5 1.0 0.2 0.5
[output] | def prints(word, count=0): for i in range(count): print(word) [instruction] | Replace the placeholder text with a valid statement that sets the default value for the 'count' parameter of the function [input] | def prints(word, count=TODO): for i in range(count): print(word)
[output] | for i in range(5): print("I love Python") [instruction] | Create a loop to print "I love Python" five times [input] |
[output] | my_list[-1] [instruction] | Take in a list and output the last element [input] | my_list = [1, 2, 3, 4]
[output] | def encrypt_string(string): encrypted_string = "" for char in string: encrypted_string += chr(ord(char) + 5) return encrypted_string [instruction] | Write code to encrypt a string [input] |
[output] | sorted_list = sorted(my_list, key=lambda x: x[1]) [instruction] | Sort a given list by the second element of each pair [input] | my_list = [(2, 9), (1, 4), (3, 5)]
[output] | i = 0 while i < len(my_list): print(my_list[i]) i += 1 [instruction] | Create a while loop to iterate over the elements in the given list [input] | my_list = [1, 2, 3, 4]
[output] | def find_min(numbers): min_value = numbers[0] for n in numbers: if n < min_value: min_value = n return min_value if __name__ == '__main__': numbers = [1, 15, 22, -5, 87] print(find_min(numbers)) [instruction] | Find the minimum among a list of integers. [input] | [1, 15, 22, -5, 87]
[output] | 2,000 meters is equal to 2 kilometers. [instruction] | How many km are in 2,000 meters? [input] |
[output] | if (num > 0) { System.out.println(num + " is a positive number"); } else { System.out.println(num + " is a negative number"); } [instruction] | Using an If statement, output whether a given number is positive or negative. [input] | int num = -25
[output] | """ Generate a random DNA sequence of length 50 """ import random def random_dna_sequence(length): bases = ["A","T","G","C"] sequence = "".join([random.choice(bases) for _ in range(length)]) return sequence if __name__ == '__main__': print(random_dna_sequence(50)) [instruction] | Generate a random DNA sequence of length 50. [input] |
[output] | <html> <head> <style> body { background-image: url("background.jpg"); background-size: cover; background-blur: 10px; } .container { position: relative; text-align: center; } </style> </head> <body> <div class="containe [instruction] | Create an HTML page with a blurred background and centered text "Hello World". [input] |
[output] | import requests # Creating list of words list = ["hello", "world", "fksgks"] # Iterating in the list of words for i in list: url = "https://www.dictionary.com/browse/"+i try: webpage = requests.get(url) # Valid word if request status # code is 200 [instruction] | You need to check a given list of strings to determine it contains all valid English words. Output true if so, output false otherwise. [input] | list = ["hello", "world", "fksgks"]
[output] | def rotateMatrix(matrix): N = len(matrix[0]) for i in range(N // 2): for j in range(i, N - i - 1): temp = matrix[i][j] matrix[i][j] = matrix[N - 1 - j][i] matrix[N - 1 - j][i] = matrix[N - 1 - i][N - 1 - j] matrix[N - 1 - i][N - 1 - j] [instruction] | Given a matrix, write a program to rotate it by 90 degrees clockwise. [input] | matrix = [[1,2,3], [4,5,6], [7,8,9]]
[output] | def reverse_dict(d): new_d = {v:k for k, v in d.items()} return new_d d = {"apple": 1, "banana": 2, "carrot": 3} print(reverse_dict(d)) [instruction] | Given a dictionary, write a program to create a new dictionary where the values are the keys and the keys are the values. [input] | {"apple": 1, "banana": 2, "carrot": 3}
[output] | import json def parse_json(json_str): data = json.loads(json_str) for key, values in sorted(data.items()): print(key, "=", values) parse_json('{"orange": 4, "apple": 1, "banana": 2 }') [instruction] | Parse a JSON string and print all the key-value pairs in alphabetical order. [input] | { "orange": 4, "apple": 1, "banana": 2 }
[output] | from bs4 import BeautifulSoup html_content = ''' <html> <head><title>HTML Example</title></head> <body> <h1>Example Page</h1> <p>This is an example of a HTML page.</p> </body> </html> ''' soup = BeautifulSoup(html_content, 'html.parser') page_title = soup.title.string print(page_title) [instruction] | Create a script that extracts the page titles from the given HTML page. [input] | <html> <head><title>HTML Example</title></head> <body> <h1>Example Page</h1> <p>This is an example of a HTML page.</p> </body> </html>
[output] | nums = [1,2,3,4,5,6] odd_nums = [] even_nums = [] for num in nums: if num % 2 == 0: even_nums.append(num) else: odd_nums.append(num) print('Odd numbers:', odd_nums) print('Even numbers:', even_nums) [instruction] | Create a program to group the numbers in the given list into odd and even groups. [input] | [1,2,3,4,5,6]
[output] | #!/bin/bash sum=0 for i in "$@"; do ((sum+=i)) done echo "$sum" [instruction] | Construct a shell script to find the sum of the given numbers. [input] |
[output] | import requests def get_content(url): response = requests.get(url) html = response.content return html [instruction] | Design a function to take a URL and return the content of the URL. [input] |
[output] | public class Person { private String name; private int age; public Person(String name, int age) { this.name = name; this.age = age; } public String getName() { return name; } public int getAge() { return age; } } [instruction] | Create a class in Java for a Person object with two fields, name and age. [input] |
[output] | <form action=""> <input type="text" name="num" placeholder="Enter a number" /> <input type="text" name="sq_root" placeholder=" Square Root" /> <input type="submit" value="Submit"/> </form> [instruction] | Write an HTML form with two text boxes, one to enter a number and another to enter the number of its square root. [input] |
[output] | def validate_email(email): regex = '^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$' if re.search(regex,email): return True else: return False [instruction] | Create a function to check the validity of an email address. [input] |
[output] | def max_sum_subarray(arr, k): max_sum = 0 for i in range(len(arr) - k + 1): curr_sum = 0 for j in range(i, i + k): curr_sum += arr[j] max_sum = max(max_sum, curr_sum) return max_sum [instruction] | Find the maximum sum of a subarray of size 'k' in a given array. [input] | arr = [1, 4, 2, 10, 23, 3, 1, 0, 20] k = 4