[output] | /^abcd.*efgh$/ [instruction] | Create a regular expression that matches a string that begins with "abcd" and ends with "efgh". [input] |
[output] | function validateForm() { // check if each form element has a valid value if (formElement1.value == '' || formElement2.value == '') { alert('Please fill out all the fields!'); return false; } else { return true; } } [instruction] | Design a JavaScript program to validate forms. [input] |
[output] | address = "901 Grand Absinth Avenue,Anytown, ST, 98765" address_dict = { "street": address.split(",")[0], "city": address.split(",")[1], "state": address.split(",")[2], "zip": address.split(",")[3] } [instruction] | Insert the proper code to convert the given address from string to a dictionary. [input] | address = "901 Grand Absinth Avenue,Anytown, ST, 98765"
[output] | string = "code" reversed_str = string[::-1] print(reversed_str) # Output: edoc [instruction] | Reverse the given input string. [input] | string = "code"
[output] | def area_of_triangle(base, height): """Calculate the area of a triangle.""" area = (0.5 * base * height) return area [instruction] | Using the comment as a guide, create a function to calculate the area of a triangle. [input] |
[output] | string = "mississippi" characters = set(string) print(characters) # Output: {'i', 's', 'p', 'm'} [instruction] | Create a set of the characters present in the given string. [input] | string = "mississippi"
[output] | import random nums = [random.randint(1, 50) for _ in range(10)] print(nums) # Output: [7, 44, 15, 47, 1, 31, 29, 39, 33, 11] [instruction] | Create an array with 10 random numbers in the range of 1 to 50. [input] |
[output] | def is_year_leap(year): # leap year is divisible by 4 # However, if year is divisible by 100, then it is not a leap year # Unless year is divisible by 400 leap_year = (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0) return leap_year [instruction] | Reconstruct the given code snippet. [input] |
[output] | num = "42" num_int = int(num) print(num_int) # Output: 42 [instruction] | Create a variable to store the given number as an integer. [input] | num = "42"
[output] | def merge_lists(list1, list2): merged_list = [] i, j = 0, 0 while i < len(list1) and j < len(list2): if list1[i] <= list2[j]: merged_list.append(list1[i]) i += 1 else: merged_list.append(list2[j]) j += 1 if i == len [instruction] | Given two sorted lists of numbers, write a code to merge them. [input] | list1 = [1, 2, 3, 4] list2 = [3, 4, 5, 6]
[output] | import random def generate_password(): letters = 'abcdefghijklmnopqrstuvwxyz' numbers = '0123456789' special_characters = '@#$%^&*()' password = '' password += random.choice(letters) password += random.choice(numbers) password += random.choice(special_characters) [instruction] | Generate a random password with a combination of letters, numbers and special characters. [input] |
[output] | SELECT * FROM Employees WHERE Department IN (SELECT Department FROM Employees GROUP BY Department HAVING COUNT(DISTINCT Job) = 1) AND Job IN (SELECT Job FROM Employees GROUP BY Job HAVING COUNT(D [instruction] | Write a sql query to find all employees who have the same job and department. [input] |
[output] | SELECT name FROM users WHERE age > 18; [instruction] | Create a MySQL query to get the names of all users who are over 18. [input] |
[output] | import pandas as pd df = pd.DataFrame({ 'name': d1['name'], 'age': d1['age'], 'weight': d2['weight'], 'height': d2['height'], 'income': d3['income'], 'job': d3['job'], 'city': d4['city'], 'country': d4['country'] }) [instruction] | Construct a pandas dataframe from 4 dictionaries. [input] | d1 = { 'name' : ["Alice", "Bob", "Charlie"], 'age' : [24, 45, 37], } d2 = { 'weight' : [87, 66, 65], 'height' : [165, 179, 173], } d3 = { 'income' : [3000, 4500, 4800], 'job' : ["engineer", "teacher", "secretary"], } d4 = { 'city' : ["Glasgow", "New York", "Paris"], 'country' : ["Scotl
[output] | let powerCalc = { (base: Int, exp: Int) -> Int in return Int(pow(Double(base), Double(exp))) } [instruction] | Create a Swift closure to calculate the power of a number. [input] |
[output] | String str = "Hello, World!"; for (int i = 0; i < str.length(); i+=2) { System.out.print(str.charAt(i)); } [instruction] | Change the following Java code so that it only prints the letters at even indices in the string. [input] | String str = "Hello, World!"; for (int i = 0; i < str.length(); i++) { System.out.print(str.charAt(i)); }
[output] | <span className="highlight" ></span> [instruction] | Construct a JSX expression that renders a <span> element with className "highlight". [input] |
[output] | import math print(math.log(500)) [instruction] | Compute the natural logarithm of 500 using Python. [input] |
[output] | <html> <head> <title>Contact Page</title> </head> <body> <h1>Contact Us Now!</h1> </body> </html> [instruction] | Compose a basic HTML page to display the phrase "Contact us now!" [input] |
[output] | DELETE FROM customers WHERE last_name = 'Smith'; [instruction] | Create a SQL query to delete all customers with a last name of "Smith" [input] |
[output] | The angle of elevation can be calculated as: angle = arctan(20m/s/9.8m/s^2) = 73.189 degrees [instruction] | Calculate the angle of elevation when a ball is thrown upward with initial velocity of 20m/s [input] |
[output] | Some ideas for designing a user interface for an online database include: - Using a search bar for users to easily find the information they are looking for quickly. - Creating a filter search to allow users to narrow down relevant results as needed. - Offering a progress bar to show the status of [instruction] | Come up with some ideas to design a user interface for an online database [input] |
[output] | return (x > 0 && x < 10); [instruction] | Transform the following piece of code into a shorter version [input] | if (x > 0 && x < 10) { return true; } else { return false; }
[output] | def scramble(arr): for i in range(len(arr) - 1): j = random.randint(0, len(arr)-1) arr[i], arr[j] = arr[j], arr[i] return arr scramble([3, 7, 8, 2, 5]) [instruction] | Scramble a given array so that it appears in a random order [input] | [3, 7, 8, 2. 5]
[output] | def is_valid_sudoku(puzzle): size = len(puzzle) for row in range(len(puzzle)): seen = set() for col in range(size): number = puzzle[row][col] if number != 0: if number in seen: return False seen.add(number) for col in range(3): seen [instruction] | Create a computer algorithm to determine the validity of a sudoku puzzle [input] |
[output] | def create_matrix(n): matrix = [] for i in range(n): row = [] for j in range(n): row.append(0) matrix.append(row) return matrix [instruction] | Write a function that accepts an integer value n and creates an n by n matrix, with all elements initialised to zero. [input] |
[output] | b(a){3} [instruction] | Create a regular expression for matching the following pattern: words starting with 'b' followed by three times the letter 'a'. [input] |
[output] | False [instruction] | Return true or false for checking if a character is alphanumeric or not. [input] | A character '&'
[output] | def compute_avg(numbers): total = 0 for num in numbers: total += num return total/len(numbers) [instruction] | Write a function in Python to compute average of the numbers in a given list. [input] | [2, 4, 5, 7]
[output] | <html> <body> <form> <input type="text" id="textbox1" /><br> <input type="text" id="textbox2" /><br> <button name="submitbtn">Submit</button><br> <button name="resetbtn">Reset</button><br> </form> </body> </html> [instruction] | Write an HTML page with a form having two textboxes and two buttons. [input] |