← 목록

Synth · CodeAlpaca일부

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

[output] | def commonElements(list1, list2): list1_set = set(list1) list2_set = set(list2) common_elements = list1_set.intersection(list2_set) return common_elements [instruction] | Create a Python program for identifying the common elements between two lists. [input] | list1 = [1, 2, 3, 4] list2 = [2, 4, 6, 8]

[output] | function getHypotenuse(a,b){ return Math.sqrt(a*a + b*b); } [instruction] | Design a JavaScript function for calculating the hypotenuse of a right triangle. [input] | a = 6; b = 8;

[output] | public class Point { private int x; private int y; public Point(int x, int y) { this.x = x; this.y = y; } public int getX() { return x; } public int getY() { return y; } } [instruction] | Create a Java class to represent a point (x, y) in a two-dimensional space. [input] |

[output] | <button onclick="window.location.href='http://example.com'">Click Here</button> [instruction] | Edit the following HTML code to redirect the user to example.com on click. [input] | <button>Click Here</button>

[output] | let user = { name: "John Doe", email: "john@example.com", age: 32 }; [instruction] | Create a JavaScript object to store user data. The data includes name, email, and age. [input] |

[output] | Strings: "Hello World!" Integers: 15 Floats: 3.14 Dictionaries: {"name": "John", "age": 32} Lists: [1, 2, 3, 4, 5] Tuples: ("Apple", "Banana", "Orange") Sets: {1, 2, 4, 8, 16} [instruction] | Provide an example for each of the following data types. [input] |

[output] | (402) 904-6151 [instruction] | Create a random phone number. [input] |

[output] | 0b00001101 [instruction] | Convert the given integer to 8-bit binary. [input] | 13

[output] | [5, 4, 3, 2, 1] [instruction] | Return the given array with all elements reversed. [input] | [1, 2, 3, 4, 5]

[output] | ["x", "y", "a", "b", "c", "d"] [instruction] | Insert two new elements at the beginning of a list. [input] | ["a", "b", "c", "d"]

[output] | 0b00110010 [instruction] | Print out the 8-bit binary representation of the given number. [input] | 50

[output] | 2 [instruction] | Subtract the second number from the first. [input] | 8, 6

[output] | let parser = new DOMParser(); let div = parser.parseFromString('<div><span>Hello World</span></div>', 'text/html'); let domTree = div.querySelector("div"); [instruction] | Convert the following HTML string to a DOM tree using JavaScript. [input] | <div><span>Hello World</span></div>

[output] | The C++ standard library does not have a function named 'to_string', so this code will not compile. To convert a floating-point number to a string, you should use std::stof() instead. [instruction] | Explain why the following C++ code would not compile. [input] | string result = to_string(3.14);

[output] | let button = document.getElementById("button"); button.classList.toggle("button--highlighted"); [instruction] | Generate a JavaScript code snippet to toggle a given CSS class on an element with a given ID. [input] | element_id: "button", class_name: "button--highlighted"

[output] | print("Hello World!") [instruction] | Suggest a code segment to render a greeting message in a terminal window using Python. [input] |

[output] | my_function(my_var) [instruction] | Suppose a functiona and a variable are already defined. Write a code statement to assign the value of the variable to the function. [input] | function: my_function variable: my_var

[output] | One approach to debug the function would be to use console.log statements to print out the values of the variables inside the function. This would help identify where the problem is and what needs to be changed in order to get the expected result. [instruction] | Suggest an approach to debug a function written in Javascript that is not returning the expected result. [input] |

[output] | class Point { public: Point(int x, int y) : x_(x), y_(y) {} int getX() const { return x_; } int getY() const { return y_; } int getSum() const { return x_+ y_; } private: int x_, y_; } int main() { Point p(3, 4); cout << p.getSum() << endl; return 0; } [instruction] | Rewrite the following C++ code using object-oriented programming principles. [input] | int x = 3, y = 4; cout << x + y << endl;

[output] | import random random_int = random.randint(0, 100) [instruction] | Suggest a code segment to generate a random integer in the range of 0 to 100 using Python. [input] |

[output] | The import statement should be placed at the beginning of the program, before any other statements are executed. This ensures that the Pandas library is available when we write code referring to the Pandas library. [instruction] | Where would you place the import statement when using the pandas library in Python? [input] |

[output] | array.sort((a, b) => a - b); [instruction] | Write a code statement to sort an array in ascending order using JavaScript. [input] | array = [3, 1, 5, 2, 4]

[output] | sudo apt-get update foo [instruction] | Suggest a command to check for any available updates for a package called 'foo' using the package manager 'apt'? [input] |

[output] | ^.*\s(.*?)\s.*$ [instruction] | Construct a regular expression to match and extract street names from a given address. [input] |

[output] | function printAsciiArt(text) { const characters = text.split(''); let outputString = ''; characters.forEach(char => { switch (char.toLowerCase()) { case 'f': outputString +=` [instruction] | Write a Nodejs function to print out the ASCII art for a given (input) text. [input] | Foo

[output] | words_counts = { "The": 1, "quick": 1, "brown": 1, "fox": 1, "jumped": 1, "over": 1, "the": 1, "lazy": 1, "dog.": 1 } [instruction] | Create a dictionary that has each unique word as the key, and the number of times the word appears as the value. [input] | The quick brown fox jumped over the lazy dog.

[output] | word = "apple" for letter in word: print(letter) [instruction] | Transform this code fragment to use the appropriate data structure. [input] | word = "apple" for i in range(len(word)): print(word[i])

[output] | def col_sum(arr): col_sum_arr = [] for j in range(len(arr[0])): s = 0 for i in range(len(arr)): s += arr[i][j] col_sum_arr.append(s) return col_sum_arr print(col_sum([[1, 2, 3], [4, 5, 6], [7, 8, 9]])) # Output: [12, 15, [instruction] | Write a Python program that can accept an array and returns the column-wise sum of the given array. [input] | [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

[output] | list1 = [] for i in range(6): list1.append(i**2) print(list1) # Output: [0, 1, 4, 9, 16, 25] [instruction] | Uses a loop to create a list with the squares of the numbers from 0 to 5. [input] |

[output] | class ComplexNumber: def __init__(self, real, imaginary): self.real = real self.imaginary = imaginary def __str__(self): if self.imaginary == 0: result = "%.2f+0.00i" % (self.real) elif self.real == 0: if self.imaginary >= 0: [instruction] | Create a class to create a Complex Number with real and imaginary parts. [input] |

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