[output] | def Fibonacci(n): if n==0 or n==1: return n else: return Fibonacci(n-1)+Fibonacci(n-2) def Fibonacci_Series(max_num): for n in range(max_num+1): print(Fibonacci(n)) # Output: 0 1 1 2 3 5 [instruction] | how to implement a recursive function for computing Fibonacci numbers? [input] | max_num = 5
[output] | ^(Apple|Bananas|Oranges)$ [instruction] | Construct a regular expression pattern to match a specific set of strings. [input] | Match the following strings: Apple, Bananas, Oranges
[output] | class Employee: def __init__(self, name, age): self.name = name self.age = age def get_age(self): print(self.age) [instruction] | Using the provided class, add a new method to print the age of employees. [input] | class Employee: def __init__(self, name, age): self.name = name self.age = age
[output] | A proxy object is an intermediary object that is responsible for managing access to a target object or service to protect it from unauthorized access. [instruction] | Explain in a sentence the concept of proxy objects. [input] |
[output] | eThay atcay jumpeday overay ethay oxbay. [instruction] | Translate the provided sentence into Pig Latin. [input] | The cat jumped over the box.
[output] | 1,2,3 4,5,6 7,8,9 [instruction] | Convert the given matrix into a comma-separated values (CSV) format. [input] | [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
[output] | # Take the input from user num1 = int(input("Enter number 1: ")) num2 = int(input("Enter number 2: ")) # Add the numbers sum = num1 + num2 # Print the result print("The sum is: " + str(sum)) [instruction] | Make a simple program that adds two numbers. [input] |
[output] | import json data = {**a, **b} json_data = json.dumps(data) [instruction] | Construct a JSON structure from its respective python dictionaries [input] | a = { "name": "John", "age": 32 } b = { "cars": ["Ford", "BMW", "Fiat"] }
[output] | def print_array(arr): for element in arr: print(element, end=' ') [instruction] | Write a function that takes an array and prints every element in a single line. [input] | my_array = [1, 2, 3]
[output] | if (number >= min_range) and (number <= max_range): print("The number is within the given range.") [instruction] | Write a statement which checks whether a number is within a given range. [input] | number = 7 min_range = 5 max_range = 10
[output] | if day_of_week == "Monday": print("It's Monday") elif day_of_week == "Tuesday": print("It's Tuesday") elif day_of_week == "Wednesday": print("It's Wednesday") elif day_of_week == "Thursday": print("It's Thursday") elif day_of_week == "Friday": print("It's Friday") elif day_of_wee [instruction] | Using a conditional statement, print a message depending on the day of the week. [input] | day_of_week = "Thursday"
[output] | x = 5 if x > 4: print('x is greater than 4') else: print('x is not greater than 4') [instruction] | Rewrite the following expression using an if-else statement. [input] | x = 5 if x > 4: print('x is greater than 4')
[output] | class Employee: def __init__(self, name, age, salary): self.name = name self.age = age self.salary = salary def get_name(self): return self.name def get_age(self): return self.age def get_salary(self): return self.salary [instruction] | Design a class that stores the data of an individual employee [input] |
[output] | def compare_numbers(num1, num2): if num1<num2: return 'lower' elif num1>num2: return 'higher' else: return 'equal' [instruction] | Create a function that compares two numbers and returns 'lower', 'higher', or 'equal' based on the comparison. [input] |
[output] | seconds_in_day = 24 * 60 * 60 [instruction] | Calculate the number of seconds in a day. [input] |
[output] | CREATE TABLE users ( id SERIAL PRIMARY KEY, username VARCHAR NOT NULL UNIQUE, password VARCHAR NOT NULL, created_at TIMESTAMP NOT NULL DEFAULT NOW() ); [instruction] | Create a database schema for managing authentication users. [input] |
[output] | $.ajax({ url: 'url', type: 'POST', contentType: 'application/json', data: JSON.stringify([{"name":"John", "age":21}, {"name":"Dave", "age":25}]) }); [instruction] | Pass the following JSON array to an AJAX request. [input] | [{"name":"John", "age":21}, {"name":"Dave", "age":25}]
[output] | arr[2] = 10; [instruction] | Change the value of the third element in the following array. [input] | int[] arr = {1, 3, 4, 5};
[output] | #sidebar { border-bottom: 1px solid black; } #content { border-top: 1px solid black; } [instruction] | Write CSS code to separate the sidebar from the content by a horizontal line. [input] |
[output] | app.get('/books', (req, res) => { // retrieve list of books from database res.json(books); }); [instruction] | Create a route for a REST API to retrieve a list of all books. [input] |
[output] | Python. [instruction] | Identify the programming language of the sample code snippet. [input] | def find_average(numbers): sum = 0 for num in numbers: sum += num return sum / len(numbers)
[output] | function heapSort(arr) { let n = arr.length; for (let i = Math.floor(n / 2 - 1); i >= 0; i--) { heapify(arr, n, i); } for (let i = n - 1; i > 0; i--) { [arr[0], arr[i]] = [arr[i], arr[0]]; heapify(arr, i, 0); } return arr; } function heapify(arr, n, i) { let largest = i; let left = [instruction] | Write a function to implement heap sort in JavaScript. [input] |
[output] | def convert_to_multi(a): result = [] for i in range(len(a)): row = [] for j in range(len(a)): row.append(a[j]) result.append(row) return result [instruction] | Edit the given function in Python to convert the given list of integers a into a multidimensional list of size len(a) X len(a). [input] | def convert_to_multi(a): return [a]
[output] | String. [instruction] | Find the data type of the variable x in the following JavaScript code snippet? [input] | let x = "Hello World";
[output] | void remove_vowels(char *s) { for (int i = 0; s[i] != '\0'; i++) { if (s[i] == 'a' || s[i] == 'A' || s[i] == 'e' || s[i] == 'E' || s[i] == 'i' || s[i] == 'I' || s[i] == 'o' || s[i] == 'O' || s[i] == 'u' || s[i] == 'U') { for (int j = i; s[j] != '\0'; ++j) { [instruction] | Given a word, remove all the vowels from it in C. [input] |
[output] | let book = { title: 'Lord of the Rings', author: 'J.R.R. Tolkien' }; [instruction] | Create an object in JavaScript to save the particular book detail. [input] | Title: Lord of the Rings Author: J.R.R. Tolkien
[output] | Classes in Java are user-defined templates for creating objects. A class specifies the data and behavior associated with any objects created from it. An object is an instance of a class which contains its own set of attributes and methods. Objects can interact with each other’s attributes and method [instruction] | Explain the concept of classes and objects in Java. [input] |
[output] | SELECT product_name, price FROM products WHERE price > 50; [instruction] | Generate an SQL query to select product names and prices that are greater than $50. [input] |
[output] | class Calculator: def add(self, x, y): return x + y def sub(self, x, y): return x - y [instruction] | Create a Python class 'Calculator' with two methods: 'add' and 'sub'. [input] |
[output] | <!-- Edited HTML page --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Table Example</title> </head> <body> <table> <tr> <th>First Header</th> <th>Second Header</th> </tr> <tr> <td>Row 1, Cell 1</td> <td>Row 1, Cell 2</td> </tr> <tr> <t [instruction] | Edit the following HTML page to add a table with three rows and two columns. [input] | <!-- HTML page --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Table Example</title> </head> <body> </body> </html>