← 목록

Synth · CodeAlpaca일부

총 20,022개 · 페이지 504/668
🔀 랜덤
불러오는 중…

[output] | Debugging a HTML page involves inspecting the page elements to detect any errors and identify the source of any issues. Many web browsers have a Developer Tools feature that can be used to inspect and debug the page. It allows you to view the page HTML and JavaScript, as well as view any errors and [instruction] | Describe how to debug a HTML web page. [input] |

[output] | arr = [1, 2, 3, 4, 5] i = 0 while i < len(arr): element = arr[i] print(element) i += 1 [instruction] | Construct a while loop in order to traverse through an array. [input] |

[output] | SELECT * FROM employees WHERE age > 30; [instruction] | Suggest a SQL query to retrieve the employee records with an age greater than 30. [input] |

[output] | We can find all the divisors of a number by using a for loop to iterate from 1 to n. For each number, we check if it is a divisor of n. If it is, then we add it to a list of divisors. At the end of the loop, we will have the list of all divisors of n. [instruction] | Suggest a way to find all the divisors of a number, n. [input] |

[output] | Writing a recursive program involves identifying a base case, which is a situation where the answer has been found and doesn’t need to be recomputed. This is followed by defining the recursive case which involves breaking the problem down into smaller and smaller subproblems until the base case is r [instruction] | Describe the process of writing a recursive program. [input] |

[output] | def sum_to_n(n): total = 0 for i in range(1, n + 1): total += i return total [instruction] | Create a function that takes an integer n as an argument and returns the sum of all numbers from 1 to n. [input] | n = 10

[output] | function isPalindrome(str) { var i; var len = str.length; for (i = 0; i < len/2; i++) { if (str[i] !== str[len - 1 - i]) { return false; } } return true; } [instruction] | Using JavaScript, write a function that takes a string as an argument and prints out whether the string is a Palindrome. [input] | str = "racecar"

[output] | def findMax2Numbers(arr): max1 = 0 max2 = 0 for i in range(len(arr)): temp = arr[i] + max1 max2 = max1 if temp > max2: max1 = temp elif max2 > temp: max1 = max2 return max1, max2 [instruction] | Find the max 2 numbers in a list of 5 numbers without using any comparison operator. [input] | arr = [3, 10, 2, 5, 9]

[output] | for i in range(1,11): print(i ** 2) [instruction] | Generate a for-loop that prints out the square of the first 10 natural numbers. [input] |

[output] | mkdir testDir [instruction] | Assume that you want to create a directory called 'testDir' in the current working directory. Write the command that can be used to do this in Linux. [input] |

[output] | public static void printList(List<String> list){ list.forEach(s -> System.out.println(s)); } [instruction] | Rewrite the following code snippet (written in Java), such that the same purpose is accomplished but with fewer lines of code. [input] | public static void printList(List<String> list) { for (int i = 0; i < list.size(); i++) { System.out.println(list.get(i)); } }

[output] | def add_nums(arr): total = 0 for x in arr: total += x return total [instruction] | Given a list of numbers, write a function that returns the sum without using the built-in 'sum()' function. [input] | arr = [3, 4, 2, 5, 9]

[output] | INSERT INTO students (name, age) VALUES ("John Doe", 21); [instruction] | Create a SQL statement that updates a table called 'students' with a new entry. [input] | name = "John Doe" age = 21

[output] | #include <iostream> // Perform addition, subtraction, multiplication and division. int main() { char operate; float num1, num2; std::cout << "Enter an operator +, -, *, or /: "; std::cin >> operate; std::cout << "Enter two numbers: "; std::cin >> num1 >> num2; [instruction] | Develop a C++ program to implement a basic calculator that performs addition, subtraction, multiplication and division. [input] |

[output] | public static boolean isPrime(int number) { if (number == 2 || number == 3) return true; if (number % 2 == 0 || number % 3 == 0) return false; int sqrtN = (int)Math.sqrt(number) + 1; for (int i = 6; i <= sqrtN; i += 6) { if (number % (i - 1) == 0 || number % (i + 1) == 0 [instruction] | Write a Java code snippet to check whether or not a number is a prime. [input] |

[output] | import random def randomString(stringLength=10): lettersAndDigits = string.ascii_letters + string.digits return ''.join(random.choice(lettersAndDigits) for i in range(stringLength)) [instruction] | Write a Python program to create a random string of size 10 consisting of alphabets and digits. [input] |

[output] | SELECT salary FROM employees WHERE salary > 50000; [instruction] | Write an SQL query to get all employee salaries whose salaries are more than 50000. [input] |

[output] | int count = 0; foreach (int num in arr) { if (num == k) count++; } Console.WriteLine("Number of occurrences of {0} is {1}.", k, count); [instruction] | Write a C# program to print the number of occurrences of the given number in a given array. [input] | int[] arr = {2, 4, 8, 8, 8, 10}, k = 8

[output] | int new_arr[6]; int j = 0; for (int i = 0; i < 6; i++) { if (arr[i] >= 0) { new_arr[j] = arr[i]; j++; } } [instruction] | Write a C++ program to create a new array from a given array of integers, removing negative numbers. [input] | int arr[] = {-4, 3, 2, -2, 6, -7}

[output] | SELECT Name FROM Employees WHERE JoinDate > '2018-01-01'; [instruction] | Construct a SQL query to get the names of all employees who joined after January 1st 2018. [input] |

[output] | SELECT E1.Name AS EmployeeName, E2.Name AS ManagerName FROM Employees E1 INNER JOIN Employees E2 ON E1.ManagerId = E2.EmployeeId; [instruction] | Write an SQL query to display the name of the employees and their managers. [input] |

[output] | for (int i = 0; i < matrix.GetLength(0); i++) { int temp = matrix[i, 0]; matrix[i, 0] = matrix[i, matrix.GetLength(1)-1]; matrix[i, matrix.GetLength(1)-1] = temp; } [instruction] | Write a C# program to interchange the elements of the first and last columns of a given matrix. [input] | int[,] matrix = { { 11, 21, 31, 41 }, { 12, 22, 32, 42 }, { 13, 23, 33, 43 } };

[output] | for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[i].length; j++) System.out.print(matrix[i][j] + " "); System.out.println(); } [instruction] | Write a Java program to print the elements (i, j) of a two dimensional array. [input] | int[][] matrix = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}

[output] | SELECT Title FROM Movies WHERE Awards > 10; [instruction] | Construct an SQL query to display the titles of movies with more than 10 awards. [input] |

[output] | <!DOCTYPE html> <html> <head> <title>Centered text heading</title> </head> <body> <h1 align="center">Heading</h1> </body> </html> [instruction] | Construct an HTML page with a centered text heading. [input] |

[output] | public class NetworkUtil { public static boolean isConnected(Context context){ ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo(); [instruction] | Write an Android program to detect if the device is connected to the Internet. [input] |

[output] | tell application "Safari" open location "https://www.google.com" end tell [instruction] | Write an AppleScript to open a given link in Safari. [input] | https://www.google.com

[output] | ALTER TABLE people MODIFY age INT; [instruction] | Write an SQL query to change the column type of a table. [input] | table: people column: age type: INT

[output] | def replace_in_list(list, old_element, new_element): for i, element in enumerate(list): if element == old_element: list[i] = new_element return list [instruction] | Create a function in Python to replace a specified element in a given list [input] |

[output] | print('Hello World') [instruction] | Write the shortest code to print Hello World [input] |

← → 방향키로 페이지 이동 · 숫자 입력 후 Enter로 점프