← 목록

Synth · CodeAlpaca일부

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

[output] | def print_message(message): print(message) print_message('Hello, World') [instruction] | Create a user-defined function that prints out a message when called. [input] | message = "Hello, World"

[output] | def fibonacci(limit) n1, n2 = 0, 1 puts "Fibonacci series upto #{limit}" while n1 <= limit print "#{n1}, " n1, n2 = n2, n1 + n2 end end fibonacci(20) [instruction] | Create a Ruby script to output the first 20 fibonacci numbers. [input] |

[output] | 3xy + 12x [instruction] | Reduce the following equation by applying the distributive property. [input] | 3x(y + 4)

[output] | 2646 [instruction] | Calculate the result of the following expression: 63 × 42 [input] |

[output] | p { font-size: 200%; color: red; font-family: 'Montserrat'; } [instruction] | Using CSS, apply the following style to a paragraph element. Make the font size 200%, the font color red, and the font family 'Montserrat'. [input] |

[output] | def only_vowels(str) str.gsub(/[^aeiou]/i, '') end [instruction] | Create a function using Ruby that takes in a string, and returns a new string that only consists of the vowels from the original string. [input] | "Testing123"

[output] | function intersect_arrays($arr1, $arr2) { return array_intersect($arr1, $arr2); } [instruction] | Write a function in PHP that takes in two arrays, and returns a new array that contains only elements present in both arrays. [input] | [1, 3, 4], [2, 4, 6]

[output] | import random import string def random_password_generator(): charsds = string.ascii_letters + string.digits password = ''.join(random.choice(charsds) for i in range(10)) return password print(random_password_generator()) [instruction] | Create a random password generator in Python that outputs 10 characters of random alphanumeric characters. [input] |

[output] | arr = [6,4,7,1,3] #Find max number def find_max(arr): max_num = arr[0] for num in arr: if num > max_num: max_num = num return max_num result = find_max(arr) print("The maximum number is:", result) [instruction] | Return the maximum number from a given array of integers. [input] | [6,4,7,1,3]

[output] | string = "12345" number = int(string) print(number) [instruction] | Write a code in Python to convert the following string to an integer. [input] | "12345"

[output] | string = "Hello World" count = 0 for char in string: if char.isupper(): count += 1 print("The number of uppercase characters are:", count) [instruction] | Write a Python code to count the number of uppercase characters in the given string. [input] | "Hello World"

[output] | Using Python's Standard Library function `difflib.SequenceMatcher` is a more efficient way to compare two strings. This function uses an algorithm to compute the longest common subsequence between the two strings which is then used to calculate the similarity score of the given strings. [instruction] | Suggest a better way to compare two strings in Python. [input] |

[output] | The third element of a list can be accessed using the index value 2, as Python indexing starts from 0. For example, if x is a list containing the elements [1, 2, 3], x[2] will return the third element of the list i.e. 3. [instruction] | How could we access the third element of a list in Python? [input] |

[output] | CREATE TABLE students ( name VARCHAR(50) NOT NULL, id INT NOT NULL, major VARCHAR(50) NOT NULL, age INT NOT NULL ); [instruction] | Write an SQL statement that creates a table named 'students' with four columns: "name", "id", "major" and "age". [input] |

[output] | #include <iostream> #include <array> bool areEqual (std::array<std::array<int,2>,2> first, std::array<std::array<int,2>,2> second ) { if( first.size() != second.size() ) return false; for(int i = 0; i < first.size(); i++) { for(int j = 0; j < first[i].size(); j++) [instruction] | Write a C++ program that takes two 2D arrays and compares them for equality. [input] | arr1 = [[1,2], [2,4]] arr2 = [[1,2], [2,4]]

[output] | function replaceVowels($string) { $vowels = array("a", "e", "i", "o", "u"); $string = str_replace($vowels, "x", $string); return $string; } [instruction] | Write a PHP function that takes a string and returns the same string with all vowels replaced with the letter 'x'. [input] |

[output] | SELECT * FROM customers WHERE age > 25; [instruction] | Write an SQL query to list all customers who are over the age of 25. [input] |

[output] | """ Print the number of days in a given month and year using C++ """ #include<iostream> int main() { int month, year; std::cout << "Enter month: "; std::cin >> month; std::cout << "Enter year: "; std::cin >> year; int numDays; if (month == 1 || month == 3 || month == [instruction] | Create a C++ program that prints out the number of days in a given month and year. [input] | Month: 10 Year: 2020

[output] | /** * Develop a function in Java that takes two integers as its arguments and prints out the maximum of the two. */ public class maximum { public static int maximum(int a, int b){ if(a > b){ return a; } else { return b; } } public static void main(Strin [instruction] | Develop a function in Java that takes two integers as its arguments and prints out the maximum of the two. [input] | A = 25 B = 27

[output] | """ Generate a best fit line for data points in Python """ import numpy as np data = [(2,4), (4,7), (6,8), (7, 11)] x = np.array([x[0] for x in data]) y = np.array([y[1] for y in data]) m, c = np.polyfit(x, y, 1) print("Best-fit line equation: y = {:.2f}x + {:.2f}".format(m,c)) [instruction] | Generate a best-fit line for data points {(2,4), (4,7), (6,8), (7,11)} in Python. [input] |

[output] | """ Develop an algorithm in Python that detects any outliers in an array """ #define function to detect outliers def detect_outliers(data): outliers = [] threshold = 3 mean = sum(data)/len(data) std = np.std(data) for i in data: z_score = (i - mean)/std if np.abs(z_score) > [instruction] | Develop an algorithm in Python that detects any outliers in an array. [input] | A = [1, 5, 2, 10, 8, 5, 9, 15]

[output] | """ Create a function in Node.js that prints out the numbers between 0 and a given limit. """ function printNumbers(limit){ for(let i = 0; i <= limit; i++) { console.log(i); } } printNumbers(10); [instruction] | Create a function in Node.js that prints out the numbers between 0 and a given limit. [input] | limit = 10

[output] | """ Design a module in JavaScript that allows a user to reverse a provided array """ //implement reverse function function reverseArray(array){ let start = 0; let end = array.length-1; while (start < end){ let temp = array[start]; array[start] = array[end]; array[end] = temp [instruction] | Design a module in JavaScript that allows a user to reverse a provided array. [input] | A = [1,2,3,4,5]

[output] | """ Develop an algorithm in JavaScript that determines whether a given year is a leap year or not """ function isLeapYear(year) { if (year % 4 === 0) { if (year % 100 === 0) { if (year % 400 === 0) { return true; } else { [instruction] | Develop an algorithm in JavaScript that determines whether a given year is a leap year or not. [input] | Year = 2100

[output] | """ Create a code in C# that takes an array of numbers and prints out the second smallest number in the array. """ public static void Main() { int[] A = { 9, 8, 12, 4, 7, 10 }; int secondMin = A[0]; if(A[1] < secondMin) { secondMin = A[1]; } for(int i = [instruction] | Create a code in C# that takes an array of numbers and prints out the second smallest number in the array. [input] | A = [9, 8, 12, 4, 7, 10]

[output] | """ Write a script in Python that takes a list of strings and prints out the first letter of each string in uppercase """ # create the function def uppercase_first_letters(list_of_strings): for string in list_of_strings: print(string[0].upper()) # call the function with the list A = ["a [instruction] | Write a script in Python that takes a list of strings and prints out the first letter of each string in uppercase. [input] | A = ["apple", "banana", "grapes"]

[output] | """ Design a module in JavaScript that sorts an array of integers starting from the smallest number. """ // Create the sorting function function sortArray(array){ // Keep track of the index of the minimum value. let index; //loop through the array starting from the beginning. for(let i = [instruction] | Design a module in JavaScript that sorts an array of integers starting from the smallest number. [input] | A = [9, 8, 12, 4, 7, 10]

[output] | """ Create a script in Java that builds a string based on a given character repeated n number of times. """ public class StringBuilder { public static String buildString(char c, int n){ StringBuilder sb = new StringBuilder(); for(int i = 0; i < n; i++){ sb.a [instruction] | Create a script in Java that builds a string based on a given character repeated n number of times. [input] | Character = '*' Number = 5

[output] | """ Develop a function in Python that takes two arguments, a base number and an exponent number, and prints out the result of the power operation. """ def power(base, exponent): result = base**exponent; return result; base = 5 exponent = 3 print(power(base, exponent)) [instruction] | Develop a function in Python that takes two arguments, a base number and an exponent number, and prints out the result of the power operation. [input] | Base = 5 Exponent = 3

[output] | def find_odd_even_frequencies(list_of_ints): count_odd = 0 count_even = 0 for num in list_of_ints: if num % 2 == 0: count_even += 1 else: count_odd += 1 return {"odd": count_odd, "even": count_even} result = find_odd_ev [instruction] | Write a code that takes a list of integers and output the frequencies of odd and even numbers within the list. [input] | list_of_ints = [7, 21, 22, 23, 24, 25]

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