← 목록

Synth · CodeAlpaca일부

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

[output] | def distance(c1, c2): """Function to calculate Euclidean distance between two sets of coordinates""" x1, y1 = c1 x2, y2 = c2 return math.sqrt((x2 - x1)**2 + (y2 - y1)**2) [instruction] | Create a function "distance" that takes two sets of coordinates in the form of [x1, y1] and [x2, y2] and computes the Euclidean distance between them. [input] |

[output] | characters = ['0'..'9', 'A'..'Z', 'a'..'z'].map { |range| range.to_a }.flatten random_string = (0...9).map { characters[rand(characters.length)] }.join puts random_string [instruction] | Create a Ruby program to generate a random 9-digit alphanumeric string. [input] |

[output] | <form action="" method="post"> <input type="text" name="field1" /> <input type="text" name="field2" /> <input type="text" name="field3" /> <input type="submit" name="submit1" value="Submit" /> <input type="submit" name="submit2" value="Cancel" /> </form> [instruction] | Using HTML, create a form with 3 text input fields and 2 buttons. [input] |

[output] | body { background-color: #FFFFFF; } [instruction] | Add CSS styling to the <body> element so that the background color of a webpage is white. [input] |

[output] | <!DOCTYPE html> <html> <head> <title>Example website</title> </head> <body> <h1>My example website</h1> <p>This is some example text</p> </body> </html> [instruction] | Rewrite this HTML code so that it is valid HTML5. [input] | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Example website</title> </head> <body> <h1>My example website</h1> <p>This is some example text</p> </body> </html>

[output] | def getGrade(score): if score >= 90: return "A" elif score >= 80: return "B" elif score >= 70: return "C" elif score >= 60: return "D" else: return "F" [instruction] | Create a function "getGrade" to get a grade based on a numeric score. [input] |

[output] | .divStyle { width: 50%; height: 75px; background-color: blue; } [instruction] | Create a CSS class to make a <div> element have a width of 50%, a height of 75px, and a blue background color. [input] |

[output] | def authentication(role): if role == 'admin': return 'Admin privileges granted.' elif role == 'manager': return 'Manager privileges granted.' elif role == 'employee': return 'Employee privileges granted.' else: return 'Login failed. Invalid role.' [instruction] | You need to build an API endpoint to support role-based authentication. [input] | User roles: 'admin', 'manager', 'employee'

[output] | del array[2] [instruction] | You need to modify an array to delete the third element of the array. [input] | array = [1, 2, 3, 4, 5]

[output] | print("Hello world") [instruction] | You need to complete the following code snippet to display 'hello world' on the console. [input] |

[output] | response = { "user_name": user_name, "user_age": user_age } [instruction] | Construct a JSON response object to return the given data in a key-value format. [input] | user_name = "John Doe" user_age = 20

[output] | new_dict = {**dic1, **dic2} [instruction] | Write code to merge two data dictionaries into one new dictionary. [input] | dic1 = {"a":1, "b":2} dic2 = {"c":3, "d":4}

[output] | def parse(string): words = set() for word in string.split(" "): words.add(word) return words [instruction] | Write a function to parse a string and return a set of unique words. [input] | string = "Hello world this is a test string"

[output] | total = 0 while True: num = input("Please enter a number (enter '0' to finish): ") if num == '0': break total += int(num) print("The total sum of numbers is:", total) [instruction] | You need to collect user input to get the total sum of numbers. [input] |

[output] | def dfs(root, value): if root is None: return False if root.val == value: return True left = dfs(root.left, value) right = dfs(root.right, value) return left or right [instruction] | You need to implement a depth-first search algorithm to search for a value in a given tree. [input] |

[output] | sorted_array = sorted(array, reverse=True) [instruction] | You need to sort the given array in descending order. [input] | array = [23, 16, 11, 45, 32]

[output] | import tensorflow as tf from tensorflow.keras.datasets import mnist (x_train, y_train), (x_test, y_test) = mnist.load_data() # Reshape and normalize the data x_train = x_train.reshape((60000, 28, 28, 1)) x_train = x_train / 255.0 x_test = x_test.reshape((10000, 28, 28, 1)) x_test = x_test / 255.0 [instruction] | Use a neural network to classify handwritten digits from the MNIST dataset. [input] |

[output] | def rearrange_array(arr): arr.sort() return arr [instruction] | Generate code to rearrange a given array of integers. [input] | [2, 4, 6, 8]

[output] | a { color: red; } [instruction] | Write a basic CSS style to apply color red to all links. [input] |

[output] | import unittest def reverse_strings_list(lst): return lst[::-1] class TestReverseStrings(unittest.TestCase): def test_reverse_strings_list(self): self.assertEqual(reverse_strings_list(["one","two","three"]), ["three", "two", "one"]) [instruction] | Create a unit test for a given function to reverse a list of strings. [input] |

[output] | a + b = 15 [instruction] | Compute the sum of 2 numbers using Python code. [input] | a = 10 b = 5

[output] | * ** *** [instruction] | Print a right angled triangle with stars. [input] |

[output] | def check_equal(x, y) { if (x == (y * -1)) { return true; } else { return false; } } [instruction] | You need to make a function that takes in a number and its reverse and checks whether the two numbers are equal or not. [input] | x = 65 y = 56

[output] | public class DebugBug { public static void main(String[] args) { int x = 10; print(x); } public static void print(int x) { System.out.println(x); } } [instruction] | Debug the given Java program to make it print out the value of x. [input] | public class DebugBug { public static void main(String[] args) { int x = 10; print(x); } public static void print(int x) { } }

[output] | string1 + string2 = "helloworld" [instruction] | Combine the two given strings into one string in the given order. [input] | string1 = "hello" string2 = "world"

[output] | A linked list is a linear data structure where each node is connected to the next node by a pointer. [instruction] | Explain what a linked list data structure is in one sentence. [input] |

[output] | public class Rectangle { // length and width parameters private double length; private double width; //Empty constructor public Rectangle(){ } //Initialized constructor public Rectangle(double length, double width) { this.length = length; [instruction] | Create a Java class called 'Rectangle' that has two properties: length and width. [input] |

[output] | This code takes a list as an argument and iterates through it using a for loop. For each element in the list, the code multiplies it to 2 and assigns it back (replacing the existing element) in the same list. At the end, every element in the list is doubled in value. [instruction] | Look at the code and explain what is it doing. [input] | def double_list(list): """Doubles every value in the list.""" for idx, item in enumerate(list): list[idx] = item * 2

[output] | function reverseString(str) { return str.split("").reverse().join(""); } [instruction] | Write a JavaScript function that will take a string and returns the reverse of that string [input] |

[output] | The first 20 prime numbers are: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71. [instruction] | Output the first 20 prime numbers [input] |

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