← 목록

Synth · CodeAlpaca일부

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

[output] | public int minValue(int a, int b) { if (a < b) { return a; } else { return b; } } [instruction] | Generate a function in Java to calculate the minimum of two values [input] |

[output] | let john = { name: "John", age: 24 }; [instruction] | Store the following information in a JavaScript object [input] | Name: John, Age: 24

[output] | class ArraySum: def __init__(self, arr): self.arr = arr def sum(self): total = 0 for i in self.arr: total += i return total [instruction] | Write a Python class to print the sum of an array elements [input] |

[output] | first_half = string[0:len(string)//2] # "This is an" [instruction] | Extract the first half of a given string. [input] | string = "This is an example of string"

[output] | last_three_primes = [97, 89, 83] [instruction] | Create an array containing the last three prime numbers. [input] |

[output] | def isLeapYear(year): if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0: return True else: return False [instruction] | Write a function to identify leap year. [input] |

[output] | javac Sample.java [instruction] | Compile a given Java program. [input] | A java program containing the following lines class Sample { public static void main(String args[]) { System.out.println("Hello World"); } }

[output] | pattern = re.compile(r"\w+able\b") [instruction] | Create a regular expression pattern to find all words ending with "able". [input] |

[output] | int count = arr.Count(x => x == 5); [instruction] | Create a LINQ query to count the number of elements with a specific value. [input] | List<int> arr = [1, 2, 3, 4, 5, 5];

[output] | double sphereVolume(double radius) { return (4.0/3.0) * 3.14159 * radius * radius * radius; } [instruction] | Define a C++ function to calculate the volume of a sphere. [input] |

[output] | ^a.* [instruction] | Design a regular expression to match strings that begin with the letter "a". [input] |

[output] | x = [i for i in x if i % 2 == 0] [instruction] | Rewrite the following code to delete the elements from the list which are not even. [input] | x = [1, 2, 3, 4, 5]

[output] | SELECT * FROM Employees ORDER BY salary DESC LIMIT 1; [instruction] | Write a query in SQL to retrieve the records that have the highest salary. [input] |

[output] | { "name": "John Doe", "age": 24, "occupation": "Software Engineer" } [instruction] | Construct a JSON object which contains the elements "name", "age", and "occupation". [input] |

[output] | <form> <label for="name_field">Name:</label> <input type="text" id="name_field" name="name"/> <br /> <label for="email_field">Email:</label> <input type="text" id="email_field" name="email"/> <br /> <input type="submit" value="Submit"/> </form> [instruction] | Construct an HTML form with input elements for name and email. [input] |

[output] | new_list = list1+list2 [instruction] | Given a two lists, combine the contents of both lists into a new list. [input] | list1 = [1, 2, 3, 4] list2 = [5, 6, 7, 8]

[output] | name = "John" [instruction] | Create a variable to store your name. [input] |

[output] | import json python_dict = json.loads(json_string) [instruction] | Convert a given JSON string to its Python dictionary equivalent. [input] | json_string = '{"name":"John","age":30}'

[output] | for num in numbers: print(num**2) [instruction] | Write a for loop to iterate through a list of integers and print out the square of each value. [input] | numbers = [1, 2, 3, 4]

[output] | index = my_list.index(element) [instruction] | Find the index of the first occurence of the given element in a list. [input] | my_list = [2, 5, 6, 8, 10] element = 8

[output] | Immutability in Python refers to the concept of objects that are unable to be modified. Immutable objects are specified when they are created and cannot be changed beyond that point. For example, tuples and strings are always immutable. [instruction] | What do we mean by immutability in Python? [input] |

[output] | stripped_string = my_string.strip() [instruction] | Strip the white spaces from a given string. [input] | my_string = " Hello World "

[output] | my_array = ["John", 25, True] [instruction] | Create an array with 3 elements of your choice. [input] |

[output] | def extract_verbs(sentence): verbs = [] words = sentence.split(" ") for w in words: if w.endswith("ed") or w.endswith("ing"): verbs.append(w) return verbs [instruction] | Parse the sentence and extract all the verbs from it. [input] | Sentence: "She ran quickly to catch the bus."

[output] | from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegression X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0) logreg = LogisticRegression(random_state=0).fit(X_train, y_train) [instruction] | Train a Machine Learning model using scikit-learn that can solve a binary classification problem. [input] | Dataset - number of samples 1000, number of features 5, target label - binary

[output] | class Student: def __init__(self, name, age): self.name = name self.age = age [instruction] | Create a class named Student. Give it two fields - name and age. [input] |

[output] | def find_adjacent(arr): max_sum = -1 for i in range(len(arr)-1): if arr[i] + arr[i+1] > max_sum: max_sum = arr[i] + arr[i+1] return max_sum [instruction] | Find the two adjacent elements in the array with the largest sum. [input] | Array: [3, 6, 8, -10, 5]

[output] | def create_dict(text): text_list = text.split(' ') count_dict = {} for word in text_list: count_dict[word] = count_dict.get(word, 0) + 1 return count_dict [instruction] | Generate a dictionary that contains all the words in a string of text, and the number of times each word occurs. [input] | Text: "I like dogs and cats and I like cats more than dogs"

[output] | persons = [ {'name': 'Alice', 'age': 24, 'city': 'Boston'}, {'name': 'Bob', 'age': 32, 'city': 'New York'}, {'name': 'Chris', 'age': 28, 'city': 'San Francisco'}, ] [instruction] | Create a list of dictionaries, with each dictionary containing a person's name, age, and city. [input] | Name1: Alice; Age1: 24; City1: Boston Name2: Bob; Age2: 32; City2: New York Name3: Chris; Age3: 28; City3: San Francisco

[output] | I worked at the library. [instruction] | Edit the sentence to make it grammatically correct. [input] | Sentence: "I work at the library did."

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