[output] | """ Function register: Registers a new user using a given username, email and password """ def register(username, email, password): # initialize user database user_db = {} # add user info to database user_db[username] = { 'email': email, 'password': password } [instruction] | Create a function to register a new user using a given username, email and password. [input] | username: angelina email: angelina@example.com password: abc12345
[output] | """ Function max_money: Computes the maximum amount of money X which can be obtained using two given coins of denomination A and B. """ def max_money(A, B, X): max_A = X // A # maximum coins A can be used max_B = X // B # maximum coins B can be used # Try all possible combinations [instruction] | Compute the maximum amount of money X which can be obtained using two given coins of denomination A and B. [input] | A = 5 B = 7 X = 31
[output] | Positive. [instruction] | Classify the given news title into two categories: Positive andNegative [input] | The stock market bounces back
[output] | """ Function group_numbers: Groups a given set of numbers into a continuous range. """ def group_numbers(nums): # Initialize left and right pointers l = 0 r = 1 # Initialize ranges list ranges = [] while r < len(nums): # If the end of the range is not same as th [instruction] | Create a function to group a given set of numbers into a continuous range [input] | Set of numbers: [1, 3, 4, 6, 7, 8, 10]
[output] | class CountryComparator implements Comparator<Country> { @Override public int compare(Country c1, Country c2) { //compare by population if (c1.population < c2.population) { return -1; } else if (c1.population > c2.population) { return 1; [instruction] | Implement a comparator method in Java to compare two objects of the same class. [input] | class Country { String name; double population; double area; }
[output] | SELECT region, COUNT(*) AS population FROM Census GROUP BY region ORDER BY population DESC LIMIT 1; [instruction] | Write a MySQL query to display the most populous region with its population count [input] |
[output] | SELECT column_name, COUNT(*) AS frequency FROM table_name GROUP BY column_name ORDER BY frequency DESC LIMIT 1; [instruction] | Write an SQL query to identify the most frequently occurring value in a given column [input] |
[output] | <table> <thead> <tr> <th>Name</th> <th>Address</th> </tr> </thead> <tbody> <tr> <td>John Doe</td> <td>123 Main Street</td> </tr> <tr> <td>Jane Doe</td> <td>456 South Ave</td> </tr> </tbody> </table> [instruction] | Write a HTML code to create a table with two columns, one for the name of a person and the other for their address. [input] |
[output] | <?php // Function to encode a given string in base-64 function encodeBase64($str){ return base64_encode($str); } echo encodeBase64("Hello World!"); ?> [instruction] | Create a PHP script to encode a given string in base-64. [input] |
[output] | db.collection.find({$where: "return this.field.includes('substring')"}) [instruction] | Write a MongoDB query to find documents where a given field contains a substring. [input] |
[output] | <select> <option value="option1">Option 1</option> <option value="option2">Option 2</option> <option value="option3">Option 3</option> </select> [instruction] | Write an HTML code to create a dropdown selection list with three options. [input] |
[output] | Compilation successful. Welcome to Java [instruction] | Compile and execute this Java code. [input] | public class Main { public static void main(String[] args) { System.out.println("Welcome to Java"); } }
[output] | The “break” keyword is used to exit from the loop and continues to execute the code after the loop. The "continue" keyword is used to skip the rest of the loop and start from the beginning of the loop again. It is used mostly when you have defined certain condition and want to skip some codes when t [instruction] | Explain the use of 'break' and 'continue' in for loops. [input] |
[output] | class NewsSystem { public string title; public string content; public NewsSystem(string title, string content) { this.title = title; this.content = content; } } interface INewsActions { void PostNewArticle(NewsSystem article); void EditArticle(NewsSystem [instruction] | Create classes and interfaces to represent an online news system. [input] |
[output] | class PersonData { String name; String phoneNumber; String address; PersonData(String name, String phoneNumber, String address) { this.name = name; this.phoneNumber = phoneNumber; this.address = address; } } [instruction] | Design a data structure that will store name, phone number and address of a person. [input] |
[output] | var newList = myList.map(function(num) { return num * 2; }); [instruction] | Convert this ES6 code to ES5. [input] | let newList = myList.map(num => num * 2)
[output] | public static int ConvertToDecimal (int value, int base) { int decimalValue = 0; int i = 0; while (value != 0 && i++ < 8) { int remainder = value % 10; value /= 10; decimalValue += remainder * (int)Math.Pow(base, i); } return [instruction] | Create a function that converts an arbitrary number from any base between 2 and 16 to its decimal representation. [input] | int value = 0xFE;
[output] | Asynchronous programming is a method of concurrent programming in which a unit of work runs separately from the main application thread and notifies the calling thread of its completion, failure or progress. It enables programs to run multiple operations at the same time without blocking other opera [instruction] | Describe the purpose of Asynchronous programming. [input] |
[output] | The HSL (hue, saturation, lightness) color model is used in web development for specifying colors. Hue is the color in the color wheel, saturation is the intensity, and lightness is how light/dark the color is. This model is easy to use and understand because it uses values that are more familiar an [instruction] | Describe the use of the HSL color model in web development. [input] |
[output] | SELECT * FROM Users WHERE LastName = (SELECT LastName FROM Users); [instruction] | Create a SQL query to select all columns with the same last name from a database table. [input] | Table Name: "Users" Columns: "FirstName", "LastName"
[output] | def greeting(name): name = name.lower() print('Hello, ' + name + '!') [instruction] | Edit the following function to only accept lowercase parameters. [input] | def greeting(name): print('Hello, ' + name + '!')
[output] | SELECT SUM(RentalFee) FROM Rentals WHERE RentalDate >= DATE_SUB(CURDATE(),INTERVAL 7 DAY); [instruction] | Write SQL query to calculate total rental fees for customers who have rented a movie in the past 7 days. [input] | Table Name: "Rentals" Columns: "CustomerId", "RentalDate", "RentalFee"
[output] | SELECT MovieName FROM Movies ORDER BY BoxOfficeGross DESC LIMIT 1; [instruction] | Create a SQL query to find the highest grossing movie. [input] | Table Name: "Movies" Columns: "MovieName", "BoxOfficeGross"
[output] | function containsVowel(str) { var vowels = "aeiou" for(i=0; i<str.length; i++) { if (vowels.indexOf(str[i]) !== -1) return true; } return false; } [instruction] | Write a function in JavaScript to check if the given string contains a vowel or not. [input] |
[output] | list = ["Apple","Banana","Orange"] list.each do |item| puts item end [instruction] | Create a Ruby script to loop through the items of a given array and print it on the command line. [input] | list = ["Apple","Banana","Orange"]
[output] | arr[-1] [instruction] | How can you access the last element of the following Python array? [input] | arr = ["A","B","C","D","E"]
[output] | word = "madam" if word == word[::-1]: print("It is a palindrome") else: print("It is not a palindrome") [instruction] | How can you check if the given word is a palindrome in Python? [input] |
[output] | SELECT SUM(Amount) FROM Inventory; [instruction] | Write an SQL query that returns the sum of inventories in the Inventory table. [input] |
[output] | struct StudentAttendance { int studentId; // Unique identifier for each student int classId; // Unique identifier for each class int year; // Year of the class string month; // Month of the class int attendance; // Number of attendances }; [instruction] | Create a data structure to store records of students' attendance. [input] |
[output] | 7 [instruction] | Read the provided string and print the number of vowels in it. [input] | "GPT-3 is an advanced language model"