[output] | <form> <label>Username:</label> <input type="text" name="username" required> <br/><br/> <label>Password:</label> <input type="password" name="password" required> <br/><br/> <input type="submit" value="Submit" > </form> [instruction] | Create an HTML code to produce a form which contains two text fields (username and password) and submit button. [input] |
[output] | function multiply(a,b) { return a * b; } [instruction] | Debug a logic error in this JavaScript code that returns the wrong result. [input] | function multiply(a,b) { return a + b; }
[output] | class Node { int data; Node previous; Node next; public Node(int data) { this.data = data; this.previous = null; this.next = null; } } class DoublyLinkedList { Node head; // Inserts a new Node at front of the list public voi [instruction] | Create a Java program to implement a doubly linked list with the following operations: insert, delete, display. [input] |
[output] | function insertAtPosition(item, position, array) { array.splice(position, 0, item); return array; } [instruction] | Create a JavaScript code to insert a given item at the specified position in an array. [input] | item = "hello world", position = 2
[output] | def max_val(list): max_val = list[0] for i in range(len(list)): if list[i] > max_val: max_val = list[i] return max_val [instruction] | Create a function that returns the maximum element of a given list. [input] | Given List: [3, 12, 2, 6, -9]
[output] | def search_x(x, vector): for i in range(len(vector)): if vector[i] == x: return i return -1 [instruction] | Design a code to search a given element x in a vector. [input] | vector: [3, 17, 5, 11], x: 5
[output] | def sort_list(givenList, sortOrder): for i in range(len(givenList)): for j in range(i + 1, len(givenList)): if sortOrder == "ascending": if givenList[i] > givenList[j]: givenList[i], givenList[j] = givenList[j], givenList[i] [instruction] | Develop a code to sort a list in ascending or descending order. [input] | givenList: [5, -3, 2, 4, 0], sortOrder: "ascending"
[output] | def multiplication(num1, num2): return num1 * num2 [instruction] | Construct a program which takes two numbers as input and returns the multiplication of these numbers. [input] | 8, 4
[output] | def delete_element(given_list, element): for i in range(len(given_list)): if given_list[i] == element: del given_list[i] break return given_list [instruction] | Develop a code to delete a given element from a list. [input] | [3, 6, 8, 14], element: 14
[output] | public static String[] convertStringToArray(String data) { String[] elements = data.split(","); // Trim all the elements for (int i = 0; i < elements.length; i++) { elements[i] = elements[i].trim(); } return elements; } [instruction] | Create a function in Java to convert a string of comma-separated values into an array. [input] | data = "Banana, Apple, Apricot"
[output] | <html> <head> <title>People Age Table</title> </head> <body> <table> <tr> <th>Name</th> <th>Age</th> </tr> <tr> <td>John</td> <td>25</td> </tr> <tr> <td>Lisa</td> <td>22</td> </tr> <tr> [instruction] | Create an HTML page with a table containing the name and age of 5 people. [input] | Name Age John 25 Lisa 22 Emily 19 George 21 Samuel 20
[output] | #include <iostream> #include <string> int main() { std::string string1 = "Hello"; std::string string2 = "World"; std::string concatenation = string1 + " " + string2; std::cout << concatenation; return 0; } [instruction] | Create a C++ program to concatenate two string variables. [input] | string1 = "Hello" string2 = "World"
[output] | SELECT first_name, last_name FROM Customers ORDER BY last_name ASC LIMIT 10 [instruction] | Write a SQL query to show the first 10 customers in an alphabetical order, sorted by their last name. [input] | Table Customers: id, first_name, last_name
[output] | function removeEvens(numbers) { return numbers.filter((num) => num % 2 !== 0); } [instruction] | Write a JavaScript expression to remove all even numbers in an array. [input] |
[output] | public class Student { private String name; private double gpa; public Student(String name, double gpa) { this.name = name; this.gpa = gpa; } public String getName() { return name; } public double getGPA() { return gpa; } } [instruction] | Create a class in Java that encapsulates a student's name and grade point average (GPA). [input] |
[output] | function findVowels(sentence) { let count = 0; let vowels = "aeiou"; for (let char of sentence.toLowerCase()) { if (vowels.indexOf(char) !== -1) { count++; } } return count === 5; } [instruction] | given a sentence, Write a JavaScript program to find out whether the sentence contains all the vowels. [input] | let sentence = "This is an example sentence";
[output] | def word_frequency(S): frequency = dict() words = S.split() for word in words: if word in frequency: frequency[word] += 1 else: frequency[word] = 1 return frequency print(word_frequency(S)) [instruction] | Write a code to create a dictionary containing the frequency of each word in a given string. [input] | S = "hello world"
[output] | def transpose_matrix(matrix): row = len(matrix) col = len(matrix[0]) transpose = [[0 for j in range(row)] for i in range(col)] for i in range(row): for j in range(col): transpose[j][i] = matrix[i][j] return transpose matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] print(transpose [instruction] | Given a 2 dimensional array, create a code to transpose the array. [input] |
[output] | """ Create a function to rotate a given linked list """ # Create a class node class Node: # Create a constructor to initialise the node object def __init__(self, data): self.data = data self.next = None class LinkedList: # Create a constructor to initialise the linked list def __init [instruction] | Write a code to create a function to rotate a given linked list. [input] |
[output] | int a = 10; int b = 20; int c = a + b; System.out.println(c); // Outputs 30 [instruction] | Print the output of adding two integers in Java. [input] | int a = 10; int b = 20;
[output] | let sum = 10 + 20; console.log(sum); // Outputs 30 [instruction] | Rewrite the following code to output the result in the command line using Node.js [input] | let sum = 10 + 20
[output] | public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } [instruction] | Correct the following code in Java. [input] | public class HelloWorld { public static Void main(String[] args) { System.out.println("Hello World!"): } }
[output] | <html> <head> <title>My Page</title> </head> <body> <div id="content"> <h1>My Page</h1> </div> <div id="footer"> <p>Copyright © 2020 MyPage</p> </div> </body> </html> [instruction] | Generate an HTML page using the defined header and footer. [input] | Header: <head> <title>My Page</title> </head> Footer: <div id="footer"> <p>Copyright © 2020 MyPage</p> </div>
[output] | The compressed string would be ‘A1B3C1D1E1F2G1’. [instruction] | Compress the following string using LZW compression. [input] | Input: ‘ABBBCDCDEFFG’
[output] | import React, {Component} from 'react'; class Employee extends Component { render() { return ( <div> <h1>Employee</h1> <table> <thead> <tr> <th>Name</th> <th>Age</th> </tr> </thead> <tbody> [instruction] | Create a React component with "Employee" as the title and "Name" and "Age" as the heading. [input] |
[output] | import ftplib def start_ftp_server(host, port, user, password): server = ftplib.FTP() server.connect(host, port) server.login(user, password) print('FTP Server started successfully') start_ftp_server('localhost', 21, 'testuser', 'testpass') [instruction] | Implement FTP server in Python [input] |
[output] | We can solve this problem using a HashSet. We traverse the array and insert the elements in the HashSet. If the element already exists in the HashSet, then it is a duplicate. public static boolean findDuplicate(int[] arr) { Set<Integer> set = new HashSet<Integer>(); for(int i = 0; i < [instruction] | Write a method to find duplicate elements in an array of integers. [input] |
[output] | fedcba [instruction] | Convert the given input string to lower case keeping all other characters same. [input] | FEDCbA
[output] | p [instruction] | Generate a random letter between a and z. [input] |
[output] | true [instruction] | There is a string of code. Can you tell me if there are syntax errors in it? [input] | def foo(): print('bar