← 목록

Synth · CodeAlpaca일부

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

[output] | const request = require('request'); // Print the output of the api request('https://example.com/api', { json: true }, (err, res, body) => { if (err) { return console.log(err); } console.log(body.output); }); [instruction] | Write a Node.js code to call an API and print the output. [input] |

[output] | def search(arr, given_str): for item in arr: if item == given_str: return True return False [instruction] | Design a program to search for a given string within an array of strings. [input] | arr = ['hello', 'world', 'how', 'are', 'you'] given_str = 'how'

[output] | def remove_element(arr, remove_element): new_arr = [] for item in arr: if item != remove_element: new_arr.append(item) return new_arr [instruction] | Write a function to remove a given element from an array of integers. [input] | arr = [2, 3, 4, 5, 6] remove_element = 4

[output] | Cosine similarity is a measure of similarity between two non-zero vectors of an inner product space that measures the cosine of the angle between them. It is a normalized measure of similarity, ranging from -1 (completely different) to 1 (exactly similar). The cosine similarity is given by the dot p [instruction] | What is the cosine similarity between two vectors? [input] |

[output] | def group_by_length(arr, k): n = len(arr) groups = [arr[i:i+k] for i in range(0, n, k)] return groups a = [1,2,3,4,5,6,7,8] k = 3 print(group_by_length(a, k)) [instruction] | Write Python code to group list elements into sublists of particular length. [input] | [1,2,3,4,5,6,7,8]

[output] | function pyramid(n) { for (let i = 0; i < n; i++) { let str = ''; for (let j = 0; j < n-i; j++) { str = str + ' '; } for (let k = 0; k <= i; k++ ) { str = str + '* '; } console.log(str); } } pyramid(7); [instruction] | Write a JavaScript code to print the pyramid pattern for a given number of rows. [input] | 7

[output] | let str = "Hello world!"; let changedStr = str.replace("Hello", "Bye"); console.log(changedStr); // Bye world! [instruction] | Create a program in JavaScript to edit the existing string by replacing some of its character. [input] | string = "Hello world!" replacement = "Bye world!"

[output] | ALGORITHM LinearSearch(arr, value) SET i = 0 WHILE i < arr.length IF arr[i] == value RETURN i ELSE SET i = i + 1 RETURN -1 [instruction] | Draft a pseudo-code to implement a linear search algorithm in an array. [input] |

[output] | sudo iptables -A OUTPUT -s 123.123.123.123 -j DROP [instruction] | Write an outbound rule in Firewall to block traffic from a certain IP address. [input] | IP address: 123.123.123.123

[output] | The angle between side a and b is 53.13°. [instruction] | Determine the angle of the triangle given its three sides. [input] | a = 5, b = 6, c = 7

[output] | def Evaluate(model): metrics = model.evaluate() return metrics [instruction] | Create a function that returns the evaluation metric of a model. [input] |

[output] | SELECT * FROM users; [instruction] | Retrieve data from an SQL database. [input] | Table name: users

[output] | Hella there [instruction] | Replace all occurrences of one character with another in a given string. [input] | string: Hello there characters: 'o' and 'a'

[output] | decimal = 109 octal = format(decimal, 'o') print("Decimal:", decimal) print("Octal:", octal) [instruction] | Convert a number from decimal to octal in Python. [input] | number = 109

[output] | var randNumber = Math.floor(Math.random() * 25) + 1; [instruction] | Write a JavaScript expression to generate a random integer between 1 and 25. [input] |

[output] | SELECT * FROM orders WHERE order_date = '2020-01-01'; [instruction] | Write a SQL query to extract all the orders placed on a given date. [input] | order_date = "2020-01-01"

[output] | function concatenate(str1, str2){ return str1 + str2; } console.log(concatenate(param1,param2)); // "helloworld" [instruction] | Write a function in JavaScript that takes 2 parameters of type string and concatenates them. [input] | param1 = "hello" param2 = "world"

[output] | def divisible_by_three(numbers): res = [num for num in numbers if num % 3 == 0] return res [instruction] | Create a list comprehension that finds all elements that are divisible by 3 in a given list. [input] | numbers =[1, 5, 8, 10, 15, 20]

[output] | number = input("Please input a number: ") if type(number) == int: print("Input is an integer") else: print("Input is a decimal") [instruction] | Modify the code so that it checks if the number input is an integer or a decimal. [input] | number = input("Please input a number: ")

[output] | def create_tuple(a, b): return (a, b) [instruction] | Create a function that creates a tuple of the given arguments and returns the tuple. [input] | a="A" b="B"

[output] | for i in range(30, -1, -1): print(i) [instruction] | Create a loop that prints out the numbers from 30 to 0, going in reverse. [input] |

[output] | class Employee: def __init__(self, ID, name, age): self.ID = ID self.name = name self.age = age def get_info(self): return (self.ID, self.name, self.age) [instruction] | Define a class named 'Employee' that stores the ID, name, and age of a person. [input] |

[output] | def is_anagram(string1, string2): if sorted(string1) == sorted(string2): return True else: return False if __name__ == '__main__': string1 = "abcde" string2 = "edcba" result = is_anagram(string1, string2) print(result) [instruction] | Write a function that takes two strings as parameters and returns whether they are an anagram of each other or not. [input] | string1 = "abcde" string2 = "edcba"

[output] | def filter(numbers): return [n for n in numbers if n > 10 and n % 2 == 0] numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [instruction] | Modify the following function to only take numbers greater than 10. [input] | def filter(numbers): return [n for n in numbers if n % 2 == 0] numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

[output] | def is_positive(num): if num > 0: return True else: return False if __name__ == '__main__': num = 5 result = is_positive(num) print(result) [instruction] | Write a function that takes a numerical parameter and returns True if it is positive and False if it is negative. [input] |

[output] | import random def generate_random_number(): return random.randint(1, 10) [instruction] | Edit the following code to make it generate a random number between 1 and 10. [input] | import random def generate_random_number(): return random.randint(0, 11)

[output] | def count_words_with_letter_a(arr): count = 0 for s in arr: if 'a' in s: count += 1 return count if __name__ == '__main__': words = ['foo', 'bar', 'baz'] count = count_words_with_letter_a(words) print(count) [instruction] | Write a function that takes a list of strings and counts the number of each string that contains the letter "a". [input] | ['foo', 'bar', 'baz']

[output] | def reverse_list(nums): return nums[::-1] if __name__ == '__main__': numbers = [1, 2, 3, 4] reversed_list = reverse_list(numbers) print(reversed_list) [instruction] | Reverse the following list of numbers. [input] | [1, 2, 3, 4]

[output] | <html> <head> <style> .container { width: 300px; height: 200px; background-color: blue; } .text { color: white; font-family: Arial; font-size: 16px; padding: 15px; text-align: center; } </style> </head> <body> <div class="container"> <div class="text">Hello Worl [instruction] | Build a HTML page using the given CSS class [input] | CSS Classes: .container { width: 300px; height: 200px; background-color: blue; } .text { color: white; font-family: Arial; font-size: 16px; padding: 15px; text-align: center; }

[output] | SELECT SUM(Price) FROM Orders; [instruction] | Construct a SQL query to identify the sum contained in the column "Price" from the table "Orders". [input] | Table: Orders Column: Price

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