← 목록

Synth · CodeAlpaca일부

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

[output] | Math.sqrt(961); //Output is: 31 [instruction] | Find the square root of 961 using JavaScript. [input] |

[output] | h1 { font-weight: bold; font-size: 24px; } [instruction] | Write a CSS code snippet to make the <h1> text bold with font size of 24px. [input] |

[output] | def dict_sum(nums): sum = 0 for key, val in nums.items(): sum +=val return sum print(dict_sum(dict)) //Output is: 18 [instruction] | Write a Python function to calculate the sum of all items in a given dictionary with integer values. [input] | dict = {'a': 5, 'b': 10, 'c': 3}

[output] | let dictionary = { "key1": "value1", "key2": "value2", "key3": "value3" }; [instruction] | Create a Dictionary object in JavaScript and add three key-value pairs. [input] |

[output] | arr.sort((a, b) => (a.age > b.age) ? 1 : -1 ); //Output is: [{name:"Jane", age:22}, {name:"Harry", age:25}, {name:"John", age:30}] [instruction] | Sort a JavaScript array of objects by a given property. [input] | arr = [ {name:"Harry", age:25}, {name:"John", age:30}, {name:"Jane", age:22} ]

[output] | for word in word_list: print(word) [instruction] | Construct a for-loop to iterate through a given list of strings and print each member one line at a time. [input] | word_list = ["hello", "world", "!"]

[output] | public class Student { int id; String name; Student(int id, String name) { this.id = id; this.name = name; } } [instruction] | Create a class in Java that stores a student's ID and name. [input] |

[output] | total=sum(arr) avg=sum(arr)/len(arr) print("Total of the array elements is: "+str(total)) print("Average of the array elements is: "+str(avg)) [instruction] | Write a Python script to calculate the total and the average of an array of numbers. [input] | arr = [56, 23, 89, 17, 13, 10]

[output] | function validateEmail(email) { var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; return re.test(email); } [instruction] | Create a Node.js function to validate an email with a given regex. [input] |

[output] | if element in arr: print("Element is present in array") [instruction] | Construct an if-statement to check whether the given element is present in an array or not. [input] | arr = [4, 5, 6] element = 5

[output] | def sort_dict_list(data): """Sort a list of dictionaries in ascending order of 'count' Args: data (list): A list of dictionaries Returns: list: A sorted list of dictionaries """ sorted_data = sorted(data, key=lambda x: x['count']) return sorted_data [instruction] | Create a Python function to sort a list of dictionaries in ascending order of "count". [input] | data = [ {'name': 'Alice', 'count': 5}, {'name': 'Bob', 'count': 3}, {'name': 'John', 'count': 7}, {'name': 'David', 'count': 4}, ]

[output] | #include <iostream> using namespace std; void Fibonacci(int n) { int f1 = 0, f2 = 1, i; if (n == 0) return; for (i = 1; i <= n; i++) { cout << f2 << " "; int next = f1 + f2; f1 = f2; f2 = next; } } int main() { [instruction] | Generate a C++ function to print the Fibonacci series [input] |

[output] | The result of performing arithmetic subtraction between two numbers, 5 and 2 is 3. Since subtraction is the inverse of addition, to get the difference between two numbers you subtract the number being subtracted from the number that is being subtracted from. Thus, 5 - 2 = 3. [instruction] | What is the result of performing arithmetic subtraction between two numbers, 5 and 2? [input] |

[output] | """Print the Hello World message using the Tkinter module in Python""" import tkinter as tk # Create the main window window = tk.Tk() # Create the label with the text hello_label = tk.Label(window, text="Hello World") # Pack the label to the window hello_label.pack() # Main loop window.mainloop( [instruction] | How can you print the Hello World message using the Tkinter module in Python? [input] |

[output] | import re sentence = "The dark night was quiet and still" pattern = r"\bT\w*e\b" # Find all the words that begin with a "t" and end with an "e" matches = re.findall(pattern, sentence) print(matches) # Output: ['The', 'night', 'quiet', 'still'] [instruction] | Use a regex expression to find all the words that begin with a "t" and end with an "e" in the following sentence. [input] | sentence = "The dark night was quiet and still"

[output] | """Using the Math object, calculate the sine of an angle""" angle = 45 sine = Math.sin(angle * Math.PI / 180); console.log(sine); # Output: 0.7071067811865476 [instruction] | Using the JavaScript Math object, calculate the sine of an angle. [input] | angle = 45

[output] | if age >= 18: print("You are an adult") else: print("You are a minor") [instruction] | Using the given variables, create an if-else statement that prints "You are an adult" when age is greater than or equal to 18, otherwise print "You are a minor". [input] | age = 18

[output] | if A > B: print("A is greater than B") [instruction] | Compare two values to check if the first one is greater than the second one, and if so, print "A is greater than B". [input] | A = 5 B = 3

[output] | def swap(my_list, index_1, index_2): # Store the two elements temp = my_list[index_1] my_list[index_1] = my_list[index_2] my_list[index_2] = temp [instruction] | Implement a function that swaps the places of two elements in a list. [input] | my_list = [1,2,3,4,5]

[output] | def create_dictionary(keys, values): # Create an empty dictionary my_dict = {} # Populate the dictionary with elements from lists for i in range(len(keys)): my_dict[keys[i]] = values[i] return my_dict [instruction] | Implement a function that creates a dictionary from two lists which contain the keys and values, respectively. [input] | keys = ["name", "age", "city"] values = ["John", 30, "New York"]

[output] | element = my_list[2] [instruction] | Access the third element from a list. [input] | my_list = [1,2,3,4,5]

[output] | CREATE TABLE products (id INTEGER, name VARCHAR(255), price DECIMAL); [instruction] | Construct a MySQL query to create a new table with 3 columns. [input] | tableName = ‘products’ columns = ['id', 'name', 'price']

[output] | SELECT * FROM [table_name] LIMIT 10; [instruction] | How would you limit the output of a SQL query to the first 10 rows? [input] |

[output] | public static void displaySquare(int num){ System.out.println(num*num); } [instruction] | In Java, how do you make a method that takes a number and displays its square? [input] |

[output] | //h2 [instruction] | Construct an XPath query to select all <h2> tags from a web page [input] |

[output] | import numpy as np import keras from keras.models import Sequential from keras.layers import Dense, Dropout, Conv2D, MaxPooling2D, Flatten # Define the model model = Sequential() model.add(Conv2D(filters=32, kernel_size=(3, 3), activation='relu', input_shape=(32, 32, 3))) model.add(MaxPooling2D(poo [instruction] | Write a neural network in Keras that can distinguish between a cat and a dog. [input] |

[output] | <div id="grid"></div> <script> $("#grid").kendoGrid({ dataSource: { sort: { field: "firstName", dir: "asc" }, pageSize: 10, serverPaging: true, serverFiltering: true }, columns: [ { field: "firstName", [instruction] | Create a Kendo-UI application to display an interactive grid with the following options: sorting, pagination, and search filter. [input] | <no-input>

[output] | class Person( var firstName: String, var lastName: String, var age: Int ) [instruction] | Create a class "Person" in Kotlin with first name, last name, and age as its fields. [input] |

[output] | filter_words_over_five_letters <- function(words_list) { filtered_words <- words_list[nchar(words_list) > 5] return(filtered_words) } [instruction] | Write a function in R to filter out the words containing more than 5 letters. [input] |

[output] | var a = 0, b = 1 for _ in 1...20 { let c = a + b a = b b = c print("\(c)") } [instruction] | Write code in Swift to print the Fibonacci Sequence to the first 20 numbers [input] |

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