[output] | let array = [1, 2, 3, 4, 5]; let json = JSON.stringify(array); console.log(json); [instruction] | Create a JSON from a given array. [input] | [1, 2, 3, 4, 5]
[output] | let arr = [5, 2, 4, 6, 1]; arr.sort(function(a, b){ return a-b; }); console.log(arr); [instruction] | Create an algorithm in JavaScript to sort an array of numbers. [input] | [5, 2, 4, 6, 1]
[output] | def count_evens(arr): count = 0 for i in arr: if (i % 2) == 0: count+=1 return count arr = [1, 2, 3, 4, 5, 6] count = count_evens(arr) print(count) [instruction] | Design a program to count the total number of even numbers in a given array. [input] | [1, 2, 3, 4, 5, 6]
[output] | function isUnique(str) { for(let i = 0; i<str.length; i++){ for(let j = i+1; j<str.length; j++){ if(str.charAt(i) === str.charAt(j)){ return false; } } } return true; } let str = 'Hello'; let result = isUnique(str); console.log(res [instruction] | Design an algorithm in JavaScript to check if a given string consists of only unique characters. [input] | Hello
[output] | .main-page { background-color: #FFC0CB; } [instruction] | Modify the following CSS code to change the background color of the element to "#FFC0CB" [input] | .main-page { background-color: #FFF; }
[output] | [5, 17, 5] [instruction] | Create an array with 3 elements, first element is 5, the second element is 17 and the third element is identical to the first element [input] |
[output] | function getValue(data, key) { return data[key]; } [instruction] | Given the following data structure, write a function that takes two arguments and returns the value of the specified property from the object [input] | const data = { id: 1, name: 'John' }
[output] | { 'apple': 'fruit', 'carrot': 'vegetable', 'sugar': 'sweetener' } [instruction] | Create a dictionary with three items of your choice [input] |
[output] | function getMaxNumber(nums) { let maxNum = nums[0]; for (let i = 1; i < nums.length; i++) { if (nums[i] > maxNum) { maxNum = nums[i]; } } return maxNum; } [instruction] | Using the same array, write a function that returns the largest number [input] | [3, 5, 22, 11, 16, 9]
[output] | SELECT * FROM users ORDER BY id DESC LIMIT 1; [instruction] | Write the SQL query to select the last element of a table [input] | table_name: users
[output] | user.company [instruction] | Retrieve the company name from the following object [input] | const user = { name: 'John Doe', company: 'Google' }
[output] | Math.round(3.1415 * 100) / 100; [instruction] | Round the number 3.1415 to the nearest hundredth [input] |
[output] | <div><p>Hello World!</p></div> [instruction] | Edit the given HTML code to create a paragraph element. [input] | <div>Hello World!</div>
[output] | SELECT * FROM table1 LIMIT 10; [instruction] | Create a query in MySQL which fetches the first 10 records from a table called 'table1'. [input] |
[output] | a = 8 b = a + 2 c = a * b print(c) [instruction] | Edit the given python code to execute the arithmetic operation. [input] | a = 8 b = a+2
[output] | ∀x(Elephant (x) ∧ Lives_in(x, African_safari)) [instruction] | Use Predicate logic for representing the following statement. [input] | "An elephant only lives in an African safari."
[output] | <html> <head> <title>Display Message</title> </head> <body> <div> <h1>Welcome!</h1> <p>This page displays a message to the user.</p> </div> </body> </html> [instruction] | Develop an HTML page in which you can display a message to the user. [input] |
[output] | SELECT * FROM employees; [instruction] | Write a SQL query which returns all columns from the table 'employees' [input] |
[output] | def check_sign(x): if x < 0: print("The number is negative.") elif x > 0: print("The number is positive.") else: print("The number is 0.") [instruction] | Create a function in Python which checks if an input value is positive or negative. [input] |
[output] | class adder { int a, b; public: adder (int a, int b) { this->a = a; this->b = b; } int add() { int sum = a + b; return sum; } }; [instruction] | Design a C++ class which adds the two arguments and returns the result. [input] |
[output] | S --> AaBb A --> aA | bB B --> bBB | bA | aB | aA [instruction] | Convert the given context free grammar to Chomsky Normal Form. [input] | S --> AaBb A --> aA | b B --> bB | a
[output] | find_average <- function(x, y){ avg <- (x + y) / 2 return(avg) } [instruction] | Define a function in R which takes two arguments and finds their average. [input] |
[output] | int[] myArray = {1,2,3}; int first = myArray[0]; int second = myArray[1]; int third = myArray[2]; [instruction] | Develop a Java code which assigns each element of an array to an individual variable. [input] |
[output] | DROP TABLE table_name; [instruction] | Write a query in PostgreSQL for deleting a table. [input] |
[output] | List even = [4, 6, 8, 10, 12] List odd = [1, 7] [instruction] | Write a Java program to read in a list of integers and separate them into two lists of even and odd numbers. [input] | [1, 4, 6, 7, 8, 10, 12]
[output] | class WeatherData { private int temperature; private int humidity; private int windSpeed; // ... setter and getter methods } [instruction] | Use an object oriented approach to create an object in Java to store the temperature, humidity and wind speed from a weather forecast. [input] |
[output] | <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Web Developer Skills</title> </head> <body> <h1>Web Developer Skills</h1> <ul> <li>HTML</li> <li>CSS</li> <li>JavaScript</li> <li>React</li> </ul [instruction] | Write a HTML structure using semantic tags to list the skills of a web developer. [input] | HTML, CSS, JavaScript, React
[output] | <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Login</title> </head> <body> <form action=""> <label for="username">Username</label> <input type="text" placeholder="Username" name="username"><br><br> [instruction] | Write a HTML to generate a form to login. [input] |
[output] | class Item { private String name; private double cost; // ... setter and getter methods } [instruction] | Use an object oriented approach to create a class in Java to store the cost and name of an item. [input] |
[output] | <html> <head> <title>My Website</title> </head> <body> <h1 align="center">My Website</h1> <img src="<link to logo file>" align="center"> <style> body { background-color: #123456; color: #234567; } h1 { color: #345678; } </style> </body> </html> [instruction] | Create HTML code for a web page that has a centered title, a logo, and a colorscheme. [input] | Title: "My Website" Logo: <link to logo file> Color Scheme: #123456, #234567, #345678