[output] | The mean of the data set is 5.5. [instruction] | Compute the mean of the given data set. [input] | Data set: {4, 5, 6, 7}
[output] | The equivalent Fahrenheit measurement is 68 degrees Fahrenheit. [instruction] | Convert the following temperature to its equivalent Fahrenheit measurement. [input] | Temperature: 20 degrees Celsius
[output] | [1, 2, 4, 6, 9] [instruction] | Find the output of the following array after sorting it in ascending order. [input] | array = [6, 2, 9, 4, 1]
[output] | [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] [instruction] | Generate a Fibonacci number sequence with n numbers [input] | 10
[output] | ['AAA', 'AAB', 'AAC', 'ABA', 'ABB', 'ABC', 'ACA', 'ACB', 'ACC', 'BAA', 'BAB', 'BAC', 'BBA', 'BBB', 'BBC', 'BCA', 'BCB', 'BCC', 'CAA', 'CAB', 'CAC', 'CBA', 'CBB', 'CBC', 'CCA', 'CCB', 'CCC'] [instruction] | Generate all possible strings of length n using A, B and C [input] | 3
[output] | 33 [instruction] | Given an array with n elements, find the maximum element of the array. [input] | [1, 10, 5, 33, 4]
[output] | True [instruction] | Write a Python program to check if a substring is present in a set of strings [input] | substring: "abc" strings: ["hoabcll", "aaabcbc", "abcbal"]
[output] | "ccc" [instruction] | You need to delete a given pattern of characters from a string [input] | string: "aaabbbccc" pattern: "ab"
[output] | <?php $string = 'This apple is red and this apple is green'; $string = str_replace('apple', 'orange', $string); echo $string; // Output: This orange is red and this orange is green ?> [instruction] | Use PHP to replace all occurances of the word 'apple' with the word 'orange' in a given string. [input] | string = 'This apple is red and this apple is green'
[output] | def filter_list(numbers): return [x for x in numbers if x % 3 == 0] filter_list(numbers) # Output: [3, 6, 9] [instruction] | Use Python to filter out all the numbers divisible by 3 from a given list. [input] | numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
[output] | def alphabeticSort(words): words.sort() return words alphabeticSort(words) # Output: ['a', 'hello', 'is', 'test', 'this'] [instruction] | Create an algorithm that sorts an array of words in alphabetical order. [input] | words = [ 'hello', 'this', 'is', 'a', 'test' ]
[output] | CREATE TABLE contacts ( contact_id int NOT NULL AUTO_INCREMENT, first_name varchar (50) NOT NULL, last_name varchar (50) NOT NULL, email varchar (255) NOT NULL, phone_number varchar (25) NOT NULL, PRIMARY KEY (contact_id) ); [instruction] | Build a SQL table to store customer contacts. [input] |
[output] | Yes, this string can be used as a valid e-mail. [instruction] | Check if the following string can be used as a valid e-mail [input] | String: myName@domain
[output] | <form method="post" action="process.php"> <label>Email address:</label> <input type="email" name="user_email" required> <input type="submit" value="Submit"> </form> [instruction] | Create an HTML form that can process the user's email address. [input] |
[output] | .gradient { background: linear-gradient(rgba(19,72,155,0.63), rgba(8,48,107,0.63)); } [instruction] | Design a CSS class for displaying a gradient transparent background. [input] |
[output] | Yes, the statement is a valid Python syntax. [instruction] | Check if the following statement is a valid python syntax [input] | Statement: for x in range(0, len(listname))
[output] | function findLargest(numArray) { var largest = numArray[0]; var secondLargest; for( var i = 1; i < numArray.length; i++ ) { if( numArray[i] > largest ) { secondLargest = largest; largest = numArray[i]; } else if ( numArray[i] > secondLargest ) { secondLargest = [instruction] | Create a JavaScript function for finding two largest numbers among a given array of numbers [input] | Array of numbers: [3, 6, 8, 5, 9, 1]
[output] | def find_words(s, words): occurrence_indices = [] for word in words: start = 0 while True: index = s.find(word, start) if index == -1: break else: occurrence_indices.append(index) start = inde [instruction] | Given a string s and a list of words words, write a program to find all occurrences of words in the string s. [input] | s = 'The quick brown fox jumps over the lazy dog.' words = ['quick', 'fox', 'dog']
[output] | import random import string def random_string(): letters = string.ascii_letters + string.digits return ''.join(random.choice(letters) for i in range(8)) [instruction] | Generate a random string of length 8 with characters from a-zA-Z0-9. [input] |
[output] | def remove_string(s, t): if t not in s: return s s = s.lower() t = t.lower() indices = [] start = 0 while True: index = s.find(t, start) if index == -1: break indices.append(index) start = index + 1 offset = 0 for in [instruction] | Implement a function to remove all occurrences of string t from string s. [input] | s = 'The quick brown fox jumps over the lazy dog.' t = 'the'
[output] | class Vector(): def __init__(self, vector, scaler): self.vector = vector self.scaler = scaler def add_vector(self, other_vector): result_vector = [] for i in range(len(self.vector)): result_vector.append(self.vector[i] + other_vector.vector[i]) [instruction] | Implement a class to represent a vector, with initial vector and a scaler. Include methods to add, subtract and multiply two vectors. [input] |
[output] | def combine_lists(list1, list2): dictionary = dict() for i in range(len(list1)): dictionary[list1[i]] = list2[i] return dictionary [instruction] | Given two lists of strings, write a program to combine them into a dictionary whose keys are the strings in one list and values are the strings in the other list. [input] | list1 = [“cat”, “dog”, “horse”] list2 = [“meow”, “bark”, “neigh”]
[output] | def edit_strings(s1, s2): s1_arr = list(s1) s2_arr = list(s2) i = 0 while i < len(s1): if s1[i] == s2[i]: i += 1 else: # remove character del s1_arr[i] if s1_arr == s2_arr: return 'removal' # [instruction] | Given two strings s1 and s2, write a program to edit s1 to s2 by removing, inserting or replacing one character in s1. [input] | s1 = “cat” s2 = “hat”
[output] | def is_palindrome(s): n = len(s) for i in range(n//2): if s[i] != s[n-1-i]: return False return True [instruction] | Given a string s, write a program to classify it as a palindrome or not. [input] | s = “malayalam”
[output] | A hash table data structure can be used to store the given data. The name will be used as the key and then an associative array or a structure can be used to store the phone number and address associated with the name. [instruction] | Describe a data structure for storing the given data. [input] | Name, Phone number, Address
[output] | def get_third_item(linked_list): curr_node = linked_list for i in range(2): curr_node = curr_node.next # Moves onto the third item. return curr_node.data # Returns the data of the third item. [instruction] | Retrieve the third item from a linked list. [input] |
[output] | i = 0 while i < 5: print(i) i += 1 [instruction] | Convert the given code by replacing for loop with a while loop. [input] | for i in range(5): print(i)
[output] | words = text.split() freq_dict = {} for word in words: if word in freq_dict.keys(): freq_dict[word] += 1 else: freq_dict[word] = 1 sorted_words = sorted(freq_dict.items(), reverse=True, key=lambda x: x[1]) second_highest_freq_word = sorted_words[1][0] print(second_highest_fre [instruction] | Retrieve the word with the second highest frequency from a given text. [input] | Text: This is a sample text with a lot of words.
[output] | def total_amount(initial, interest): total = initial for i in range(1, 5): total += total * (interest/100) return total [instruction] | Create a function that calculates the total amount of money after 5 years given an initial amount of money and a certain rate of interest. [input] | Initial amount: 1000 Rate of interest: 2%
[output] | The code will not print out "Done" as it is inside an infinite loop. To fix this, we can either remove the 'break' statement or add an else statement after the if statement as a way of exiting the loop when the condition is not satisfied. words = ['hello', 'world', 'foo', 'bar'] for i in words: [instruction] | Debug the given code and explain your solution. [input] | words = ['hello', 'world', 'foo', 'bar'] for i in words: if i == 'foo': break print('Done')