← 목록

Synth · CodeAlpaca일부

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

[output] | SELECT * FROM products WHERE product_id = 1 LIMIT 10; [instruction] | Create a SQL statement to select the first ten elements from a table with a specific id. [input] | The table name is 'products', and the product id is 1.

[output] | Sub upperCase() Dim myText As String myText = "Hello World" ActiveCell.Value = UCase(myText) End Sub [instruction] | Write a VBA macro to convert a sequence of text to uppercase. [input] | The text is: "Hello World".

[output] | <html> <body> <ol> <li>Apple</li> <li>Banana</li> <li>Orange</li> <li>Strawberry</li> <li>Lemon</li> </ol> </body> </html> [instruction] | Create a HTML page with an ordered list of items using [input] | Five items: apple, banana, orange, strawberry, and lemon.

[output] | #include <iostream> int main() { // Print the pattern using nested for loop for (int i=0; i<5; i++) { for (int j=0; j<i+1; j++) std::cout << "*"; std::cout << std::endl; } return 0; } /* Output * ** *** **** ***** */ [instruction] | Write a C++ program that prints the following pattern to the screen: [input] |

[output] | public static String reverse(String str) { String reversedString = ""; for (int i = str.length() - 1; i >= 0; i--) { reversedString += str.charAt(i); } return reversedString; } [instruction] | Design a method for reversing a string in Java [input] |

[output] | def sortAsc(lst): for i in range(len(lst)): for j in range(i+1, len(lst)): if lst[i] > lst[j]: lst[i], lst[j] = lst[j], lst[i] return lst [instruction] | Given an input list of integers, sort the list in ascending order [input] |

[output] | SELECT state FROM zip_codes WHERE zip_code = '90210'; [instruction] | Create an SQL query to find all states in a given zip code [input] | The zip code is 90210.

[output] | Total Cost = Item Price + (Item Price * (Tax Rate/100)) [instruction] | Create a formula that calculates the total cost of an item given the item price and tax rate [input] |

[output] | <?xml version="1.0"?> <root> <person> <name>John Doe</name> <age>22</age> <address> <street>123 Main St.</street> <city>Anytown</city> <state>FL</state> <zip>12345</zip> </address> </person> </root> { "person" : { "name" : "John Doe", "age" : 22 [instruction] | Convert a given XML document to JSON document [input] |

[output] | a = 3 b = 5 if a > b: print(a) else: print(b) [instruction] | Input two numbers and output the maximum one in Python [input] | 3, 5

[output] | def quick_sort(arr): if len(arr) <= 1: return arr pivot = arr[len(arr) // 2] left = [x for x in arr if x < pivot] right = [x for x in arr if x > pivot] return quick_sort(left) + [pivot] + quick_sort(right) [instruction] | Sort the list using Quick Sort [input] | [2, 3, 5, 6, 1, 4]

[output] | SELECT * FROM my_table WHERE age IS NULL OR age != ''; [instruction] | Generate a SQL query to return all records from the table with a specified column including null values [input] | Table name: my_table Column name: age

[output] | if (number % 4 == 0) System.out.println("The number is divisible by 4"); else System.out.println("The number is not divisible by 4"); [instruction] | Construct an if-else statement to determine if a given number is divisible by 4 [input] |

[output] | SELECT * FROM my_table ORDER BY date DESC LIMIT 1; [instruction] | Formulate a SQL query that fetches the records with the latest date [input] | Table name: my_table Columns: id, date

[output] | const greenObjects = arr.filter(obj => obj.color === 'green'); [instruction] | Write a script in JavaScript to iterate over a given array of objects and return all objects with the color green. [input] | const arr = [{ color: 'blue', shape: 'square' }, { color: 'red', shape: 'triangle' }, { color: 'green', shape: 'circle' }]

[output] | function findElementsSum(array, target){ let result = []; for (let i = 0; i < array.length; i++){ for (let j = i+1; j < array.length; j++){ if (array[i] + array[j] == target){ result.push([i, j]); } } } return result; } [instruction] | Write a JavaScript function that returns that number of elements from an array of numbers which sum up to a given target. [input] | array = [2, 3, 7, 8, 10] target = 11

[output] | def all_vowels_palindrome(word): vowels = ['a', 'e', 'i', 'o', 'u'] if not word == word[::-1]: return False for char in vowels: if char not in word: return False return True [instruction] | Write a Python function to check if a given string is a palindrome and has all the vowels in it. [input] |

[output] | def same_frequency(num1,num2): str1 = str(num1) str2 = str(num2) if len(str1) != len(str2): return False dict = {} for char in str1: if char in dict: dict[char] += 1 else: dict[char] = 1 for char in str2: if not char in [instruction] | Write a Python script to detect if two numbers have the same frequency of digits. [input] |

[output] | def transpose_(arr): transposedarr = [] for i in range(len(arr[0])): row = [] for j in range(len(arr)): row.append(arr[j][i]) transposedarr.append(row) return transposedarr [instruction] | Writing a Python function which takes a 2D array as an argument and transposes it. [input] | arr = [[4, 5, 44], [3, 8, 20], [2, 5, 10]]

[output] | function sortedArraySearch(arr, el) { let start = 0, end = arr.length - 1; while (start <= end) { let mid = Math.floor((start + end) / 2); if (arr[mid] === el) return true; else if (arr[mid] < el) start = mid + 1; else end = mid - 1; } return false; } [instruction] | Create a function in JavaScript to search an element in a given sorted array. [input] | arr = [1, 3, 4, 5, 6, 7, 9, 11]

[output] | Polymorphism is the ability of an object to be interpreted and used differently in different contexts. In object-oriented programming, it allows operations to be performed on objects despite different underlying data types. For example, it allows functions to take multiple types of arguments and sti [instruction] | What is polymorphism and how it is used in object-oriented programming? [input] |

[output] | public class Person { String name; void displayAge(){ System.out.println("age is: "+ age); } void printName(){ System.out.println("Name: "+ name); } } [instruction] | Edit the following code in Java to include a new method “printName()”. [input] | public class Person { String name; void displayAge(){ System.out.println("age is: "+ age); } }

[output] | The class keyword in C++ is used to declare a class, which contains (public or private) data members, member functions, and constructors. A class can be thought of as a blueprint for creating objects that have their own state and behavior. Data members represent the state of an object, and the membe [instruction] | Describe the use of the class keyword in C++. [input] |

[output] | Average age = 17.8 [instruction] | Compute the average age of the following ages: 18, 20, 17, 19, 15. [input] |

[output] | A min-heap is a data structure used for storing and retrieving data. It is a complete binary tree, where the root node is the minimum element in the heap. Each node of the heap follows the "min-heap" property, where the parent node is always less than or equal to its children. This property allows f [instruction] | Explain how a min-heap works. [input] |

[output] | cd /Users/username/Documents [instruction] | Write a shell command to switch to a given directory [input] | Dirpath=/Users/username/Documents

[output] | for i, num in enumerate(lst): print(i, num) [instruction] | Construct a for loop in Python to iterate through the items in the list and print their corresponding index. [input] | lst = [1,2,3]

[output] | name_planets = ["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"] fifth_planet = name_planets[4] print(fifth_planet) [instruction] | Write a code snippet to get the name of the planet which is the fifth planet from the sun. [input] |

[output] | for item in lst[:]: if not isinstance(item, int): lst.remove(item) [instruction] | Write code to delete all elements in a given Python list which are NOT integer type. [input] | lst = [1, "a", 2.3, False, 4, "abc"]

[output] | ALTER TABLE products ADD COLUMN size INT, ADD COLUMN color VARCHAR(100); [instruction] | Write an SQL statement to add two new columns, 'size' and 'color', to the existing products table. [input] |

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