[output] | text = 'Hello World' print(text[::-1]) [instruction] | Construct a python code to print the following text in reverse. [input] | Hello World
[output] | 5 parameters. [instruction] | Count the number of parameters for the given function. [input] | def add_names(name1, name2, name3, name4, name5): names = [name1, name2, name3, name4, name5] return names
[output] | def gcd(num1, num2): if(num2 == 0): return num1 else: return gcd(num2, num1 % num2) # Driver code num1 = 99 num2 = 77 print ("The GCD of", num1, "and", num2, "is", gcd(num1, num2)) [instruction] | Create a program that prints the greatest common divisor between two numbers. [input] | num1 = 99 num2 = 77
[output] | class Node: def __init__(self, data): self.data = data self.next = None def convertToLinkedList(arr): # Last Node last = None # convert given array to linked list for i in range(len(arr) - 1, -1, -1): # create a new node node = Node(ar [instruction] | Change the given array to a singly linked list without using a loop. [input] | array = [1, 2, 3, 4, 5]
[output] | input_string = 'Hello World!' def reverse_string(input_string): if len(input_string) == 0: return "" else: return reverse_string(input_string[1:]) + input_string[0] res = reverse_string(input_string) print(res) [instruction] | Generate a code to reverse a string without using any loop. [input] | Input String = "Hello World!"
[output] | def longest_common_substring(s1, s2): m = len(s1) n = len(s2) # initialize matrix L = [[0 for x in range(n + 1)] for x in range(m + 1)] # To store the length of longest common substring length = 0 # Comparing each character of s1 and s2 for i in range [instruction] | Write a function that returns the length of the longest common substring between two strings. [input] | s1 = 'abcde' s2 = 'abfghe'
[output] | 5.2 [instruction] | Evaluate the following expression and report the result [input] | 3 * (4 + 2) / 5
[output] | true [instruction] | Output true if the given string contains the word "Hello", otherwise output false. [input] | "Hello world!"
[output] | 384 [instruction] | Print out the product of all the even numbers between 0 and 10 [input] |
[output] | 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 [instruction] | Output the Fibonacci sequence up to 50 [input] |
[output] | def reverse(s): rev = "" i = len(s) while i > 0: rev += s[ i - 1 ] i = i - 1 return rev [instruction] | Complete the following function to output a reversed string [input] |
[output] | { "user1": { "visit_count": 0 }, "user2": { "visit_count": 0 } } [instruction] | Write a JSON script that keeps track of the number of times a user has visited a website. [input] |
[output] | def is_prime(n): if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def find_prime_numbers(n): primes = [] for i in range(2, n + 1): if is_prime(i): primes.append(i) return primes [instruction] | Given an integer n, write a program to print out the prime numbers up to n. [input] |
[output] | [ ['1', 'x', '1'], ['x', '1', 'x'], ['1', 'x', '1'], ] [instruction] | Given a 2D array of characters, replace each '0' entry with 'x'. [input] | [ ['1', '0', '1'], ['0', '1', '0'], ['1', '0', '1'], ]
[output] | CREATE FUNCTION getMaxSalary() RETURNS int BEGIN DECLARE @maxSalary int; SELECT @maxSalary = MAX(salary) FROM employees; RETURN @maxSalary; END [instruction] | Create a function in SQL to find the maximum salary of an employee. [input] |
[output] | public float getAverage(float a, float b) { return (a + b) / 2; } [instruction] | Modify the following code to convert it from JavaScript to Java. [input] | function getAverage(a, b) { return (a + b) / 2; }
[output] | <?php function isDivisibleBy7($num) { return ($num % 7 == 0); } ?> [instruction] | Create a PHP script to return whether a given number is divisible by 7 [input] |
[output] | class ArraySort { void sort(int arr[]) { int n = arr.length; // One by one move boundary of unsorted subarray for (int i = 0; i < n-1; i++) { // Find the minimum element in unsorted array int min_index = i; for [instruction] | Create a Java class which sorts the given array of numbers. [input] | [9, 2, 4, 3, 6, 1]
[output] | function addNumbers(a, b) { return a + b; } [instruction] | Create a function in JavaScript to sum two numbers. [input] |
[output] | <!DOCTYPE html> <html> <head> <title>Hello World</title> <style> body { display: flex; justify-content: center; align-items: center; margin: 0; } </style> </head> <body> <h1>Hello World</h1> </body> </html> [instruction] | Create an HTML page which displays Hello World in the center of the page. [input] |
[output] | Print "Hello World". [instruction] | Turn the following sentence into an imperative sentence. [input] | Let's print "Hello World"
[output] | def reverse_nums(num_list): n = len(num_list) for i in range(n//2): num_list[i], num_list[n-i-1] = num_list[n-i-1], num_list[i] return num_list [instruction] | Compose a program to reverse a list of numbers [input] |
[output] | num = input("Enter a number: ") try: num = int(num) except ValueError: print("Input must be a number") [instruction] | Modify the given code to ensure that the input is a number [input] | num = input("Enter a number: ")
[output] | def remove_even(arr): new_arr = [] for num in arr: if num % 2 != 0: new_arr.append(num) return new_arr [instruction] | Program a function to remove all the even numbers from an array [input] |
[output] | string = input("Enter a string: ") if not string.isalpha(): print("Input must contain only letters") [instruction] | Modify the code for the given purpose [input] | string = input("Enter a string: ")
[output] | def find_sum(x): sum = 0 for i in range(1, x): if i % 3 == 0: sum += i elif i % 5 == 0: sum += i return sum [instruction] | Rewrite the program to get the same output [input] | def find_sum(x): sum = 0 for i in range(1,x): if i % 3 == 0 or i % 5 == 0: sum += i return sum
[output] | def is_divisible(n, m): if n % m == 0: return True return False [instruction] | Create a program to determine if a number is divisible by another number [input] |
[output] | def foo(x, y, z = 0): print(x, y, z) [instruction] | Modify the given code to set the third parameter to 0 [input] | def foo(x, y, z): print(x, y, z)
[output] | import base64 def encode_base64(text): return base64.b64encode(text.encode()).decode() [instruction] | Write a code to encode a given body of text into base64 [input] | text="Hello World"
[output] | def contains(nums, element): return element in nums [instruction] | Write a code to determine if a given list contains a particular element [input] | nums=[1,2,3,4]