← 목록

Synth · CodeAlpaca일부

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

[output] | function sumOfInt(arr) { var sum = 0; for (var i = 0; i < arr.length; i++) { if (arr[i] > 5) { sum += arr[i]; } } return sum; } sumOfInt(myList); // Returns 13 [instruction] | Write a script to iterate over all elements in a list, and sum up all integers greater than 5. [input] | var myList = [3, 7, 5, 6, 1]

[output] | let zipCodeRegEx = /^\d{5}$/; [instruction] | Create a regex that validates a numeric zip code with 5 digits. [input] |

[output] | class StringList { constructor(arr) { this.list = arr; } filterA() { return this.list.filter(val => !val.includes('a')) } } [instruction] | Implement a class which stores a list of strings and provides a method to filter out the items containing an 'a' character. [input] |

[output] | function packChars(str) { var arr = []; for (var i = 0; i < 8; i++) { arr.push(str[i] || " "); } return arr; } packChars(myString); // Returns ["a", "b", "c", "d", "e", "f", "g", "h"] [instruction] | Pack a string of characters into an array of length 8 [input] | var myString = "abcdefgh"

[output] | \d{4} [instruction] | Create a regex pattern to match any 4-digit integer. [input] |

[output] | if (string1 == string2) cout << "Strings are equal"; else cout << "Strings are not equal"; [instruction] | Compare the given strings to check if they are equal. [input] | string1 = "hello world" string2 = "hello world"

[output] | The first occurrence of substring "data" can be found at position 0 in the given string. [instruction] | Find the first occurrence of substring "data" in the given string. [input] | String: "Data Science is a field of study"

[output] | CREATE OR REPLACE PROCEDURE count_employees AS BEGIN SELECT COUNT(*) FROM Employees; END; [instruction] | Write a procedure in PL/SQL to count the number of employees in a company. [input] |

[output] | def search_for_element(array, element): """Search array for element and return index position.""" for i in range (0, len(array)): #loop through array if array[i] == element: #check if element is equal to the value in the array return i #return index position return [instruction] | Create a function that searches for elements in an array and returns the index position of the element. [input] | array = [3, 7, 11, 14, 19] element = 11

[output] | function sum_(start, end) { let sum = 0; // iterate over the range and add the elements // to the 'sum' variable for (let i = start; i <= end; i++) { sum += i; } return sum; } [instruction] | Modify the JavaScript code given below to return the sum of all numbers from 0 to 10 (inclusive). [input] | function sum_(start, end) { // TODO return 0; }

[output] | def replace_string(main_string, searching_substring, replacement_string): """Replace all occurrences of the searching substring in the main string with the replacement string.""" # replace all occurrences of the searching substring with the replacement string replaced_string = main_ [instruction] | Create a function that takes in three parameters, a main string, searching substring, and a replacement string, and returns the main string with all occurrences of the searching substring replaced by the replacement string. [input] | main_string = "Helllllllllllo World" searching_substring = "lllllllll" replacement_string = "y"

[output] | def check_divisible(value): """Check if value is divisible by 3 and 5.""" # check if value is divisible by 3 and 5 if value % 3 == 0 and value % 5 == 0: return True else: return False [instruction] | Make a script that checks if a given integer value is divisible by 3 and 5 both. [input] | value = 10

[output] | def get_complement(dna_string): """Get complement of given DNA string""" # create a dictionary with complementary keys and values dna_complement = {'A':'T', 'T':'A', 'C':'G', 'G':'C'} # create an output variable output_str = "" # iterate over each char in the dna string an [instruction] | Create a function that returns the complement of a given DNA string (A → T, C → G). [input] | dna_string = "ATCGACG"

[output] | def factorial_(num): """Find the factorial of a given number""" # initialize the value of factorial factorial = 1 # multiply the number with the numbers # below its value to get the factorial for i in range(1, num+1): factorial *= i return factorial [instruction] | Modify the given code to find the factorial of a specified number. [input] | def factorial_(num): """Find the factorial of a given number""" # TODO return 1

[output] | def search_word(main_word, searching_word): """Check if the searching word is present in the main word.""" # iterate over the main word, and check if # any substring is equal to the searching word for i in range(0, len(main_word)): if main_word[i:(i + len(searching_word))] [instruction] | Create a function that takes in two parameters―a main word and a searching word―and checks if the searching word is present in the main word. [input] | main_word = "Hello" searching_word = "el"

[output] | name.length == 5 [instruction] | Describe a boolean condition that checks whether a name is 5 letters long. [input] |

[output] | def cosine_distance(a, b): numerator = 0 sum_a_sq = 0 sum_b_sq = 0 for (x, y) in zip(a, b): numerator += x*y sum_a_sq += x**2 sum_b_sq += y**2 denominator = (sum_a_sq * sum_b_sq)**.5 return numerator/denominator cosine_distance(vector1, vector2) [instruction] | Write a Python function that calculates the cosine distance between two vectors. [input] | vector1 = [1, 2, 3] vector2 = [4, 5, 6]

[output] | SELECT email FROM customers WHERE email LIKE '%.net'; [instruction] | Write an SQL query to retrieve customer emails ending in .net [input] |

[output] | p{ font-weight: bold; color: red; } [instruction] | Write a CSS style to make all paragraphs in a page bold and red. [input] |

[output] | def quadratic_equation(a,b,c): discriminant = pow(b,2)-4*a*c if(discriminant < 0): return "No real solutions" elif(discriminant == 0): return (-b + pow(discriminant, 0.5))/(2*a) else: return ((-b + pow(discriminant, 0.5))/(2*a), (-b - pow(discriminant, 0.5))/(2*a)) [instruction] | Create a function that evaluates the quadratic equation. [input] |

[output] | typeof value == 'number' && isFinite(value) [instruction] | Create a boolean condition to check if the value is a real number. [input] |

[output] | <button>Submit</button> [instruction] | Write a ReactJS code to render a button element with the text "Submit". [input] |

[output] | const languages = { 'Java': 'Object-oriented, high-level language', 'Python': 'Interpreted, scripted, high-level language', 'C++': 'Object-oriented, compiled, low-level language', 'JavaScript': 'Interpreted, scripted, high-level language', 'C': 'Compiled, low-level language' }; [instruction] | Create an object of key-value pairs that contains 5 programming languages. [input] |

[output] | while counter < max_count: counter += 1 [instruction] | Create a while loop using the given conditions. [input] | counter = 0 max_count = 5

[output] | def add_lists(list1, list2): res = [] for i in range(0, len(list1)): res.append(list1[i] + list2[i]) return res [instruction] | Make a function that adds two lists of numbers together element-wise. [input] | list1 = [1, 2, 3] list2 = [4, 5, 6]

[output] | public static int sum(int number1, int number2) { return number1 + number2; } [instruction] | Write a Java method using the given parameters. [input] | methodName: sum parameters: int number1, int number2

[output] | def longest(words): max_len = 0 for i in range(0, len(words)): if (len(words[i]) > max_len): max_len = len(words[i]) longest = words[i] return longest [instruction] | Using the given input, output the longest word in the array. [input] | words = ["water", "grand", "piano", "mountain"]

[output] | for char in text: print(char) [instruction] | Write a loop to iterate over a string and print each character on a new line. [input] | text = "Hello world!"

[output] | def is_angry(sentence): angry_phrases = ["angry", "enraged", "aggrieved", "ineluctably", "ireful", "lusty", "tedious", "vexed", "irked", "wrath"] words_in_sentence = sentence.lower().split(" ") for phrase in angry_phrases: if phrase in words_in_sentence: [instruction] | Implement a text classifier for recognizing phrases that are indicative of anger in a sentence. [input] | He threw the ball so hard, his anger couldn't be concealed.

[output] | import string import random def randomPassword(): password_characters = string.ascii_letters + string.digits + '!@#$%^&*()' password = random.choice(string.ascii_lowercase) #Include atleast one lowercase password += random.choice(string.ascii_uppercase) #Include atleast one upperc [instruction] | Generate a random password consisting of alphanumeric characters and special characters. [input] |

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