← 목록

Synth · CodeAlpaca일부

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

[output] | SELECT * FROM Customers WHERE customerId LIKE 'C%' [instruction] | Write a query to retrieve all the customers whose customer ID starts with a "C". [input] |

[output] | def longest_palindrome_substring(s): n = len(s) if n == 0: return "" dp = [[False for _ in range(n)] for _ in range(n)] start = 0 max_length = 1 # All substrings of length 1 are palindrome for i in range(n): dp[i][i] = True # Check for substring of length 2. for i in range(n-1): if s[ [instruction] | Given a string s, write a Python function that returns the longest substring of the given string that is a palindrome. [input] | s = "abcbabcd"

[output] | print("Hello, I am your chatbot!") while True: user_input = input("What would you like to talk about?\n") if user_input == "bye": print("Bye! It was nice talking to you.") break if user_input == "weather": print("It is sunny outside!") else: print("I am sorry, I don't understand your [instruction] | Create a simple chatbot using Python. [input] |

[output] | def multiplication_table(num): for i in range(1, 11): print(num, '*', i, '=', num*i) # Driver code multiplication_table(5) [instruction] | Create a function to create a multiplication table for a given number. [input] | Number: 5

[output] | def is_balanced(s): stack = [] for letter in s: if letter in ["(", "[", "{"]: stack.append(letter) else: if len(stack) == 0: return False top = stack.pop(-1) if top == '(': if letter == ' [instruction] | Implement a function to check for balanced parentheses in a given string. [input] | String: (((())()))

[output] | def most_frequent_word(str): split_str = str.split() frequencies = {} for word in split_str: if word in frequencies: frequencies[word] += 1 else: frequencies[word] = 1 most_frequent_word = "" highest_freq = 0 for key, value i [instruction] | Write a code snippet to find the most frequent word in a given sentence. [input] | Sentence: The quick brown fox ate the lazy dog

[output] | def sum_of_multiples(num): sum = 0 for i in range(num): if i % 3 == 0: sum += i elif i % 5 == 0: sum += i return sum # Driver code sum = sum_of_multiples(15) print("Sum of multiples of 3 and 5 =",sum) [instruction] | Write a code to find the sum of the multiples of 3 and 5 up to a given number. [input] | Number: 15

[output] | def is_nearly_identical(str1, str2): edit_dist = 0 m = len(str1) n = len(str2) # Create matrix to store results of subproblems dp = [[0 for x in range(n + 1)] for x in range(m + 1)] for i in range(m + 1): for j in range(n + 1): if i == 0: [instruction] | Create a code to check whether two words are nearly identical. [input] | Word A: bte Word B: tree

[output] | list(range(2, 8)) # [2, 3, 4, 5, 6, 7] [instruction] | Convert the following range to list elements in Python. [input] | range(2, 8)

[output] | arr = [4, 15, 12, 3, 8] total = 0 for num in arr: total += num print(total / len(arr)) [instruction] | Complete the following code with a condition so it prints the average of the array elements. [input] | arr = [4, 15, 12, 3, 8] total = 0 for num in arr: # Your code here print(total / len(arr))

[output] | dlroW olleH [instruction] | Reverse the following string without using in-built functions in Python. [input] | Hello World

[output] | const findElement = (arr, test) => { for(let element of arr){ if(test(element)){ return element; } } }; [instruction] | Write a JavaScript function to find the first element of an array that passes a given test. [input] | const arr = [10, 20, 9, 5];

[output] | list = [1, 3, 7, 4, 2] def swap(list, i, j): # Swap the elements list[i], list[j] = list[j], list[i] [instruction] | Complete the following code so it swaps two given elements in the list. [input] | list = [1, 3, 7, 4, 2] def swap(list, i, j): # Your code here

[output] | function generateDates(startdate, enddate) { const dates=[], start=new Date(startdate), end=new Date(enddate); while (start <= end) { const newdate = new Date(start); const formatteddate = `${newdate.getDate()}/${newdate.getMonth()+1}/${newdate.getFullYea [instruction] | Generate a list of distinct dates between two given dates using JavaScript. [input] | startdate = "01/20/2020" enddate = "05/17/2020"

[output] | def is_algorithm_syntactically_correct(algorithm): algorithm = algorithm.replace('\n', ' ').replace('\t ', ' ').lower() required_words = ['read', 'input', 'initialize', 'variables', 'process', 'output', 'result'] for word in required_words: if word not in algorithm: [instruction] | Write a Python script to check for syntactic correctness of an algorithm. [input] | Algorithm = "1. Read input 2. Initialize variables 3. Process input 4. Output result"

[output] | SELECT name FROM Customers WHERE order_date < '17/2/2020'; [instruction] | Write an SQL query to find the name of all customers who have made orders before the given date. [input] | Table: Customers Fields: name, order_date Given_date = 17/2/2020

[output] | def reverse_string(s): # initialize an empty string reversed_string = "" # loop through the string and concatenate the characters in reverse order for i in range(len(s) - 1, -1, -1): reversed_string += s[i] return reversed_string print(reverse_string("apple")) # elppa [instruction] | Given a string s, reverse its characters and return the resulting string. [input] | s = "apple"

[output] | The apex of the programming language C++ is Object Oriented Programming. It is a style of programming that uses objects and their interactions to design applications and computer programs. Object-oriented programming allows for code re-use, modularity and easy debugging. This makes the language an e [instruction] | What is the apex of the programming language C++? [input] |

[output] | def remove_negatives_and_sort(numbers): # filter out negative numbers non_negatives = list(filter(lambda x: x >= 0, numbers)) # sort the non-negative numbers non_negatives.sort() return non_negatives print(remove_negatives_and_sort([-5, -1, 2, 0, 4, 5, 9])) # [0, 2, 4, 5, 9] [instruction] | Given a list of numbers, remove all negative numbers and sort the remaining numbers in ascending order. [input] | numbers = [-5, -1, 2, 0, 4, 5, 9]

[output] | def most_frequent_letter(s): # get the letter frequency letter_frequency = {} for ch in s: if ch in letter_frequency: letter_frequency[ch] += 1 else: letter_frequency[ch] = 1 # find the letter with the max frequency max_frequency = 0 m [instruction] | Write a function that takes a string and returns the letter which appears most frequently. [input] | s = "apple"

[output] | The most common integer in a list can be found using the collections.Counter module. The Counter class creates a dictionary with the elements in the list as keys and the number of occurrences as values. The most_common() method can then be used to find the element with the highest number of occurren [instruction] | How to find the most common integer in a list? [input] |

[output] | # get two integers from the user x = int(input("Enter value for x: ")) y = int(input("Enter value for y: ")) # swap tmp = x x = y y = tmp # print the swapped values print("x =", x, "and y =", y) [instruction] | Construct a program that takes integers x and y and swaps their values. [input] | x = 5 y = 10

[output] | Abstract classes in Java provide a way to define and enforce common behavior that is shared between derived classes. They also allow for code reuse as the shared code can be reused by other classes. Furthermore, with the help of abstract classes, one can create a structure for developers to follow a [instruction] | What are the benefits of abstract classes in Java? [input] |

[output] | <html> <head> <title>Login Page</title> </head> <body> <h1>Please enter your login details</h1> </body> </html> [instruction] | Codify a static HTML page such that when the page URL is accessed, it displays the message "Please enter your login details". [input] |

[output] | function jsonToQueryString(jsonObject) { let queryString = ''; for(let key in jsonObject) { queryString += key + '=' + jsonObject[key] + '&'; } return queryString.substring(0, queryString.length-1); } console.log(jsonToQueryString(obj)); // prints "name=John&age=25&job=devel [instruction] | Given a JSON object, code a JavaScript function to convert the object into a query string. [input] | let obj = { name: 'John', age: 25, job: 'developer' }

[output] | public static int countArrayElements(int[] input) { int count = 0; for (int element : input) { count++; } return count; } int arraySize = countArrayElements(array); // prints 4 [instruction] | Design a Java code to create a method that counts the number of elements in a given array. [input] | int[] array = {2, 4, 6, 8}

[output] | #Title { border: 1px solid black; } [instruction] | Write a CSS script to add a border to the 'Title' element on a webpage. [input] |

[output] | function keywordExists(arr, keyword){ return arr.includes(keyword); } console.log(keywordExists(arrWords, keyword)); // prints true [instruction] | Given an array of strings and a search keyword, code a JavaScript function to check if the keyword exists in the array. [input] | let arrWords = ["cat", "dog", "dog", "fish"] let keyword = 'dog'

[output] | def generateFibonacciSeries(num): series = [0, 1] for i in range(2, num): series.append(series[i - 2] + series[i - 1]) return series print(generateFibonacciSeries(num)) # prints [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] [instruction] | Using Python, write a code to generate the Fibonacci series up to the given number. [input] | num = 10

[output] | function getNumericElements(arr) { return arr.filter(item => typeof item === 'number'); } console.log(getNumericElements(arr)); // prints [1, 4] [instruction] | Write a Node.js script to filter numeric elements from an array. [input] | let arr = [1, 'two', 'three', 4, 'five']

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