[output] | def concatenate(str1, str2): return str1 + str2 print (concatenate(str1, str2)) [instruction] | String concatenation is the process of combining two individual strings into one. Write a Python program to concatenate two strings using the + operator. [input] | str1 = 'Hello' str2 = 'World'
[output] | def get_name_of_day(day): days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] if day >= 0 and day <= 6: return days[day] else: return None [instruction] | Print the name of the day depending on the given integer. [input] | day = 0
[output] | You can search for and replace a string with a substring in Python by using the "replace" method. The syntax would be: string.replace("string_to_be_replaced", "new_string"). For example: "Hello, world".replace("world", "there") would return "Hello, there". [instruction] | How can you search for and replace a string with a substring in Python? [input] |
[output] | The Python library used to parse a JSON string is json. The json library provides functions for encoding and decoding a JSON string. The syntax for decoding would be: json.loads(data). The syntax for encoding would be: json.dumps(data). [instruction] | What is the Python library used to parse a JSON string? [input] |
[output] | The most efficient way to iterate through a list of dictionaries in Python is to use the "for-in" loop. This loop iterates over the elements of the list and accesses the values of the dictionary using the "key" argument. The syntax would be: for item in list: do_something(item[key]). [instruction] | What is the most efficient way to iterate through a list of dictionaries in Python? [input] |
[output] | with open('textfile.txt') as f: for line in f: if 'Python' in line: print(line) [instruction] | Create a code to read a textfile line by line and print out the lines that have the word "Python". [input] |
[output] | class Person: def __init__(self, name, age, gender): self.name = name self.age = age self.gender = gender person1 = Person("John", 25, "Male") [instruction] | Create a class constructor to initialize the values of a person. [input] |
[output] | CREATE DATABASE customerDB; USE customerDB; CREATE TABLE customers ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) NOT NULL, address VARCHAR(50) NOT NULL, email VARCHAR(50) NOT NULL, phone VARCHAR(20) NOT NULL, gender VARCHAR(10) NOT NULL ); [instruction] | Create a MySQL database and table for storing customer information. [input] | Each customer data should have the following attributes: Name, Address, Email, Phone, Gender.
[output] | <html> <head> <title>Current Weather</title> </head> <body> <p>Temperature: <span id="temperature"></span></p> <p>Humidity: <span id="humidity"></span></p> <p>Wind Speed: <span id="wind_speed"></span></p> <p>Barometric Pressure: <span id="pressure"></span></p> <script> [instruction] | Create a web page to display the current weather in your city. [input] | The weather data should be in the form of temperature, humidity, wind speed, and barometric pressure.
[output] | SELECT name, address FROM customers WHERE address LIKE ('%[zipcode]%') [instruction] | Write an SQL query for finding customers who live in a given zipcode. [input] |
[output] | const http = require('http'); const hostname = 'localhost'; const port = 8000; const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/plain'); res.end('Hello, World!'); }); server.listen(port, hostname, () => { console.log(`Server runnin [instruction] | Create a Node.js server that serves a simple "Hello, World!" page. [input] |
[output] | public class loancalculator extends Activity { EditText loanamount, interestrate, repaymentperiod; TextView txtmonthlypayments; Button calculate; Double ans; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); [instruction] | Create an Android application for calculating monthly loan payments. [input] | The application should be able to calculate the monthly payments for different loan types (e.g. car, house, etc.).
[output] | public class PrimeNumbers { public static void main(String[] args) { System.out.println("All prime numbers between 1 and 100:"); int counter; for (int i = 2; i <= 100; i++) { counter = 0; for (int num = i; num >= 1; num--) { if (i % num == 0) { counter = counter + 1; } [instruction] | Create a program in Java for displaying all prime numbers between 1 and 100. [input] |
[output] | import React, { Component } from 'react'; class DropdownMenu extends Component { state = { displayMenu: false, }; showDropdownMenu = (event) => { event.preventDefault(); this.setState({ displayMenu: true }, () => { document.addEventListener('click', this.hideDropdownMenu); [instruction] | Create a React component for a dropdown menu. [input] | The menu should list the following options: Home, About, Contact.
[output] | #include <string> #include <algorithm> string longestCommonSubstring(string s1, string s2) { int s1Length = s1.size(); int s2Length = s2.size(); int** dp = new int*[s1Length + 1]; for (int i = 0; i <= s1Length; ++i) { dp[i] = new int[s2Length + 1]; dp[i][0] [instruction] | Write an C++ algorithm for finding the longest common substring between two strings. [input] |
[output] | def sort_array(arr): n = len(arr) for i in range(n): min_idx = i for j in range(i+1, n): if arr[min_idx] > arr[j]: min_idx = j arr[i], arr[min_idx] = arr[min_idx], arr[i] return arr [instruction] | Create a program for sorting a given array in O(n) time complexity. [input] |
[output] | SELECT customers.name FROM customers INNER JOIN orders ON customers.ID = orders.customer_id INNER JOIN products ON orders.product_id = products.ID WHERE customers.city = 'City Name' AND products.name = 'Product Name'; [instruction] | Write an SQL query to find customers who live in a given city and have purchased a given product. [input] |
[output] | // This function takes in two values, a base and an exponent, and calculates the power of the base with the exponent. The result is computed by multiplying the base with the exponent. The result is then returned to the caller. [instruction] | Comment on the following code: [input] | function power (base, exponent) { let result = 1; for (let count = 0; count < exponent; count++) { result *= base; } return result; }
[output] | Integer. [instruction] | What is the type of the value of the following expression: 4* 4 + 8 [input] |
[output] | <html> <head> <title>User Registration Form</title> </head> <body> <h1>Register a new user</h1> <form action="register.php" method="POST"> <label>First Name:</label><br> <input type="text" name="firstName" required><br><br> <label>Last Name:</label><br> [instruction] | Design an HTML form to register users on a website. [input] |
[output] | const MyButton = () => { return <button className="MyButton"> My Button </button> } [instruction] | Create a UI element in ReactJS. [input] | Element type: button
[output] | for (int i = 0; i < 5; i++) { System.out.println("Hello World"); } [instruction] | Debug the following code to check if it has any syntax errors. [input] | for (int i = 0; i < 5; i++) println("Hello World");
[output] | \b(https?):\/\/[\w+&@#\/%?=~_|!:,.;]+[\w+&@#\/%=~_|] [instruction] | Construct a regex pattern to extract the URLs from a string. [input] | String: "Visit http://www.example.com or https://www.example2.com "
[output] | The 'const' keyword in C++ is used to indicate that the value of a variable cannot be modified after its initial assignment. It can be used to create read-only variables that are useful for preventing accidental data modification. [instruction] | Explain the significance of the 'const' keyword in C++. [input] |
[output] | model = tf.keras.models.Sequential() # Add a convolutional layer model.add(tf.keras.layers.Conv2D(32, kernel_size=(3,3), activation='relu', input_shape=(28, 28, 1))) # Add a max pooling layer model.add(tf.keras.layers.MaxPooling2D(2,2)) # Add a flatten layer model.add(tf.keras.layers.Flatten()) [instruction] | Write a TensorFlow code to build a convolutional neural network to predict the digits from the MNIST dataset. [input] |
[output] | <?php if(isset($_POST['submit'])){ $name = $_POST['name']; $subject = $_POST['subject']; $mailFrom = $_POST['email']; $message = $_POST['message']; $mailTo = "example@gmail.com"; $headers = "From: ".$mailFrom; $txt = "You have received an email from ".$name.".\n\n".$message; mail($mailTo, $subj [instruction] | Write a PHP script to create a simple contact form [input] |
[output] | [ { "name" : "John", "age" : 30, "city" : "New York" }, { "name" : "Mike", "age" : 25, "city" : "California" } ] [instruction] | Convert this Python list of dictionaries to JSON. [input] | list_of_dictionaries=[ { "name" : "John", "age" : 30, "city" : "New York" }, { "name" : "Mike", "age" : 25, "city" : "California" } ]
[output] | <form> <label for="name">Name:</label><br> <input type="text" name="name" placeholder="Enter your name"><br> <label for="email">Email:</label><br> <input type="email" name="email" placeholder="Enter your email"><br> <label for="phone">Phone:</label><br> <input type="tel" name="phone" pla [instruction] | Create a HTML form with all the necessary fields to input user information, such as name, email, phone number, etc. [input] |
[output] | import Foundation let url = URL(string: "https://my-api.com/endpoint")! let task = URLSession.shared.dataTask(with: url) {(data, response, error) in guard let data = data else { return } do { let json = try JSONSerialization.jsonObject(with: data, options: []) print(json) } catch { [instruction] | Create a Swift program to make a request to an API and display the response in the console. [input] |
[output] | DELETE from user WHERE email="example@example.com"; [instruction] | Write an SQL query to delete a record from a table named 'user' where the email is 'example@example.com'. [input] |