[output] | <select class="form-control"> <option value="">Select one</option> <option value="Option 1">Option 1</option> <option value="Option 2">Option 2</option> <option value="Option 3">Option 3</option> </select> [instruction] | Extend the following HTML code to include a dropdown list. [input] | <select class="form-control"> <option value="">Select one</option> </select>
[output] | def fibonacci(n): if n <= 0: return 0 elif n == 1: return 1 else: return fibonacci(n-1) + fibonacci(n-2) [instruction] | Code a function in Python to calculate the nth value of the Fibonacci sequence. [input] |
[output] | The customer preferences can be compared using a bar chart. The X-axis can have the labels ‘Website 1’ and ‘Website 2’ and the Y-axis can have ‘Video games/Consoles’, ‘Movies’, ‘Music’ and ‘Books’ on the axis. The bars can represent the percentage of customers with the corresponding favourite produc [instruction] | Create a visualization to compare the customer preferences of two websites. [input] | Website 1 has 4000 customers and their favourite products are video games and consoles. Website 2 has 5000 customers and their favourite products are movies, music and books.
[output] | import requests data = {'name': 'John Doe', 'age': '25'} headers = {'Content-type': 'application/x-www-form-urlencoded', 'Accept': 'text/plain'} response = requests.post('https://example.com/api/v1/data', data=data, headers=headers) [instruction] | Visit the API documentation and create code to make a POST request using Python. [input] |
[output] | const VirtualObject = () => { const [state, setState] = React.useState({ height: 100, width: 100, backgroundColor: 'blue' }); return ( <div style={{ height: state.height, width: state.width, backgroundColor: state.backgroundColor }} > </div> ); }; [instruction] | You need to generate a virtual object with React.js. [input] |
[output] | SELECT name FROM customers WHERE age > 30 [instruction] | Create an SQL query to search for customer names whose age is greater than 30 [input] |
[output] | import nltk from nltk.corpus import stopwords txt = "I am wondering what is the best way to learn English." words = nltk.word_tokenize(txt) filtered_words = [w for w in words if not w in stopwords.words('english')] print(filtered_words) [instruction] | Use nltk package in Python and remove stopwords from the given text. [input] | Text: "I am wondering what is the best way to learn English."
[output] | switch (day) { case "Sunday": printf("Sunday is a Day of Rest"); break; case "Saturday": printf("Saturday is a Day of Work"); break; default: printf("Default Action"); break; } [instruction] | Construct a switch statement for the given pseudo-code. [input] | switch (day) case Sunday: print("Sunday is a Day of Rest"); break; case Saturday: print("Saturday is a Day of Work"); break;
[output] | import requests from bs4 import BeautifulSoup page = requests.get(<uri of website>) soup = BeautifulSoup(page.content, 'html.parser') rests = soup.find_all('div', class_='restaurant-item') # Parse the details of restaurants one by one for rest in rests: name = rest.find('div', class [instruction] | Build a web scraper in Python to fetch the restaurant details from the website. [input] | <uri of the website>
[output] | <svg width="100%" height="100%" viewBox="0 0 500 500" > <rect x="0" y="0" width="500" height="500" fill="black"/> <rect x="20" y="20" width="20" height="20" fill="red" id="car"/> <animate xlink:href="#car" attributeName="x" from="20" to="480" dur="4s" repeatCount="indefinite" /> </svg> [instruction] | Using SVG element and CSS properties, create an animation of a car moving in a straight line. [input] |
[output] | public static void printPrimeNumbers(int n) { for (int i = 2; i < n; i++) { boolean isPrime = true; for (int j = 2; j < i; j++) { if (i % j == 0 ) { isPrime = false; } } if (isPrime) { S [instruction] | Develop a function in Java to display the prime numbers between 0 and 100. [input] |
[output] | import base64 json_object = '{"name":"John Doe","age":25}' encoded_object = base64.b64encode(bytes(json_object, 'utf-8')) print(encoded_object) [instruction] | Given a JSON object, encode it using Base64. [input] | { "name":"John Doe", "age":25 }
[output] | function checkKeys(array, object) { for (let i = 0; i < array.length; i++) { let key = array[i]; if (object.hasOwnProperty(key)) { console.log("key "+key+" exists"); } else { console.log("key "+key+" does not exist"); } } } [instruction] | Build a function to loop through an array and check if each key exists in the object. [input] | array = [1,2,3] object = { 1: 'one', 2: 'two' }
[output] | def spellWord(word): words = list(word) for i in range(len(words)): print(words[i]) [instruction] | Develop a program to spell a given word. [input] | "Hello"
[output] | for i in range(7): print("Hello, World!") [instruction] | Fill in the blank to print a string 7 times. [input] |
[output] | int i = 5; if (i < 10) { i++; } [instruction] | Edit the following code to increment a variable by one when its value is less than 10. [input] | int i = 5;
[output] | def remove_character(var_str, n): first_part = var_str[:n] last_part = var_str[n+1:] return first_part + last_part print(remove_character('Python', 0)) Output: ython [instruction] | Write a Python program to remove the nth index character from a nonempty string. [input] | var_str = Python, n = 0
[output] | def count_instances(list1): count_dict = dict() for item in list1: if (item in count_dict): count_dict[item] += 1 else: count_dict[item] = 1 for key, value in count_dict.items(): print(f"{key} : {value}") count_instances(list1 [instruction] | Iterate over a list and count the number of occurrences of each item. [input] | list1 = [10, 20, 30, 10, 10, 40, 10]
[output] | def longest_word(sentence): words = sentence.split() max_len = len(words[0]) for word in words: if len(word) > max_len: max_len = len(word) max_word = word return max_word print(longest_word('I am Python Programmer')) Output: Programmer [instruction] | Determine the longest word in a given string. [input] | sentence = "I am Python Programmer"
[output] | def print_hello(n): for i in range (n): print("Hello") print_hello(5) Output: Hello Hello Hello Hello Hello [instruction] | Given a number n, print “Hello” n times. [input] | n = 5
[output] | def check_case_ignore(str1, str2): return str1.lower().endswith(str2.lower()) print(check_case_ignore('Strawberry', 'berry')) Output: True [instruction] | Given two strings, return True if either of the strings appears at the very end of the other string, ignoring upper/lower case differences. [input] | str1 = "Strawberry", str2 = "berry"
[output] | from itertools import permutations def permutations_string(string): return list(permutations(string)) permutations_string("abc") Output: [('a', 'b', 'c'), ('a', 'c', 'b'), ('b', 'a', 'c'), ('b', 'c', 'a'), ('c', 'a', 'b'), ('c', 'b', 'a')] [instruction] | Get all permutations of string. [input] | string = "abc"
[output] | <!DOCTYPE html> <html> <head> <title>HTML Table</title> </head> <body> <table> <tr> <th>Column 1</th> <th>Column 2</th> <th>Column 3</th> <th>Column 4</th> </tr> <tr> <td>Row 1</td> <td>Row 1</td> <td>Row 1</td> <td>Row 1</td> </tr> <tr> <td>Row [instruction] | You need to create an HTML page containing a table that contains at least 4 columns and 5 rows. [input] |
[output] | def count_primes(numbers): count = 0 for number in numbers: if is_prime(number): count += 1 return count def is_prime(number): if number <= 1: return False for i in range(2, number): if number % i == 0: return False return Tru [instruction] | You are given a list of numbers. Count how many of them are prime numbers. [input] | [1,2,3,4,5,6,7]
[output] | def handleInput(name): if len(name) > 0: print('Hello, ' + name) else: print('No name provided.') [instruction] | Edit the given code to ensure it outputs appropriate messages for successful and unsuccessful output. [input] | def handleInput(name): if len(name) > 0: print('Hello, ' + name)
[output] | Yes. The function is syntactically correct. [instruction] | Is the following code syntactically correct? [input] | function addNumbers(a, b) { return a + b
[output] | function rotateString(string) { return string.slice(3) + string.slice(0, 3); } [instruction] | Create a JS program that rotates a given string by 3 characters. [input] |
[output] | def reverse_string(str): reverse = "" # Traverse through each letter of the input string for i in range(len(str) - 1, -1, -1): reverse = reverse + str[i] print(reverse) [instruction] | Modify the following code so that it takes a string as a parameter, reverses it and prints out the reversed string. [input] | str = "Hello World!"
[output] | import random # Function to swap two elements # in a list at positions i and j def swap(arr, i, j): arr[i], arr[j] = arr[j], arr[i] # Function to generate a random # permutation of arr[] def randomize ( arr, n ) : # Start from the last element and swap # one by one. We don't [instruction] | Find a way to randomly swap two elements of an array. [input] | [1, 2, 3, 4, 5]
[output] | // A linked list node class Node: # Constructor to create a new node def __init__(self, data): self.data = data self.next = None # Function to reverse the linked list def reverse(head): prev = None current = head while(current is not None): next [instruction] | Implement a method that reverses a linked list [input] | head = 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> null