← 목록

Synth · CodeAlpaca일부

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

[output] | sum = 0 for elem in list: sum += elem [instruction] | Update the following code to sum the elements in a given list [input] | list = [1,3,4,5]

[output] | for (let i = 0; i < arr.length; i++) { console.log(arr[i]); } [instruction] | Write a JavaScript code to loop over all elements in a given array. [input] | arr = [1,2,3]

[output] | SELECT COUNT(*) FROM Employees WHERE Department = 'Software Engineering'; [instruction] | Write a query in SQL to find the total number of people who currently work in the software engineering department. [input] |

[output] | function filter_short_words($words) { $filtered = array(); foreach($words as $word) { if (strlen($word) >= 3) { array_push($filtered, $word); } } return $filtered; } [instruction] | Create a function in PHP that takes an array of strings as an argument and returns an array containing only the strings with at least 3 characters. [input] | array = ['hi', 'hello', 'world']

[output] | def zip_lists(list1, list2): zipped_dict = {} for k, v in zip(list1, list2): zipped_dict[k] = v return zipped_dict print(zip_lists(list1, list2)) [instruction] | Create a function in Python that takes two lists as arguments and returns a dictionary with elements of the first list as keys and elements of the second list as values. [input] | list1 = ['a', 'b', 'c'] list2 = [1, 2, 3]

[output] | function replaceWithAt(str, num){ let replaceString = ''; let i = 0; while (i < num) { replaceString += '@'; i++; } return str.replace(str.substring(0, num), replaceString); } console.log(replaceWithAt(string, number)); [instruction] | Create a function in JavaScript that takes a string and a number as arguments, and returns a string with the first number of characters (specified by the number argument) replaced with the character '@'. [input] | string = 'Hello World' number = 4

[output] | def find_sum(lst): """Return the sum of a given list of numbers.""" res = 0 for x in lst: res += x return res # was missing, was iterating over list instead of lst. [instruction] | Inspect the given code and find any possible bugs. [input] | def find_sum(lst): """Return the sum of a given list of numbers.""" res = 0 for x in list: res += x return res

[output] | <ol> <li>9</li> <li>15</li> <li>3</li> <li>4</li> </ol> [instruction] | Write an HTML code to produce an ordered list with the following numbers: 9, 15, 3, 4. [input] |

[output] | def remove_duplicates(arr) arr.uniq end puts remove_duplicates([1, 2, 2, 3, 4, 4]) # should print [1, 2, 3, 4] [instruction] | Write a Ruby program to remove duplicate elements from the given array. [input] | arr = [1, 2, 2, 3, 4, 4]

[output] | # import the necessary libraries import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegression # preprocess the data df = pd.read_csv('data.csv') X = df.drop('target', axis=1) y = df['target'] X_train, X_test, y_train [instruction] | Create a machine learning model to predict a binary class. [input] |

[output] | DELETE FROM CITY WHERE CITY = 'Frankfurt'; [instruction] | Write a SQL query to delete a row from the "CITY" table where the city is "Frankfurt". [input] |

[output] | /^[a-zA-Z]+$/ [instruction] | Construct a regular expression to match strings containing only alphabets. [input] |

[output] | def calculate_circumference(radius): circumference = 2*3.14*radius return circumference [instruction] | Develop an algorithm to calculate the circumference of a circle provided the radius. [input] | radius = 5

[output] | var xhr = new XMLHttpRequest(); xhr.open('GET', 'https://example.com/ajax_call', true); xhr.send(); [instruction] | Edit the following JavaScript code to make an AJAX call to a specific URL. [input] |

[output] | public static int[] filterArrayByK(int[] arr, int k) { int i, j, index = 0; int[] filteredArray = new int[arr.length]; for (i = 0; i < arr.length; i++) { if (arr[i] <= k) { filteredArray[index] = arr[i]; index++; } } int[] result = new int[index]; for (j = 0; j < index; j [instruction] | Create a function in Java that filters a given array by a specific number. [input] | int[] arr = {4, 2, 10, 15, 8, 7}; int K = 9;

[output] | SELECT SUM(books) FROM authors; [instruction] | Write a query to find the sum of all authors' books in the database. [input] |

[output] | mylist = [1, 5, 9, 2, 6, 8] mylist.sort() print(mylist) [instruction] | Create a program in Python that sorts the following list and prints the sorted version of the list. [input] | mylist = [1, 5, 9, 2, 6, 8]

[output] | def square_number(number): return number*number [instruction] | Add code to this function to return the square of the input number. [input] | def square_number(number): 1

[output] | def compare_strings(string_1, string_2): if string_1 == string_2: return True else: return False [instruction] | Write a function to compare two strings. The function should return true if the strings are equal and false if the strings are not equal. [input] | string_1 = "Hello" string_2 = "World"

[output] | SELECT year, author, MAX(books) AS most_books FROM authors GROUP BY year; [instruction] | Write a query to find the author with the highest number of books in each year. [input] |

[output] | string = "This is an example" print(string.find("is")) [instruction] | Find the position of the substring "is" in the string. [input] | string = "This is an example"

[output] | num_1 = 10 num_2 = 15 print(num_1 * num_2) [instruction] | Create a program in Python that takes two numbers as input and prints the result of the multiplication of those numbers. [input] | num_1 = 10 num_2 = 15

[output] | DELETE FROM blog_posts; [instruction] | Construct an SQL statement that deletes all records from the "blog_posts" table. [input] |

[output] | def sortArray(arr): # loop to run for every element in the array for i in range(len(arr)): # loop to run for elements till the sorted part for j in range(0, len(arr)-i-1): # If a element is found to be greater than its next element then s [instruction] | Suppose you are given a array of 0s,1s and 2s . Write a program to sort the given input array. [input] |

[output] | def binaryToDecimal(binary): # to store decimal number decimal, i = 0, 0 while(binary != 0): dec = binary % 10 decimal = decimal + dec * pow(2, i) binary = binary//10 i = i + 1 return decimal [instruction] | Offer a solution for converting a bank of binary strings, represented as an array, to Decimal numbers. [input] |

[output] | <!DOCTYPE html> <html> <head> <title>Table example</title> </head> <body> <h1>Names and Usernames</h1> <table> <thead> <tr> <th>Name</th> <th>Username</th> </tr> </thead> <tbody> <tr> <td>Jenny</td> < [instruction] | Create an HTML page with a Table, which lists out the names and usernames of 4 people. [input] | Jenny, jenny123 John, john123 Alice, alice123 Bob, bob123

[output] | # A Backtracking program # in Python to solve Sudoku problem # A Utility Function to print the Grid def print_grid(arr): for i in range(9): for j in range(9): print(arr[i][j]), print ('n') # Function to Find the entry in the Grid that is still not us [instruction] | Design a program to solve a 3x3 Sudoku puzzle. [input] |

[output] | def add_period(phrase): if not isinstance(phrase, str): raise ValueError("phrase should be a String") return phrase + "." [instruction] | Create a function that takes a String and adds a period punctuation mark at the end. [input] | phrase = "I am having a good day"

[output] | total = 0 for i in range(11): total += i [instruction] | Update the code to sum the numbers from 0 to 10 and store the result in the 'total' variable. [input] | total = 0

[output] | total = number1 + number2 print("The total is", total) [instruction] | Construct a program to compute the sum of two numbers and display the result. [input] | number1 = 5 number2 = 10

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