[output] | sorted_list = sorted(tuple_list, key=lambda x: x[0]) [instruction] | Sort this list of tuples in ascending order by the first value of the tuple [input] | tuple_list = [(3,4),(5,6),(7,1)]
[output] | This sentence is an example of an imperative statement, which is an order or command given to someone to do something. The subject of the imperative sentence, "This sentence", is in the third person and the verb, "is", is in the present tense. [instruction] | Analyze the syntax of the sentence [input] | This sentence is an example of an imperative statement
[output] | import random def game(): options = ['rock', 'paper', 'scissors'] player1 = random.choice(options) player2 = random.choice(options) if player1 == 'rock' and player2 == 'scissors': print("Player 1 Wins!") elif player1 == 'paper' and player2 == 'rock': print("Pla [instruction] | Design a basic game of rock, paper, scissors [input] |
[output] | pattern = r'^\d+$' [instruction] | Write a regular expression to match any sequence of digits (ex. 10, 01, 025 ZCZ) [input] |
[output] | # Pattern 1 for i in range(1, 10): for j in range(1, i + 1): print("*", end=" ") print(" ") # Pattern 2 for i in range(10, 0, -1): for j in range(i, 0, -1): print("*", end=" ") print(" ") [instruction] | Write a Python code that prints out the following patterns: [input] |
[output] | <!DOCTYPE html> <html> <head> <title>My Page</title> </head> <body> <h1>Welcome</h1> <p>This is the first paragraph in my page.</p> <p>This is the second paragraph in my page.</p> </body> </html> [instruction] | Create an HTML page with a heading and two paragraphs. [input] |
[output] | public static int[] deleteElement(int[] arr, int pos) { int n = arr.length; int i; // Removing the element at a given position for (i = pos; i < n - 1; i++) arr[i] = arr[i+1]; // Returning the resulting array return arr; } public static void main(String[] args) { int[] arr = {1, 3, 5, [instruction] | Create a Java program to delete an element for a given position in an array. [input] | [1, 3, 5, 6, 8], position=2
[output] | # Pattern for i in range(1,6): for j in range(1,i+1): print(i,end="") print("") [instruction] | Create a Python code for printing the following pattern. [input] |
[output] | import random def random_int_1_10(): return random.randint(1, 10) if __name__ == '__main__': print(random_int_1_10()) [instruction] | Write a Python function to generate a random integer in the range of 1 to 10. [input] |
[output] | import string import random def random_password_string(): characters = string.ascii_letters + string.digits + string.punctuation password = ''.join(random.sample(characters, 8)) return password if __name__ == '__main__': print(random_password_string()) [instruction] | Generate a unique 8 character string that contains a lowercase letter, an uppercase letter, a numerical digit, and a special character. [input] |
[output] | def is_palindrome(string): string = string.lower() rev_string = string[::-1] if string == rev_string: return True return False if __name__ == '__main__': print(is_palindrome('racecar')) [instruction] | Write an algorithm to determine if an input string is a palindrome. [input] | racecar
[output] | def power_of_two(n): for i in range(0,n): print(2**i,end=" ") if __name__ == '__main__': power_of_two(8) [instruction] | Write a code to print the power of 2 up to the given limit. [input] | 8
[output] | import string import random def random_string(length): characters = string.ascii_letters + string.digits return ''.join(random.choice(characters) for i in range(length)) if __name__ == '__main__': print(random_string(10)) [instruction] | Generate a random string of a given length using different uppercase, lowercase characters, and digits. [input] |
[output] | myString := flag.String("name", "Default Value", "description") [instruction] | Create a string parameter with a default value in golang. [input] |
[output] | SELECT * FROM Employees WHERE JoinDate BETWEEN DATEADD(year, -5, GETDATE()) AND GETDATE() [instruction] | Write a query statement to find all employees who joined in the last 5 years. [input] |
[output] | #!/bin/bash array=("Hello" "World" "Natasha") array_elements=${#array[@]} max_length=0 for i in `seq 0 $(($array_elements-1))`; do length=${#array[$i]} if [ "$length" -gt "$max_length" ]; then max_length=$length fi done echo "The length of the longest string is $max_length" [instruction] | Create a bash script to print the length of the longest string in an array. [input] | array = ["Hello", "World", "Natasha"]
[output] | model = LogisticRegression() model.fit(X, y) [instruction] | Train a logistic regression classifier on the given dataset. [input] | [Dataset details] This dataset contains information on Belgian bank customers, including their credit score and risk profile. It consists of 1000 rows and 5 columns. The columns are: - Age - Credit Score - Gender - Risk Profile - Status
[output] | model = Sequential() model.add(Conv2D(32, (3, 3), activation='relu', input_shape=(150, 150, 3))) model.add(MaxPooling2D((2, 2))) model.add(Conv2D(64, (3, 3), activation='relu')) model.add(MaxPooling2D((2, 2))) model.add(Conv2D(128, (3, 3), activation='relu')) model.add(MaxPooling2D((2, 2))) m [instruction] | Implement a neural network in Keras to solve the given classification problem. [input] | [Problem description] Given a dataset of images containing cats and dogs, create a neural network in Keras to classify the images into one of the two categories.
[output] | The mean of the data is 3.77, the median is 4 and the mode is 3. [instruction] | Analyze the following data in R and identify the mean, median and mode of the data. [input] | [Data] [2, 3, 5, 6, 4, 1, 3, 6, 4]
[output] | Hill climbing is a heuristic optimization algorithm that starts with a random solution and gradually iterates over it to find the best solution. In each iteration, the algorithm looks for its neighbors and checks if they are better than the current solution. If so, then the algorithm moves to its ne [instruction] | Describe the following heuristic optimization algorithm. [input] | [Algorithm Name] Hill Climbing Algorithm
[output] | INSERT INTO Employees (column list) VALUES (value list); [instruction] | Write a SQL statement to insert a new record into the table. [input] | [Table Name] Employees
[output] | <script> function dragStart(event){ event.dataTransfer.setData("Text", event.target.id); event.dataTransfer.dropEffect = "move"; } function allowDrop(event) { event.preventDefault(); } function drop(event) { event.preventDefault(); var data = event.dataTransfer.getData("Text"); [instruction] | Using HTML and JavaScript, implement a drag and drop feature. [input] |
[output] | .model small .stack 100h .data num dw 5 .code start: mov ax, @data mov ax, num cmp ax, [num+2] ; compare current number with the next number jbe least ; if current number is lesser or equal jump to least ;code to print least number least: mov ah, 9 mov dx, offset num int 21h mov ah, 4Ch int 21 [instruction] | Write an assembly language program to check if a given number is least in its sequence. [input] |
[output] | #!/bin/bash if [[ "$1" =~ ^[0-9][A-Z]+$ ]]; then echo "Password matches the regular expression" else echo "Password does not match the regular expression" fi [instruction] | Write a Bash script to check if a given password matches the given regular expression. [input] | Regular expression: ^[0-9][A-Z]+$ Password: 123ABC
[output] | sumOfNums :: Integer -> Integer sumOfNums n = sum [1 .. n] [instruction] | Using Haskell, implement a function to calculate the sum of numbers from 1 to the given number. [input] |
[output] | SELECT * FROM table_name WHERE date_col >= DATE_SUB(CURDATE(), INTERVAL 5 DAY); [instruction] | Write SQL query to select all rows where the date value is in past 5 days. [input] |
[output] | import requests url = 'https://www.wikihow.com/Main-Page' response = requests.get(url) print(response) [instruction] | Generate a HTTP request using Python to send a GET request to https://www.wikihow.com/Main-Page [input] |
[output] | dictionary = {'name': 'John', 'age': 28} # To find the keys in dictionary keys_in_dictionary = dictionary.keys() print(keys_in_dictionary) # Output: dict_keys(['name', 'age']) [instruction] | Create a dictionary and explore its functionality by finding the keys in the dictionary. [input] | dictionary = {'name': 'John', 'age': 28}
[output] | def is_minor(age): """ Function to determine if a person is a minor or not """ if age < 18: return True else: return False # Let's test it age = 18 print(is_minor(age)) # Output: False [instruction] | Write a script in Python to take an age as an input and return a boolean which indicates if a person is a minor or not. [input] |
[output] | # Create an empty string cut_string = "" # Loop over the string for i in range(0, len(string), 4): cut_string += string[i] print(cut_string) # Output: Hoeo! [instruction] | Cut a string of characters at every fourth character. [input] | string = "Hello World!"