[output] | * { font-size: 14px; } [instruction] | Using CSS, write a code to set the font size of all the HTML elements on the page to 14px [input] |
[output] | SELECT name FROM Employees WHERE salary > (SELECT AVG(salary) FROM Employees); [instruction] | Write a SQL query to find the names of the people who have a salary greater than the average salary. [input] | Table name: Employees Columns: id, name, salary
[output] | def reverseString(string): return string[::-1] print(reverseString(string)) # Output: !dlrow olleH [instruction] | Create a Python function that takes a string and prints out its reverse. [input] | string = "Hello world!"
[output] | @app.route('/store_data', methods=['POST']) def store_data(): data = request.get_json() first_name = data['first_name'] last_name = data['last_name'] db.execute("INSERT INTO users (first_name, last_name) VALUES (%s, %s)", (first_name, last_name)) db.commit() return jsonify(message="Data [instruction] | Write a Flask route to store the inputted data in the database. [input] | url: '/store_data' data: { first_name: 'John', last_name: 'Doe' }
[output] | const array = [ { id: 1, firstName: 'John', lastName: 'Doe', age: 20 }, { id: 2, firstName: 'Jane', lastName: 'Smith', age: 21 }, { id: 3, firstName: 'Mike', lastName: 'Williams', age: 22 } ]; [instruction] | Create an array of objects in JavaScript for the following data: id, first name, last name, age. [input] |
[output] | SELECT * FROM employees WHERE salary > 40000; [instruction] | Write a MySQL query to fetch all the employees with the salary greater than 40,000. [input] |
[output] | class TableViewController: UITableViewController { override func viewDidLoad() { super.viewDidLoad() tableView.dataSource = self } override func numberOfSections(in tableView: UITableView) -> Int { // Number of sections your table view has return 1 [instruction] | Create an iOS table view to display the list of items. [input] |
[output] | <table> <tr> <th>Name</th> <th>Email</th> <th>Phone Number</th> </tr> <tr> <td>John Doe</td> <td>john@example.com</td> <td>123-456-7890</td> </tr> </table> [instruction] | Generate an HTML table with 3 columns for Name, Email and Phone Number. [input] |
[output] | def calculate_mean(numbers) sum = 0 numbers.each { |number| sum += number } return (sum.to_f / numbers.length) end [instruction] | Create a Ruby method for calculating the mean of the given array of numbers. [input] |
[output] | my_dict = {'name': 'John', 'age': 25} [instruction] | Create a python dictionary of two elements 'name' and 'age' with the corresponding values John and 25. [input] |
[output] | def calculate_factorial(num): if num == 0 or num == 1: return 1 else: return num * calculate_factorial(num-1) [instruction] | Implement a recursive function to calculate the factorial of a number, given by the user as an argument. [input] |
[output] | dict = {1:1, 3:3, 5:5} total = 0 for num in dict.values(): total += num [instruction] | Edit the following code to use a dictionary instead of a list. [input] | list = [1, 3, 5] total = 0 for num in list: total += num
[output] | pairs = [] for i in range(len(list)): for j in range(i+1, len(list)): pairs.append((list[i], list[j])) print(pairs) [instruction] | Create a code to display all unique pairs from the following list. [input] | [1,2,3,4,5,6]
[output] | import random myList = [] for i in range(10): myList.append(random.randint(0,10)) print(myList) [instruction] | Write code to create a list of length 10 with random integers. [input] |
[output] | my_list = [] for i in range(1, 10): my_list.append(str(i) + "abc") print(my_list) [instruction] | Generate a sequence of strings according to the following pattern: [input] |
[output] | SELECT category, COUNT(*) FROM table_name GROUP BY category; [instruction] | Write a SQL query to group the data based on 'category' and counting the number of entries in each category. [input] |
[output] | def sort_list(list): for i in range(len(list)): for j in range(0, len(list)-i-1): if len(list[j]) < len(list[j+1]): list[j], list[j+1] = list[j+1], list[j] return list sort_list(["Hello", "World", "Technology"]) [instruction] | Format the following list in descending order of number of characters in each string. [input] | list = ['Hello', 'World', 'Technology']
[output] | my_dict = dict([('a', 1), ('b', 2)]) print(my_dict) [instruction] | Generate a dictionary with the following entries [input] | [('a',1),('b',2)]
[output] | class Student { private: int id; string name; int age; string gender; public: int getId() const; void setId(int id); string getName() const; void setName(string name); int getAge() const; void setAge(int age); string getGender() const; void setGen [instruction] | Create a C++ class called 'Student' with the following fields: id, name, age, and gender. [input] |
[output] | ^[a-z0-9_.]+@[a-z0-9_.]+[.]+[a-z]+$ [instruction] | Write a regular expression which can validate a given email address. [input] |
[output] | SELECT * FROM employees WHERE salary >= 40,000; [instruction] | Create a PostgreSQL query to find all employees with a salary greater than or equal to 40,000. [input] |
[output] | The maximum value an int type can hold is 2147483647. [instruction] | What is the maximum value an int type can hold? [input] |
[output] | ['The', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog.'] [instruction] | Take a sentence and tokenize it into separate words. [input] | The quick brown fox jumps over the lazy dog.
[output] | 22 [instruction] | Calculate the result of 3 \* 5 + 7. [input] |
[output] | def same_output(input): return input [instruction] | Write a function that outputs the exact same output as its input. [input] |
[output] | dict = { 'Alice':'0123456789', 'Bob' : '0987654321', 'Cara' : '0345567890', 'Dave' : '0412356789', 'Ed' : '0999888777' } [instruction] | Use a dictionary to store the names of 5 people and their contact numbers. [input] | Alice - 0123456789, Bob - 0987654321, Cara - 0345567890, Dave - 0412356789, Ed - 0999888777
[output] | def multiply_array(arr): sum_of_arr = sum(arr) for i in range(len(arr)): arr[i] = arr[i] * sum_of_arr return arr [instruction] | Write a function to multiply an array of 3 numbers by their sum. [input] | [4, 5, 6]
[output] | There are 25 distinct prime numbers less than 100. [instruction] | How many distinct prime numbers are there less than 100? [input] |
[output] | You can convert an integer to a float in Python using the float() function. For example, float(4) would return 4.0. [instruction] | How would you convert an integer to a float in Python? [input] |
[output] | class Car: def __init__(self, make, model, year): self.make = make self.model = model self.year = year [instruction] | Design a class to represent a car with member variables for the make, model, and year. [input] |