← 목록

Synth · CodeAlpaca일부

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

[output] | for (int i = 0; i < 10; i++) { System.out.println(i); } [instruction] | Edit the following code to make the loop run for 10 iterations. [input] | for (int i = 0; i < 5; i++) { System.out.println(i); }

[output] | Matplotlib, Seaborn, Bokeh, Plotly, and Altair. [instruction] | Name five different Python libraries used for visualization. [input] |

[output] | public static void printSubstrings(String str) { for (int i = 0; i < str.length(); i++) { for (int j = i + 1; j <= str.length(); j++) { System.out.println(str.substring(i, j)); } } } [instruction] | Create a function in Java to print out all substrings of an input string. [input] |

[output] | A queue in Java is typically implemented using a linked list or an array. [instruction] | What kind of data structure is used for a queue in Java? [input] |

[output] | from sklearn.feature_extraction.text import CountVectorizer from sklearn.linear_model import LogisticRegression # Vectorize the message into a format that the model can accept vect = CountVectorizer().fit(X_train) X_train_vectorized = vect.transform(X_train) # Train a Logistic Regression model mod [instruction] | Create a text classification model using Scikit-learn to classify a message with either "positive" or "negative" sentiment. [input] |

[output] | SELECT * FROM student LIMIT 3; [instruction] | Write a MySQL query to select the first 3 rows of the student table. [input] |

[output] | SELECT gender, age, COUNT(*) FROM people WHERE age BETWEEN 20 AND 30 GROUP BY gender, age; [instruction] | Write an SQL query to select the gender, age and count of people from the people table for people aged 20-30. [input] |

[output] | def factor(x): factors = [] for i in range(1, x + 1): if x % i == 0: factors.append(i) return factors print(factor(64)) # Output: [1, 2, 4, 8, 16, 32, 64] [instruction] | Create a function that returns a list of all the factors of a given number. [input] | 64

[output] | def morse_encode(input_string): morse_encoder = { "A":".- ", "B":"-... ", "C":"-.-. ", "D":"-.. ", "E":" . ", "F":"..-. ", "G":"--. ", "H":".... ", "I":".. ", "J":".--- ", "K":"-.- ", "L":".-.. ", [instruction] | Write a code to convert a given string of English characters to corresponding Morse code. [input] | "Hello World!"

[output] | def is_anagram(a, b): a = a.lower() b = b.lower() if len(a) != len(b): return False for char in a: if char not in b: return False b = b.replace(char, '', 1) return True print(is_anagram("silent", "listen")) # Output: True [instruction] | Define a function to check whether string a is an anagram of string b. [input] | "silent" "listen"

[output] | def linear_search(arr, target): for i in range(len(arr)): if arr[i] == target: return i return None print(linear_search([4, 5, 2, 3], 2)) # Output: 2 [instruction] | Write a code for linear search algorithm. [input] | [4, 5, 2, 3] 2

[output] | def get_diff(list_a, list_b): diff = list_a for i in list_b: if i in list_a: diff.remove(i) return diff [instruction] | Compare two Python lists having integers and write a function to output the differences [input] | list_a = [1, 2, 3] list_b = [2, 3, 4]

[output] | def make_dict(list_a, list_b): dict = {} for a, b in zip(list_a, list_b): dict[a] = b return dict [instruction] | Generate a dictionary out of two lists by matching each element in the two lists [input] | list_a =[2, 3, 4] list_b = ["a", "b", "c"]

[output] | def mirror_tree(root): if root is None: return # Do the postorder traversal to traverse down to leaf nodes mirror_tree(root.left) mirror_tree(root.right) # Swap the pointers in this node root.left, root.right = root.right, root.left [instruction] | Write a Python code to convert a binary tree to its mirror tree [input] |

[output] | def knight_moves(x, y): result = [] # Move 1 on x-axis, 2 on the y-axis result.append((x + 1, y + 2)) # Move 2 on x-axis, 1 on the y-axis result.append((x + 2, y + 1)) # Move 1 on x-axis, -2 on the y-axis result.append((x + 1, y - 2)) # Move -2 on x-axis, 1 o [instruction] | Find all the possible moves of a knight in a chessboard [input] |

[output] | class CountryCapitalPopulation{ HashMap<String, Integer> countryCapPop; public CountryCapitalPopulation(){ countryCapPop = new HashMap<String, Integer>(); } public void addCountryCapitalPopulation(String country, String capital, int population){ countryCapPo [instruction] | Design a data structure that can efficiently store the capitals of different countries and their respective populations. [input] |

[output] | SELECT * FROM employees WHERE date_of_birth > '1984-01-01'; [instruction] | Compose an SQL query to identify which employees were born after January 1, 1984. [input] |

[output] | <!DOCTYPE html> <html> <head> <title>Hello World!</title> </head> <body> <div class="box">Hello World!</div> </body> </html> [instruction] | Develop a HTML5 program to display a box with the text "Hello World!" [input] |

[output] | function get_freq_words($str, $n) { $arr = explode(" ", $str); $freq = array_count_values($arr); arsort($freq); return array_slice(array_keys($freq), 0, $n); } [instruction] | Create a robust Helper Function in PHP that returns an array containing the N most frequent words in a string [input] | Input String: "The quick brown fox jumps over the lazy dog" N: 3

[output] | def sum_digits(input_number): sum_of_digits = 0 while input_number > 0: last_digit = input_number % 10 sum_of_digits += last_digit input_number //= 10 return sum_of_digits sum_digits(354) [instruction] | Develop a Python script to sum up all the individual digits of a given number [input] | 354

[output] | const fetch = require('node-fetch'); const csv = require('csvtojson'); async function callAPIAndConverttoCSV(url) { try { const response = await fetch(url); const jsonData = await response.json(); const csvData = await csv().fromString(jsonData); return csvData; } catch (err) { throw er [instruction] | Design a NodeJS script to call a remote API and convert the response to a csv object. [input] |

[output] | <nav style="overflow-y: scroll; max-height: 200px;"> <a href="#">Link 1</a> <a href="#">Link 2</a> <a href="#">Link 3</a> <a href="#">Link 4</a> </nav> [instruction] | For the following HTML code, how could you style the `nav` element to make it scrollable? [input] | <nav> <a href="#">Link 1</a> <a href="#">Link 2</a> <a href="#">Link 3</a> <a href="#">Link 4</a> </nav>

[output] | SELECT * FROM registrations WHERE registration_date IN (SELECT MAX(registration_date) FROM registrations GROUP BY user_id); [instruction] | Write a SQL query to select the latest registration record for each user. [input] |

[output] | Python has a built-in zipfile module which provides support for reading and writing zip archives in native Python code. The module provides a ZipFile object with methods to read and extract contents of the archive, as well as a class representing individual entries such as files and directories. Fo [instruction] | How could you read a specific compression format such as .zip in Python? [input] |

[output] | # Load the data df = read.csv("data.csv") # Find the correlation correlation = cor(df$column1, df$column2) print(correlation) [instruction] | Write an R script to find correlation between two columns in a given Data Frame. [input] |

[output] | <input type="number" value={value} onChange={handleChange} /> [instruction] | Edit the following React component to make the text input to accept only number values. [input] | <input type="text" value={value} onChange={handleChange} />

[output] | import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; @Injectable({ providedIn: 'root' }) export class AuthService { constructor(private http: HttpClient) { } authenticateUser(username: string, password: string) { const body = { username: username, p [instruction] | Create an Angular service to authenticate a user using an API endpoint. [input] |

[output] | def avg(nums): sum = 0 for num in nums: sum += num return sum/len(nums) [instruction] | Find the average of five numbers. [input] | 11, 15, 20, 7, 19

[output] | def reverse_words(words): reversed_words = [] for word in words: reversed_words.append(word[::-1]) return reversed_words [instruction] | Given a list of strings, reverse the order of each string in the list. [input] | ["hello", "world", "this", "is", "amazing"]

[output] | import random def generate_password(): uppercase_characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' numbers = '0123456789' password = '' for i in range(5): password += random.choice(uppercase_characters) password += random.choice(numbers) password += random.choice(list( [instruction] | Generate a random 10 character password with at least one uppercase letter and one number. [input] |

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