instruction stringlengths 14 288 | input stringlengths 0 635 | output stringlengths 0 3.91k |
|---|---|---|
Create an HTML form to allow a user to enter their contact information. | Fields requested: Name, Email, Phone number | <form action="contactinfo.php" method="POST">
<label>Name</label>
<input type="text" name="name" />
<label>Email</label>
<input type="text" name="email" />
<label>Phone Number</label>
<input type="text" name="phone" />
<input type="submit" value="Submit" />
</form> |
Create a C++ object to represent a 2D point. | class Point2D {
private:
double x;
double y;
public:
Point2D(double x_coordinate, double y_coordinate);
double get_x();
double get_y();
};
Point2D::Point2D(double x_coordinate, double y_coordinate) {
x = x_coordinate;
y = y_coordinate;
}
double Point2D::get_x() {
return x;
}
d... | |
Write a MySQL query to insert new records in an 'Employees' table. | Table Name: Employees
Records to add:
Name: John, Age: 28, Job Title: Programmer
Name: Alice, Age: 24, Job Title: Designer | INSERT INTO Employees (Name, Age, Job_Title)
VALUES ('John', 28, 'Programmer'),
('Alice', 24, 'Designer'); |
Create a web page that shows a short biography of the given person. | Person: Marie Curie | <html>
<head>
<title>Biography of Marie Curie</title>
</head>
<body>
<h1>Marie Curie</h1>
<p>Marie Curie (1867-1934) was a Polish physicist and chemist who conducted pioneering research on radioactivity and discovered the elements radium and polonium. She was twice awarded the Nobel Prize, first in ph... |
Sum up the values in the given list using a for loop. | List: [2, 3, 6, 4, 8] | total = 0
for number in [2, 3, 6, 4, 8]:
total += number
print("Total: ", total) # Output: Total: 23 |
Perform an insertion sort on the given list. | List: [9, 5, 4, 8, 6] | def insertionSort(arr):
# Traverse through 1 to len(arr)
for i in range(1, len(arr)):
key = arr[i]
# Move elements of arr[0..i-1], that are
# greater than key, to one position ahead
# of their current position
j = i-1
while j >= 0 and key < arr[j] :
arr[j + 1... |
Given a list of integers, find the smallest and the largest of the set. | [1, 9, 45, -5, 23, 18] | let list = [1, 9, 45, -5, 23, 18];
let smallest = Math.min(...list);
let largest = Math.max(...list);
console.log("Smallest: " + smallest + ", Largest: " + largest); |
Parse a JSON string and print each key-value pair to the console. | '{"name": "John", "age": 30, "likes": ["sports", "chess"]}' | const jsonStr = '{"name": "John", "age": 30, "likes": ["sports", "chess"]}';
let jsonObj = JSON.parse(jsonStr);
for (let key in jsonObj) {
console.log(`${key}: ${jsonObj[key]}`);
} |
Implement a shell script to retrieve the IP address of a website. | #!/bin/bash
if [ $# -eq 0 ]; then
echo "Error: No arguments supplied."
exit 1
fi
ip=$( dig +short $1 )
echo $ip | |
Create a regular expression that matches strings starting with "Hello". | let regex = /^Hello/; | |
Create an Android app with a button to switch between light and night mode. | public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Get reference to button
Button switchModeButton = (Button) findViewById(R.id.switch_mode_button);
... | |
Write a JavaScript function to format a given number to HH:MM:SS. | // Given a number of seconds input
let secs = 85 | const formatTime = (secs) => {
let d = new Date(0);
d.setSeconds(secs);
let hh = d.getHours().toString().padStart(2, '0');
let mm = d.getMinutes().toString().padStart(2, '0');
let ss = d.getSeconds().toString().padStart(2, '0');
return `${hh}:${mm}:${ss}`;
} |
Edit the following HTML to give a baseline styling to the body. | <body>
<h2>Hello World</h2>
</body> | <body style="margin: 0; padding: 0; font-family: sans-serif; box-sizing: border-box; font-size: 16px; line-height: 1.5; background-color: #f5f5f5; color: #222222;">
<h2>Hello World</h2>
</body> |
Implement a Python class that prints a given given text when a certain condition is satisfied. | Print a text "Endless fun" when the numbers given in a list equals to 10 | class MyClass:
def __init__(self, given_list):
self.given_list = given_list
def check_equal_to_10(self):
if len(self.given_list) == 0:
return False
for num in self.given_list:
if num != 10:
return False
print("Endless fun")
ret... |
Create a SQL database containing three tables. | CREATE TABLE Employee (
Id INT NOT NULL UNIQUE PRIMARY KEY,
Name VARCHAR(50) NOT NULL,
Age INT NOT NULL
);
CREATE TABLE Department (
Id INT NOT NULL UNIQUE PRIMARY KEY,
Name VARCHAR(50) NOT NULL
);
CREATE TABLE Employee_Department (
EmployeeId INT NOT NULL UNIQUE,
DepartmentId INT NOT NULL UNIQUE
); | |
Generate a Bash script to grep a given line from the command output. | grep the line "The result is" from the following command
"echo "The result is 120"" | #!/bin/bash
CMD="echo "The result is 120""
eval $CMD | grep -o "The result is.*" |
Generate a JavaScript code to get the key names of an object. | key names of the following object
let obj = {name: "John", age: 30, job: "teacher"}; | let objKeyNames = Object.keys(obj);
console.log(objKeyNames); // outputs ["name", "age", "job"] |
Identify and display all the data types within the column 'price' in a table named 'products'. | SELECT DISTINCT data_type
FROM products
WHERE column_name = 'price'; | |
Create a basic Python script to accept two numbers from the user and
print out the sum. | num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))
# add two numbers
sum = num1 + num2
# display the sum
print("The sum of {0} and {1} is {2}".format(num1, num2, sum)) | |
Create a basic C# program to print out the current date and time. | using System;
public class Program
{
public static void Main()
{
Console.WriteLine(DateTime.Now.ToString());
}
} | |
Find and display all the employees who earn more than the average salary across all departments. | SELECT e.name
FROM employees e
WHERE e.salary > (SELECT AVG(salary) FROM employees); | |
Create a Python program to accept a string from the user and print out the number of vowels in the string. | Hello World | def countVowels(str):
vowel = 0
for i in str:
if i.lower() in ['a', 'e', 'i', 'o', 'u']:
vowel += 1
return vowel
# Driver code
str = "Hello World"
print("Number of vowels are:", countVowels(str)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.