← 목록

Synth · CodeAlpaca일부

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

[output] | for word in list_words: print(word) [instruction] | Generate the appropriate code for a for-loop that iterates through a list. [input] | list_words = ["Hello", "World", "GPT", "Model"]

[output] | <noinput> Output: This sentence is a great example of how powerful GPT-3 models are at generating meaningful sentences. [instruction] | Generate a sentence from a given sentence input, using a GPT-3 model. [input] | This is a sentence.

[output] | import re def check_digits(string): """ This function takes a string and checks if it contains any digit. """ regex_pattern = r"[0-9]" return bool(re.search(regex_pattern, string)) [instruction] | Given a string, write the appropriate regex pattern that checks if the string contains any digit. [input] |

[output] | def classify_sentiment(string): """ This function takes a string and classifies its sentiment as either positive or negative. """ if string.lower().find("positive") != -1 or string.lower().find("amazing") !=-1: return "positive" elif string.lower().find("negative [instruction] | Given a string, classify the sentiment of the text as either positive or negative. [input] | The GPT model is amazing.

[output] | def convert_array(array): """ This function takes a NumPy array and converts it to a list. """ return array.tolist() [instruction] | Convert this NumPy array to a list. [input] | import numpy as np my_array = np.array([[1,2,3], [4,5,6], [7,8,9]])

[output] | let appleCount = 0; for(let i = 0; i < fruits.length; i++) { if(fruits[i].type === "Apple") { appleCount += fruits[i].count; } } [instruction] | Write a loop to compute the total number of fruits of type "Apple". [input] | var fruits = [{ type: 'Mango', count: 10}, {type: 'Apple', count: 5}, {type: 'Strawberry', count: 8}]

[output] | Hello! This is a test. There are numbers here. [instruction] | Given a document, remove all numbers from the content. [input] | Hello! This is a test. There are 1, 2, 3 numbers here.

[output] | function isSameTree(p, q) { if (p === null && q === null) { return true; } if (p === null || q === null || p.val !== q.val) { return false; } return isSameTree(p.left, q.left) && isSameTree(p.right, q.right); } [instruction] | Implement a function to check if two binary trees are same or not. [input] |

[output] | def transposeMatrix(arr): let t_arr = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]; for i in range(len(arr)): for j in range(len(arr[0])): t_arr[j][i] = arr[i][j] return t_arr [instruction] | Create a function which takes a 3x3 2D array and returns its transpose. [input] | let arr = [[0, 1, 2], [3, 4, 5], [6, 7, 8]]

[output] | let sumArray = []; for (let i = 0; i < array1.length; i++) { sumArray.push(array1[i] + array2[i]); } console.log(sumArray); // Output: [4, 5, 4, 4, 8] [instruction] | Write a JavaScript program to calculate the sum of each individual index value from two given arrays of equal length. [input] | let array1 = [1, 0, 2, 3, 4]; let array2 = [3, 5, 2, 1, 4];

[output] | capitalized_words = [word.capitalize() for word in words] print(capitalized_words) # Output: ['The', 'Quick', 'Brown', 'Fox'] [instruction] | Given a list of strings, write a Python program to capitalize the first letter of each word. [input] | words = ['The', 'quick', 'brown', 'fox']

[output] | SELECT title FROM movies_table WHERE year = 2021 AND revenue > 20000000 [instruction] | Compose a query to find the titles of the movies released in 2021 which produce revenue more than $2,000,000. [input] | movies_table = 'movies'

[output] | SELECT customers.name, sum(sales.amount) as total_sales FROM customers INNER JOIN sales ON customers.customer_id = sales.customer_id WHERE MONTH(sales.date) = '04' AND YEAR(sales.date) = '2021' GROUP BY customers.name [instruction] | Write a MySQL query to select the name of the customer and the total sales made by each customer in a given month. [input] | customers_table = 'customers'; sales_table = 'sales'; month = '04'; year = '2021';

[output] | #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main(){ int array[10]; srand(time(0)); // Generating random numbers for (int i = 0; i < 10; i++) { array[i] = (rand() % 20) + 1; } // Printing the obtained random numb [instruction] | Create a C++ code to generate 10 random numbers between 1-20 and store them in an array. [input] |

[output] | library(ggplot2) df <- data.frame(Current=data1, Previous=data2) ggplot(df, aes(x=rownames(df))) + geom_col(aes(y=Current, fill="Current Month"), position=position_dodge(), width=0.5, color="black") + geom_col(aes(y=Previous, fill="Previous Month"), position=position_dodge(), width=0.5, color="bl [instruction] | Write an R script to generate a chart to compare the sales between the current month and the previous month. [input] | data1 = c(10,15,3,4,7,10,12) data2 = c(23,20,21,19,15,8,11)

[output] | SELECT COUNT(order_id) AS orders, DAY(date) AS `day` FROM orders_table WHERE MONTH(date) = '05' AND YEAR(date) = '2021' GROUP BY DAY(date); [instruction] | Create a SQL query for finding the number of orders made each day in a given month. [input] | orders_table = 'orders' month = '05' year = '2021'

[output] | import { FormGroup, FormControl, Validators } from '@angular/forms'; this.myForm = new FormGroup({ userName: new FormControl('', Validators.required), lastName: new FormControl('', Validators.required), email: new FormControl('', [Validators.required, Validators.email]) }); [instruction] | Write a Angular typescript code to validate the input form. [input] |

[output] | The Boolean value returned by == when two operands are equal is True. [instruction] | Which Boolean value is returned by == when two operands are equal? [input] |

[output] | There are two types of methods available in Python: instance methods and class methods. [instruction] | How many types of methods are available in Python? [input] |

[output] | sorted_lists = sorted(list1 + list2) print(sorted_lists) # Output: [2, 3, 4, 5, 7, 8, 9, 10] [instruction] | Compare two objects and sort them using the inbuilt sorting function. [input] | list1 = [7, 3, 5, 9] list2 = [4, 8, 2, 10]

[output] | The ternary operator can be used to conditionally assign a value. For example, the following code assigns max to the larger value of x and y: max = x if x > y else y [instruction] | Describe a use case of the ternary operator in Python. [input] |

[output] | matrix = [[1, 2], [3, 4], [5, 6]] [instruction] | Create a 3x2 matrix using nested lists. [input] |

[output] | The DataFrame can be converted to a list using the tolist() method. For example: import pandas as pd df = pd.DataFrame([[1, 2], [3, 4], [5, 6]]) my_list = df.tolist() print(my_list) # Output: [[1, 2], [3, 4], [5, 6]] [instruction] | How to convert a pandas DataFrame to a python list? [input] |

[output] | 4, 8, 12, 21, 53 [instruction] | Sort the following list of numbers in ascending order: 53, 8, 12, 4, 21. [input] | 53, 8, 12, 4, 21

[output] | def replace_e(mystring): return mystring.replace('e', '*') [instruction] | Create a function in Python that takes in a string as an argument and replaces all occurances of 'e' with an asterisk ('*'). [input] | mystring = 'hello world'

[output] | SELECT name, age FROM employees WHERE age > 33; [instruction] | Write a SQL statement to retrieve the name and age of all employees who are older than 33. [input] |

[output] | class UserInput: def __init__(self): self.data = None def get_data(self): self.data = input("Enter something: ") return self.data [instruction] | Design a class in Python that creates objects based on user input. [input] |

[output] | import java.lang.Math; public class QuadraticEquation { public static void main(String[] args) { double a = 1; double b = -2; double c = -8; double x1, x2; double discr = b * b - 4 * a * c; if (discr > 0) { x1 = ( - b + Math.sqrt(discr)) / (2 * a); x2 = [instruction] | Create a Java program for solving quadratic equations. [input] |

[output] | function get_date_difference($date1, $date2){ $date1_time = strtotime($date1); $date2_time = strtotime($date2); $difference = $date2_time - $date1_time; return $difference; } [instruction] | Create a PHP function that returns the difference between two dates. [input] | $date1 = '2020-10-29'; $date2 = '2021-02-02';

[output] | public static double computeAverage(int[] numbers){ int sum = 0; for(int i=0; i<numbers.length; i++){ sum += numbers[i]; } double average = (double)sum/numbers.length; return average; } [instruction] | Design a Java program for computing the average of a given list of numbers. [input] | [1, 2, 4, 5]

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