[output] | She_looked_up_at_the_stars_and_got_lost_in_thought_ [instruction] | Replace all punctuation marks in the following sentence with underscores. [input] | She looked up at the stars and got lost in thought.
[output] | <html> <head> </head> <body> <h1>User Details</h1> <p>John – Age: 24, Profession: Developer</p> <p>Mark – Age: 26, Profession: Designer</p> </body> </html> [instruction] | Create a HTML page to display information about a group of users. [input] | User details: John – Age: 24, Profession: Developer Mark – Age: 26, Profession: Designer
[output] | int compareObjects(Object obj1, Object obj2) { if (obj1.name == obj2.name) { return obj1.age - obj2.age; } else { return obj1.name.compareTo(obj2.name); } } [instruction] | Compare two objects and return 0 if the objects are equal, greater than 0 if the first object is larger, and less than 0 if the second object is larger. [input] | Object 1 - [name: John, age: 30] Object 2 - [name: Jane, age: 28]
[output] | <form> <label for="name">Name:</label> <input type="text" id="name" name="name" required/> <br> <label for="age">Age:</label> <input type="text" id="age" name="age" required/> <br> <label for="gender">Gender:</label> <select type="text" id="gender" name="gender" required> <option [instruction] | Create an HTML5 form to get a user's name, age, and gender. [input] |
[output] | SELECT SUM(salary) AS TotalSalarySpending FROM Empolyees WHERE MONTH(date) = 6; [instruction] | Construct a SQL query to find the total salary spending of an organization by employees in the month of June. [input] |
[output] | #logo { position: absolute; top: 0; right: 0; } [instruction] | Create a CSS style to position a logo in the top right corner of a webpage. [input] |
[output] | sum_even_num = 0 for num in [1, 4, 6, 7, 8, 12, 19]: if num % 2 == 0: sum_even_num = sum_even_num + num print(sum_even_num) [instruction] | Find the sum of all even numbers in the following list (Python code): [input] | [1, 4, 6, 7, 8, 12, 19]
[output] | def double_list(lst): output_list = [x * 2 for x in lst] return output_list [instruction] | Insert a line into the code to improve its efficiency. [input] | def double_list(lst): for i in range(len(lst)): lst[i] *= 2
[output] | let containsOnlyVowels = str => { let vowels = ["a", "e", "i", "o", "u"]; for (let i = 0; i < str.length; i++) { if (!vowels.includes(str[i])) { return false; } } return true; }; let result = containsOnlyVowels(str); console.log(result); // prints false [instruction] | Create a program to detect whether a given string contains only vowels or not. [input] | let str = "hello"
[output] | let printMultiples = (num, limit) => { for (let i = num; i <= limit; i += num) { console.log(i); } }; printMultiples(number, limit); // prints 3, 6, 9 [instruction] | Create a function to print the multiples of an integer up to a limit. [input] | let number = 3 let limit = 10
[output] | arr_copy = [] for i in arr: arr_copy.append(i) [instruction] | Create a for loop for copying an array. [input] | arr = [1, 2, 3, 4, 5]
[output] | discounted_price = '${:.2f}'.format(price * (1 - discount)) [instruction] | Format a string for a discounted price. [input] | price = 5.99 discount = 0.20
[output] | def get_user_name(user_id): sql_query = "SELECT first_name, last_name FROM user_profiles WHERE user_id = ?" user = cursor.execute(sql_query, (user_id,)) return user[0] + " " + user[1] [instruction] | Create a function that takes a user id and returns their name. [input] | user_id = 1
[output] | list[0], list[-1] = list[-1], list[0] [instruction] | Switch the positions of the first and last element in a list. [input] | list = [1, 2, 3, 4, 5]
[output] | import requests response = requests.get(API_URL) data = response.json() [instruction] | Create an HTTP request to retrieve data from an API. [input] | API_URL = "https://example.com/api/get_data"
[output] | def calculate_sum(a, b): return a + b [instruction] | Rewrite the following program snippet according to the PEP8 guidelines: [input] | def calculate_sum(a,b): return a+b;
[output] | # Function to sort a list of numbers without using Python's built-in sort function def my_sort(numbers): n = len(numbers) for i in range(n): for j in range(0, n-i-1): if numbers[j] > numbers[j+1] : numbers[j], numbers[j+1] = numbers[j+1], numbers[j] [instruction] | Create a function to sort a list of numbers without using python's built-in sort function. [input] | [3,5,4,2,1]
[output] | from bs4 import BeautifulSoup # HTML page html = '<html><a href="https://example.com">Link 1</a><a href="https://example2.com">Link 2</a></html>' soup = BeautifulSoup(html, 'html.parser') # Extracting all anchor elements in a list anchor_elements = soup.findAll('a') # Printing anchor elements f [instruction] | Parse the HTML page to extract all anchor elements [input] |
[output] | list = [1,2,3,4,5] list_length = len(list) max_val = max(list) min_val = min(list) avg_val = sum(list) / list_length # Display Output print("Maximum: ", max_val) print("Minimum: ", min_val) print("Average: ", avg_val) [instruction] | Make a program to display the maximum, minimum and average of numbers in a list [input] | [1,2,3,4,5]
[output] | def intersection(list1, list2): l1_set = set(list1) l2_set = set(list2) commons = l1_set.intersection(l2_set) return list(commons) # Example list1 = [1, 2, 3] list2 = [3, 4, 5] print(intersection(list1, list2)) [instruction] | Create a program to determine the intersecting elements of two lists [input] | list1 = [1, 2, 3] list2 = [3, 4, 5]
[output] | *_*_* _*_*_ *_*_* [instruction] | Using the given input, print a zero (or cross) pattern using asterisks (*) and underscores (_) [input] | 3
[output] | def frequency_of_odd_and_even(arr): freq_even = 0 freq_odd = 0 for i in arr: if i % 2 == 0: freq_even += 1 else: freq_odd += 1 print("Frequency of even numbers:", freq_even) print("Frequency of odd numbers:", freq_odd) [instruction] | Write a Python function that prints the frequencies of even and odd numbers in a given array. [input] | [2, 5, 4, 6, 8, 10]
[output] | class Textbox { constructor(size, position, color) { this.size = size; this.position = position; this.color = color; } showTextbox() { const textbox = document.createElement("div"); textbox.style.width = this.size + "px"; textbox.style.pos [instruction] | Create a JavaScript class that allows the user to choose the size, position and color of a textbox. [input] |
[output] | fetch("https://example.com/api/users", { method: 'POST', headers: { 'Content-type': 'application/json' }, body: JSON.stringify({name: 'John'}) }) [instruction] | Convert the given API call from cURL to Fetch [input] | curl -X POST https://example.com/api/users -H 'Content-type: application/json' -d '{ "name": "John" }'
[output] | The volume of a sphere with radius 7 cm is 1436.755 cm3. [instruction] | What is the volume of a sphere with radius 7 cm? [input] |
[output] | def compare_lists(A, B): return set(B).issubset(set(A)) [instruction] | Suppose you are given two lists A and B and you need to check if B’s elements are all in A. [input] | A = [1, 2, 3, 4, 5], B = [2, 3]
[output] | SELECT SUM(price) FROM orders WHERE customer_id = 1 and order_date > DATE_SUB(NOW(), INTERVAL 1 MONTH) [instruction] | Create a MySQL query to calculate the total price paid by customer with ID 1 in the last month. [input] |
[output] | 2.345 can be converted to binary representation by multiplying 2.345 by 2 repeatedly and taking note of the whole number of each multiplication. The binary representation of 2.345 is 10.011111. [instruction] | How would you convert a decimal number such as 2.345 to a binary representation? [input] |
[output] | Function overloading refers to using the same function name for different functions, with different parameter lists. On the other hand, function overriding refers to redefining a base class function with a child class that has the same signature. Function overriding enables the child class to have [instruction] | What is the difference between function overloading and function overriding in Java? [input] |
[output] | The code snippet is using a nested list comprehension to flatten the list ``lst``. The outer loop iterates over each sublist in the list while the inner loop iterates over each element of the sublist. As a result, the output is a flattened list containing all the elements in the original list. In th [instruction] | Explain why the following code snippet produces the output it does [input] | lst = [[1, 2], [1, 2], [3, 4]] [x for i in lst for x in i]