[output] | The hexadecimal representation of 595 is 0x257. [instruction] | Convert the decimal number 595 to hexadecimal representation. [input] |
[output] | for i in range(1,101): if i % 5 != 0: print(i) [instruction] | Create a loop that prints all numbers 1 to 100 with the exception of multiples of 5. [input] |
[output] | CREATE TABLE users ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(128) NOT NULL, email VARCHAR(128) NOT NULL UNIQUE, password VARCHAR(128) NOT NULL ); [instruction] | Construct a database table in SQL to store user information. [input] |
[output] | from datetime import date print(date.today().strftime("%B %d, %Y")) [instruction] | Edit the following Python code to print a date in a human-readable form. [input] | print(date.today())
[output] | import json data = json.loads(input) for user in data['users']: print(user['name']) [instruction] | Parse this JSON data and print the names of all the users. [input] | { "users": [ { "name": "John" }, { "name": "Jill" }, { "name": "Harry" } ] }
[output] | def shuffle(arr): for i in range(len(arr)-1, 0, -1): j = random.randint(0, i) arr[i], arr[j] = arr[j], arr[i] return arr [instruction] | Write your own version of Fisher-Yates algorithm for shuffling an array. [input] |
[output] | import string import random def generate_password(): length = random.randint(12, 24) pwd = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(length)) return pwd [instruction] | Generate a random password. [input] |
[output] | SELECT name, COUNT(*) FROM users GROUP BY name HAVING COUNT(*) > 1; [instruction] | Construct a query in SQL to find out how many users have the same name. [input] |
[output] | n = '1' for x in range(5): a, b = '', '' count = 1 for i in range(1, len(n)): if(n[i] != n[i-1]): a += str(count) a += n[i-1] count = 1 else: count+=1 if(n[i] == n[i-1]): a += str(count) [instruction] | Recreate the same result from the given sample output. [input] | Sample output: 1 11 21 1211 111221
[output] | import sys #Defining the Task class class Task(object): """ Class to keep track of tasks and provide status updates. """ def __init__(self, name, status): """Initializing instance attributes""" self.name = name self.status = status self.status_dict = [instruction] | Write an application that keeps track of tasks and provides status updates for the tasks. [input] |
[output] | class Ball: def __init__(self, x, y, z): self.x = x self.y = y self.z = z [instruction] | Create a class called Ball which has three dimensional coordinates x, y and z. [input] |
[output] | import random class Die: def __init__(self): self.sides = 6 def roll(self): return random.randint(1, self.sides) [instruction] | Write a class that simulates a die with 6 sides. [input] |
[output] | dict = {x:x for x in list} [instruction] | Create a dictionary comprehension to create a dictionary with the values from the given list. [input] | list = ["a","b","c"]
[output] | A_Transpose = A' [instruction] | Suppose you have a 3x2 matrix, A. Find the transpose of A. [input] | A = [1 9 7; 8 0 6];
[output] | int sum=0; for (int i=0; i<=n; ++i) sum += pow(i,2); end [instruction] | Implement the following pseudocode in C language. [input] | sum = 0 for i = 0 to n inclusive sum += i^2 end
[output] | #container { width: 500px; } [instruction] | Create a CSS rule to make the div element with an id of "container" to have a width of 500px. [input] |
[output] | sd(x) [instruction] | Write an R command to calculate the standard deviation of the given array. [input] | x = c(3, 4, 5, 7, 8)
[output] | public class TemperatureReading { private Date date; private String location; private int temperature; public TemperatureReading(Date date, String location, int temperature) { this.date = date; this.location = location; this.temperature = temperature; } public Date getDate( [instruction] | Create a class in Java that comprises of a date, a location and temperature reading associated with that location on that particular date. [input] |
[output] | alias mkapp="MyApp" [instruction] | Create a shortcut command in Bash to run a program called "MyApp" [input] |
[output] | SELECT * FROM employee WHERE YEAR(CURDATE()) - YEAR(dob) BETWEEN 30 and 39; [instruction] | Write a SQL query to select the employees who are in their 30s. [input] |
[output] | let identical = str1 === str2; if (identical) { console.log("Strings are identical"); } else { console.log("Strings are not identical"); } [instruction] | Compare two strings to check if they are identical using the JavaScript language. [input] | str1 = 'Testing' str2 = 'Testing'
[output] | class Day: def __init__(self): self.day = "" def set_day(self, day): self.day = day def get_day(self): return self.day [instruction] | Define a class named "Day" in Python to represent a day of the week. [input] |
[output] | #include <iostream> using namespace std; int main() { int n, t1 = 0, t2 = 1, nextTerm; cout << "Enter the number of terms: "; cin >> n; cout << "Fibonacci Series: "; for (int i = 1; i <= n; ++i) { if (i == 1) { cout << " " << t1; cont [instruction] | Write a C++ program that prints the Fibonacci numbers up to the number specified by the user. [input] |
[output] | int [] nums = {8, 10, 12}; System.out.println("Number \tNumber \tNumber"); for(int i=0; i<nums.length; i++) { System.out.println(nums[i] + "\t\t" + nums[i+1] + "\t\t" + nums[i+2]); i++; } [instruction] | Write a Java code snippet to show the below numbers in a tabular format on the console. [input] | num1 = 8 num2 = 10 num3 = 12
[output] | count = 0 for string in string_list: if string.startswith("a"): count += 1 print("The count of strings starting with 'a' is:", count) [instruction] | Given a list of strings, use Python to print the count of strings that start with the letter 'a'. [input] | string_list = ["apple","mango","banana","avocado"]
[output] | def myFunction(): print("Hello World") myFunction() [instruction] | Generate a piece of code that defines and calls a function in Python. [input] |
[output] | ['Apple', 'Banana', 'Orange', 'Grape', 'Potato', 'Carrot', 'Onion', 'Cucumber', 'Tomato', 'Pepper'] [instruction] | Create an array of fruits and vegetables with 10 items. [input] |
[output] | let x = 7; [instruction] | Write a line of JavaScript code to create a variable `x` and assign the number `7` to it. [input] |
[output] | System.out.println("Hello World!"); [instruction] | Generate a code snippet in Java to display a message "Hello World!" [input] |
[output] | int c = 5 + 10; [instruction] | Refactor the given piece of code in Java to make it more concise. [input] | int a = 5; int b = 10; int c = a + b;