[output] | def print_dict_key_value(dic): for key, value in dic.items(): print(f"{key}: {value}") [instruction] | How would you print all the key-value pairs of an already existing dictionary? [input] |
[output] | def delete_all_elements(lst): del lst[:] [instruction] | How can we delete all the elements of a list in Python? [input] |
[output] | Welcome to My Program! Please select from the following menu: 1. Run Program 2. Edit Settings 3. View Logs 4. Quit Program Please enter the number of your choice: [instruction] | Create a text-based menu for a command-line program. [input] |
[output] | const parsedJSON = JSON.parse(jsonObject); const address = parsedJSON.data[0].details.address; const phone = parsedJSON.data[0].details.phone; [instruction] | Parse the following JSON object and extract the data stored in the "details" field. [input] | { "data": [ { "name": "John", "details": { "address": "123 Main St.", "phone": "000-123-4567" } } ] }
[output] | def array_int_string(arr): """Converts an array of integers into strings.""" return [str(num) for num in arr] array_int_string(arr) # returns ["1", "2", "3"] [instruction] | Write a Python function to convert an array of integers into their respective strings. [input] | arr = [1, 2, 3]
[output] | The missing number is 12. [instruction] | Find the missing number in the following array: [16, 3, 2, 11, 15, 5, 4, 14]. [input] |
[output] | INSERT INTO customers (name, age, address, city, state) VALUES ('John Smith', 32, '201 Mission Street', 'San Francisco', 'CA'); [instruction] | Insert the following data into a SQL table named "customers": Name: John Smith Age: 32 Address: 201 Mission Street City: San Francisco State: CA [input] |
[output] | multiples_of_four = [n for n in range(0, 51) if n % 4 == 0] [instruction] | Using a for loop, create a list of integers that are multiples of 4 from 0 to 50. [input] |
[output] | let book = { title: "The Cat in the Hat", author: "Dr. Seuss", pages: 60 }; [instruction] | Create a JavaScript object representing a book, with properties such as title, author and pages. [input] |
[output] | The surface area of the pyramid is 24 cm². [instruction] | Compute the surface area of a pyramid with a base area of 10 cm and a height of 7 cm. [input] |
[output] | import tkinter as tk root = tk.Tk() # design the window root.title("Calculator") root.geometry("200x250") # create the buttons button1 = tk.Button(root, text="1", width=5, height=2) button1.grid(row=0, column=0, padx=4, pady=4) button2 = tk.Button(root, text="2", width=5, height=2) button2.grid( [instruction] | Design a basic graphic user interface (GUI) for a calculator. [input] |
[output] | def max_elements(matrix): max_elements = [] for row in matrix: max_elements.append(max(row)) return max_elements [instruction] | Create an array where each element is the maximum of each row in a given matrix. [input] | [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
[output] | def int_to_binary(num): return '{0:08b}'.format(num) [instruction] | Convert this integer to its corresponding binary representation in 8 bits. [input] | 32
[output] | You can remove all blank spaces from a given string in Python using the replace() function. This function takes two arguments, the first is the substring to be replaced and the second is the substring to be inserted in its place. In this case, you can use an empty string as the second argument to re [instruction] | How can you remove all blank spaces from a given string in Python? [input] |
[output] | import json String = '{"name":"John","age":25,"city":"New York"}' # Parse the string js = json.loads(String) # Print all key-value pairs for k, v in js.items(): print(k, ":", v) [instruction] | Parse the following JSON string and print out all the key-value pairs: {“name”:”John”,”age”:25,”city”:"New York" [input] | String = '{"name":"John","age":25,"city":"New York"}'
[output] | h2 { text-decoration: underline; } [instruction] | Write a CSS rule to create a text-decoration line below the h2 element. [input] |
[output] | // This function accepts an array as argument and returns true if array is sorted, else false. let isSorted = (arr) => { // Set the initial status as true let sorted = true; // Iterate over the complete array for (let i = 0; i < arr.length - 1; i++) { // Compare adjacent eleme [instruction] | Write an algorithm for checking if an array is sorted or not. [input] | Array = [4, 1, 7, 5]
[output] | h1 { font-size: 34px; } [instruction] | Create a CSS rule to set the size for all h1 elements as 34px. [input] |
[output] | function reverseString(str) { let reversedStr = ''; for (let i = str.length - 1; i >= 0; i--) { reversedStr += str[i]; } return reversedStr; } [instruction] | Design and implement a function that takes a string as input and returns the reverse string. [input] |
[output] | UPDATE users SET age = (age + 1) WHERE id = 4; [instruction] | Create a SQL query to add 1 to a designated row in a table. [input] | Table: users Row: age Location: id = 4
[output] | arr = np.array([[7, 7, 7], [7, 7, 7]]) [instruction] | Construct a Numpy array of shape 2x3 containing all 7s. [input] |
[output] | 1. Set a variable, maxValue, and initialize it to the first element in the array. 2. Iterate through the array, comparing each element to maxValue. 3. If the element is bigger than maxValue, replace maxValue with the element. 4. When the loop is finished, save maxValue and return it as the maximum v [instruction] | Design an algorithm to get the maximum value from a given array of four elements. [input] | [-5, 2, 45, 9]
[output] | Statement coverage is a software testing metric which measures the percentage of statements in the source code which have been exercised by the test suite. Statement coverage focuses on validating that every line of source code is executed and checked. A successful statement coverage of 100% implies [instruction] | Explain what is meant by 'statement coverage' in software testing. [input] |
[output] | 1. Set a variable, secondMinimum, to the first element of the array. 2. Iterate through the array. 3. For every element check if it is smaller than secondMinimum, but bigger than the smallest element in the array. 4. If it is, set secondMinimum to that element. 5. When the iteration is finished, [instruction] | Create an algorithm to find the second minimum element from a given array of 7 elements. [input] | [87, 34, 56, 12, 21, 45, 67]
[output] | SELECT * FROM user_data WHERE age >= 20; [instruction] | Write a SQL query to select users whose age is greater than or equal to 20 from the user_data table. [input] |
[output] | <html> <head> <title>Number Table</title> </head> <body> <table> <tr> <th>Number</th> </tr> {% for number in range(1, 11) %} <tr> <td>{{number}}</td> </tr> {% endfor %} </table> </body> </html> [instruction] | Generate a web page containing an HTML table containing the numbers from 1 to 10. [input] |
[output] | def merge(l1, l2): l3 = l1 + l2 return l3 [instruction] | Develop a function to merge two lists l1 and l2 into a single list. [input] | 1. l1 = [3, 4, 5] 2. l2 = [7, 8]
[output] | def print_paths(root): path = [] print_paths_util(root, path, 0) def print_paths_util(root, path, pathLen): if root is None: return if (len(path) > pathLen): path[pathLen] = root.data else: path.append(root.data) pathLen = pathLen + 1 [instruction] | Create a function to print all the paths in a binary tree. [input] |
[output] | d = { "one" : 1, "two" : 2, "three" : 3 } [instruction] | Write a Python program to create a dictionary with three elements. [input] |
[output] | #!/bin/bash # Get the current date in the format "year-month-date" date +"%Y-%m-%d" [instruction] | Write a Bash script to print the system date in the format "year-month-date". [input] |