[output] | import java.util.Scanner; public class Echo { public static void main(String[] args) { Scanner input = new Scanner(System.in); String line = input.nextLine(); System.out.println(line); } } [instruction] | Create a Java program that takes input from a user and prints it out. [input] |
[output] | h1, h2, h3 { font-weight: bold; } [instruction] | Create a CSS rule to make all titles on a page bold. [input] |
[output] | celsius_temperature = function(fahrenheit_temperature) { celsius_temperature = (fahrenheit_temperature - 32) * 5 / 9 return(celsius_temperature) } # Test case print(celsius_temperature(100)) # Output: 37.77778 [instruction] | Develop an R script that converts a given number from Fahrenheit to Celsius. [input] | Fahrenheit temperature = 100
[output] | <?php $username = 'NewUser'; $password = 'Test123'; $connection = mysqli_connect("localhost", "root", "", "mydatabase"); $sql = "INSERT INTO users (username, password) VALUES ('".$username."', '".$password."')"; if(mysqli_query($connection, $sql)) { echo "User added successfully"; } e [instruction] | Create a PHP script to add a given user to a database [input] | username = 'NewUser' password = 'Test123'
[output] | public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } [instruction] | Place the missing code in the following Java program to print "Hello World!". [input] | public class HelloWorld { public static void main(String[] args) { ~ } }
[output] | import random random_string = ''.join(random.choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ') for _ in range(10)) [instruction] | How can you create a string of all random characters of length 10 in Python? [input] |
[output] | def FunctionA(arr): output = set() for elem in arr: if elem > 0: output.add(elem) return list(output) [instruction] | Improve the following code by implementing a more efficient algorithm. [input] | def FunctionA(arr): output = [] for elem in arr: if elem > 0 and not elem in output: output.append(elem) return output
[output] | if x >= 0: print("x is positive") [instruction] | What should be written in place of "___" to make the following code a valid if-else statement in Python? [input] | if x >= 0: ___
[output] | sum_of_odds = 0 i = 1 while i <= 100: if i % 2 != 0: sum_of_odds += i i+=1 [instruction] | Construct a while loop to add all odd integers from 1 to 100. [input] |
[output] | for (let i=1; i<=5; i++) { for (let j=5; j>=i; j--) { document.write("*"); } document.write("<br>"); } [instruction] | How can you print the following pattern in JavaScript? [input] |
[output] | <li class="highlight">Hello</li> [instruction] | Change the following line of HTML code to add a class named "highlight" to the list item. [input] | <li>Hello</li>
[output] | p { color: blue; font-style: italic; } [instruction] | Create a CSS style for the text within the tag <p> to be blue and italicized. [input] |
[output] | def sumNums(n): if n == 0: return 0 else: return n + sumNums(n-1) # Driver Code n = 4 print(sumNums(n)) [instruction] | Implement a recursive method to find the sum of all numbers from 1 to n. The method should take an integer n as its argument. [input] | 4
[output] | h1 { color: #FF0000; } [instruction] | Edit the following CSS code to add a color of your choice to the <h1> element. [input] |
[output] | function concatenate(string1, string2) { return string1 + string2; } [instruction] | Implement a method in JavaScript to concatenate two strings together. [input] |
[output] | div { width: 200px; height: 50px; } [instruction] | Create a CSS style for a div element to have a width of 200px and a height of 50px. [input] |
[output] | <input type="checkbox" name="yes" value="Yes">Yes <input type="checkbox" name="no" value="No">No [instruction] | Write an HTML code snippet to create two check boxes with labels “yes” and “no”. [input] |
[output] | SELECT Name, MAX(Population) FROM countries; [instruction] | Write an SQL query to find the highest population of any country from the table of countries. [input] | Table: countries Columns: Name (string), Population (int)
[output] | StringBuilder sb = new StringBuilder(); sb.append("Hello,"); sb.append(" world!"); sb.append(" Have a nice day!"); String finalString = sb.toString(); [instruction] | Use the Java StringBuilder class to append three strings to a single string. [input] | String1: "Hello," String2: " world!" String3: " Have a nice day!"
[output] | CREATE PROCEDURE getCourseStudents (@courseId INT) AS BEGIN SELECT s.Name FROM students s INNER JOIN courses c ON s.CourseId = c.Id WHERE c.Id = @courseId END [instruction] | Write a SQL stored procedure to find all students enrolled in a specific course. [input] | Table: courses Columns: Id (int), Name (string) Table: students Columns: Id (int), Name (string), CourseId (int)
[output] | <form> <label for="firstname">First Name:</label> <input type="text" id="firstname" name="firstname" > <br> <label for="lastname">Last Name:</label> <input type="text" id="lastname" name="lastname" > <br> <label for="address">Address:</label> <input type="text" id="address" name="add [instruction] | Create an HTML form to collect user information such as address and contact details. [input] |
[output] | class Book { private var title: String private var authorName: String private var yearOfPublication: Int private var ISBN: String constructor(title: String, authorName: String, yearOfPublication: Int, ISBN: String) { this.title = title this.authorName = authorNa [instruction] | Write a Kotlin class to represent a book. It should contain the title, author name, year of publication and ISBN. [input] |
[output] | CREATE TABLE employees ( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, phone VARCHAR(20) NOT NULL, PRIMARY KEY (id) ); [instruction] | Use the MySQL CREATE command to create a table of employees containing an employee ID, name, email address and phone number. [input] |
[output] | def is_prime(n): """ A better algorithm for determining if a number is prime :param n: The number to determine whether is prime :return: a boolean if the number is prime """ if (n <= 1): return False if (n <= 3): return True if (n % 2 == 0 or n % [instruction] | Suggest a better algorithm for finding a prime number. [input] |
[output] | There are several ways to write a program to append two strings together: 1. Using the + operator, you can concatenate the two strings: string_combined = string1 + string2 2. Using the format() method, you can combine the two strings into one string: string_combined = '{}{}'.format(stri [instruction] | In how many ways can you write a program to append two strings together? [input] |
[output] | FROM python:3.7-alpine WORKDIR /app # Copy and install dependencies COPY requirements.txt . RUN pip install -r requirements.txt # Copy application source COPY src ./src # Set environment variables ENV DJANGO_SETTINGS_MODULE=app.settings EXPOSE 8000 # Run server ENTRYPOINT ["python", "src/manag [instruction] | Create a dockerfile to deploy a python app. [input] |
[output] | def mult_by_two(nums): """ Returns a new list with each item multiplied by 2 in an existing list :param nums: a list of numbers :return: a list of numbers with each item multiplied by 2 """ new_list = [] for num in nums: new_list.append(num * 2) return new_lis [instruction] | Create a python program to return a new list with each item multiplied by 2 in an existing list. [input] | [1, 2, 3, 4, 5]
[output] | The regular expression pattern that identifies 3 consecutive numbers is: \d{3} [instruction] | Suggest a regular expression pattern that identifies 3 consecutive numbers. [input] |
[output] | A valid IPv4 address can be identified using the regular expression pattern: ^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}$ [instruction] | How would you use regex to identify a valid ip4 address? [input] |
[output] | def reverse_string(str): if len(str) == 0: return str else: return reverse_string(str[1:]) + str[0] [instruction] | Reverse a given string using recursive function in Python. [input] |