[output] | prime_list = [] for num in range(100): if num > 1: for i in range(2, num): if (num % i) == 0: break else: prime_list.append(num) print(prime_list) [instruction] | Generate the list of all prime numbers between 0 and 99. [input] |
[output] | my_array = [] for x in range(1, 11): my_array.append(x) print(x) [instruction] | Create an array loop to print all the elements from 1 to 10. [input] |
[output] | import math my_list = [5, 10, 20, 7, -8, 15] largest = max(my_list) smallest = min(my_list) print("Largest element is:", largest) print("Smallest element is:", smallest) [instruction] | Find the largest and smallest number in a given list. [input] | [5, 10, 20, 7, -8, 15]
[output] | <html> <head> <title>Menu toggle example</title> </head> <body> <h1>Toggle Menu</h1> <div id="menu-container"> <a href="link1.html">Link 1</a> <a href="link2.html">Link 2</a> <a href="link3.html">Link 3</a> </div> <button id="toggle-menu">Toggle Menu</butt [instruction] | Create a web page that has a button to toggle a navigation bar. [input] |
[output] | button:hover { display: block; } button { display: none; } [instruction] | Emulate the following behavior in CSS [input] | // Button should show/hide when hovered
[output] | # return square of x [instruction] | Isolate all the comments from a given piece of code [input] | def square(x): # return square of x return x * x
[output] | for i in range(10): print(i) [instruction] | Modify this piece of code to print numbers up to 10 [input] | for i in range(5): print(i)
[output] | <ul> <li class="list-item">Apple</li> <li class="list-item">Orange</li> <li class="list-item">Banana</li> </ul> [instruction] | Add a class titled "list-item" to the following HTML tag [input] | <ul> <li>Apple</li> <li>Orange</li> <li>Banana</li> </ul>
[output] | int[][] array = new int[5][6]; [instruction] | Generate a 2D array with 5 rows and 6 columns in Java [input] |
[output] | The area of the square is 9 square inches. [instruction] | Calculate the area of a square with each side equal to 3 inches [input] |
[output] | The greatest common divisor of 3 and 8 is 1. [instruction] | Compute the greatest common divisor of the numbers 3 and 8 [input] |
[output] | <html> <head> <title>Weekdays</title> </head> <body> <h1>Weekdays</h1> <ul> <li>Monday</li> <li>Tuesday</li> <li>Wednesday</li> <li>Thursday</li> <li>Friday</li> <li>Saturday</li> [instruction] | Create a web page to display all the weekdays [input] |
[output] | def is_prime(num): if num <= 1: return False for i in range(2, num): if num % i == 0: return False return True [instruction] | Write a function to determine if a given number is prime and returns true or false. [input] |
[output] | def area_of_circle(r): area = 3.14 * (r ** 2) return area [instruction] | Write a function to find the area of a circle when the radius is given in input. [input] | r = 4
[output] | def validate_strings(s1, s2): if len(s1) > 10 and '@' not in s1: return False if len(s2) < 5 and '@' in s2: return False return True [instruction] | Perform data validation on two strings s1 and s2 according to the given conditions on the length and special characters. [input] | s1 = "Hello@world" s2 = "Test"
[output] | def pre_order_traversal(tree): # Visit the root print(tree.value) # Traverse the left subtree, if it exists if tree.left: pre_order_traversal(tree.left) # Traverse the right subtree, if it exists if tree.right: pre_order_traversal(tree.right) [instruction] | Given a tree, traverse it in the pre-order manner. [input] |
[output] | SELECT Name, Age, Score FROM Student; [instruction] | Write a SQL query to retrieve all records from a table called 'Student' which has the fields 'Name', 'Age' and 'Score'. [input] |
[output] | public static void printNumbers(int n) { for (int i = 1; i <= n; i++) { System.out.print(i + " "); } System.out.println(); } [instruction] | Design a function in Java which takes an integer n as an argument and prints the numbers from one to n. [input] |
[output] | let student = { name: "John", email: "john@example.com", grades: ["A", "B", "C"] } [instruction] | Create a JavaScript object which contains student information such as name, email and grades. [input] | Name: John Email: john@example.com Grades: A, B, C
[output] | <p><strong>This is some sample text.</strong></p> [instruction] | Modify the given HTML code to make the text bold. [input] | <p>This is some sample text.</p>
[output] | SELECT Name, Age FROM Student WHERE Score > 95; [instruction] | Produce a SQL query to find the names and ages of all students who have a score greater than 95. [input] |
[output] | <html> <body> <p>Today is <span id="date"> </span> and the time is <span id="time"> </span>.</p> <script> let d = new Date(); let date = d.toDateString(); document.getElementById("date").innerHTML = date; let time = d.toLocaleTimeString(); document.getElementById("time").inner [instruction] | Write an HTML page which displays the current time and date. [input] |
[output] | public static int countVowels(String str) { int count = 0; for (int i = 0; i < str.length(); i++) if (str.charAt(i) == 'a' || str.charAt(i) == 'e' || str.charAt(i) == 'i' || str.charAt(i) == 'o' || str.charAt(i) == 'u') count++; return count; } [instruction] | Prepare a Java method which takes a string as an argument and returns the number of vowels in it. [input] |
[output] | def find_median(arr): arr.sort() if len(arr) % 2 != 0: return arr[len(arr)//2] return (arr[(len(arr)//2)-1] + arr[len(arr)//2])/2 [instruction] | Design a Python script that takes an array of integers and finds the median. [input] |
[output] | import pandas as pd # Input Data df = pd.DataFrame({'Name': ['John','Jane','Maria'], 'Age': [25, None, 30]}) # Filter the Data filtered_df = df.loc[df['Age'].notnull()] print(filtered_df) [instruction] | Write a Python function using the Pandas library to filter out the rows with a missing value in the specified column. [input] | Dataframe: Name Age John 25 Jane Maria 30 Column Name: Age
[output] | SELECT * FROM customers WHERE age BETWEEN 18 AND 25; [instruction] | Create an MySQL query that finds customers whose age is between 18 and 25 [input] |
[output] | L = [1, 'a', 4, 3, 'b', 6, 'c'] def Max_in_List(L): max_num = 0 for item in L: if type(item) == int and item > max_num: max_num = item return max_num print(Max_in_List(L)) [instruction] | Create a Python script to find the maximum value of a list containing both strings and numbers [input] | L = [1, 'a', 4, 3, 'b', 6, 'c']
[output] | def my_generator(N): for i in range(N): yield i g = my_generator(5) print(list(g)) # [0, 1, 2, 3, 4] [instruction] | Generate a Python generator to produce a sequence of the first N numbers [input] | 5
[output] | def even_length_words(word_list): even_words = [] for word in word_list: if len(word) % 2 == 0: even_words.append(word) return even_words if __name__ == '__main__': print(even_length_words(word_list)) [instruction] | Create a python script to filter a list of words, and return only those with even length characters. [input] | word_list = ["Python", "C++", "Java", "JavaScript", "Ruby"]
[output] | 15 [instruction] | Outpus the sum of two integer variables. [input] | a = 5 b = 10