← 목록

Synth · CodeAlpaca일부

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

[output] | import random # Generate a list of 10 numbers nums = [i for i in range(10)] # Shuffle the list random.shuffle(nums) # Print the shuffled list print(nums) # [5, 0, 2, 3, 9, 8, 4, 1, 7, 6] [instruction] | Create a list in Python of elements 0-9 in random order. [input] |

[output] | class Book: def __init__(self, title, num_pages): self.title = title self.num_pages = num_pages self.pages_read = 0 def read(self, num_pages): self.pages_read += num_pages # Create an instance book = Book("War and Peace", 1220) # Read some pages book.re [instruction] | Design a data structure to store books that keeps track of page numbers. [input] |

[output] | sentence = "This sentence has an incorrect structure." [instruction] | Edit a given sentence to make its sentence structure correct. [input] | sentence = "This is wrong sentence structure"

[output] | import math def log10(x): return math.log10(x) if __name__ == '__main__': print(log10(10)) [instruction] | Create a function to calculate log base 10 in Python. [input] |

[output] | #Calculate the number of valid permutations of length n with respect to a given set of n distinct elements. def num_permutations(n): if n == 0: return 0 else: return math.factorial(n) if __name__ == '__main__': print(num_permutations(5)) [instruction] | Calculate the number of valid permutations of length n with respect to a given set of n distinct elements. [input] | n=5

[output] | const product = arr => arr.reduce((finalProduct, num) => finalProduct * num); console.log(product([5,4,2])); [instruction] | Calculate the total product of all numbers in an array in JavaScript. [input] | [5, 4, 2]

[output] | SELECT FirstName, Age FROM TableName WHERE YEAR(Birthday) = YEAR(NOW()) [instruction] | Create an SQL query to find the First Name and Age of all people with the same Year of Birth. [input] | noinput

[output] | def generateParenthesis(N): string = "" result = [] # dfs on the result def generate(left, right, string): if (left == 0 and right == 0): result.append(string) return if left > 0: generate(left - 1, right, string + "(" [instruction] | Write an algorithm to print all possible combinations of balanced parentheses. [input] |

[output] | public class FindIndex { public static int findIndex(int[] arr, int n) { int i; for (i = 0; i < arr.length; i++) { if (arr[i] == n) break; } if (i < arr.length) return i; else return -1; } } [instruction] | Given an array of numbers, find the index of the first occurrence of a given number in Java. [input] |

[output] | #include <iostream> using namespace std; int main(int argc, char* argv[]) { cout << argv[1]; return 0; } [instruction] | Create a C++ program that uses command line arguments to print out the argument passed in as a string. [input] |

[output] | let numbers = [1,2,3,4,5,6,7,8,9,10]; [instruction] | Create an array of the first 10 natural numbers in JavaScript. [input] |

[output] | import pandas as pd data = { "name": "John", "age": 30, "city": "New York" } df = pd.DataFrame([data]) [instruction] | Given a JSON object, write a Python program to convert it into a Pandas dataframe. [input] | { "name": "John", "age": 30, "city": "New York" }

[output] | SELECT name FROM table WHERE name LIKE 'A%'; [instruction] | Create a SQL query to print names starting with a certain letter. [input] | Letter: A

[output] | 55 [instruction] | Find the sum of the sequence of numbers from 1 to 10. [input] |

[output] | ls /home/test/*/ [instruction] | Write a Bash command to list all the subdirectories of a given directory. [input] | Path: /home/test

[output] | An infinite loop is created by writing a loop that always evaluates to true, causing it to repeat indefinitely. This can be done by writing the loop with no condition, or a condition that can never be false. For example, a loop with the condition “i < 10” will run infinitely if it increments i by 1 [instruction] | How is an "infinite loop" created? [input] |

[output] | int[][] array 2D = new int[n][m]; //where n is the number of rows and m is the number of columns. //You can also create a 2D array by initializing elements with curly brackets, for example int[][] array2D = {{1,2,3},{4,5,6}}; [instruction] | How is a 2D array declared and initialized in Java? [input] |

[output] | Branching is the ability to create a separate line of development within a version control system. This allows developers to have multiple versions of the same project, each with its own unique changes. Branches are used to isolate different features or bug fixes in different versions, without affec [instruction] | What is "branching" in version control systems? [input] |

[output] | list_of_tuples.sort(key=lambda tup: tup[1]) [instruction] | Write code to sort a Python list of tuples based on their second element in the tuple. [input] | list_of_tuples = [('a', 5), ('b', 1), ('c', 10)]

[output] | SELECT department, MAX(salary) FROM Salary GROUP BY department; [instruction] | Create a SQL query to select the maximum salary for each department from the "Salary" table. [input] |

[output] | SELECT name, age FROM Employees WHERE age > 25; [instruction] | Construct a SQL query to select the names and ages of employees in the "Employees" table where the age is greater than 25. [input] |

[output] | #include<stdio.h> #include<string.h> void reverse(char *str) { int i = strlen(str) - 1, j = 0; while (i > j) { char temp = str[i]; str[i] = str[j]; str[j] = temp; i--; j++; } } void reverseSentence(char *str) { reverse(str) [instruction] | Modify the above C program to reverse a sentence. [input] |

[output] | <!DOCTYPE html> <html> <body> <select name="color"> <option value="green">Green</option> <option value="blue">Blue</option> <option value="red">Red</option> </select> </body> </html> [instruction] | Create a HTML page with a drop-down menu with values “green”, “blue” and “red”. [input] |

[output] | def remove_duplicates(list): unique = [] for item in list: if item not in unique: unique.append(item) return unique list_a = [1, 2, 2, 3, 4, 4] list_a = remove_duplicates(list_a) print(list_a) [instruction] | Create a program in Python to remove duplicate values from a list. [input] | list_a = [1, 2, 2, 3, 4, 4]

[output] | Polymorphism in programming is a principle allowing the same code to be used for objects of different types, or for a given object to behave differently in different contexts. Polymorphism is an essential element of object-oriented programming, as it allows for code reusability, among other benefits [instruction] | What is the definition of polymorphism in programming? [input] |

[output] | def time_in_seconds(time_string): hour, minutes, seconds = map(int, time_string.split(':')) return second + minutes * 60 + hour * 3600 time_in_seconds(time_string) # 4290 [instruction] | Create a Python function that takes in a time string in the format hh:mm:ss and returns the time in seconds. [input] | time_string = '01:10:30'

[output] | <div class="container">Hello</div> [instruction] | Using the given HTML, add the class "container" to the <div> element. [input] | <div>Hello</div>

[output] | <div id="myDiv">Hello</div> [instruction] | Using the following HTML, add an id attribute to the <div> element. [input] | <div>Hello</div>

[output] | #include <iostream> int main() { int n = 20; int a = 0, b = 1, c; std::cout << a << " " << b << " "; for (int i = 2; i < n; ++i) { c = a + b; std::cout << c << " "; a = b; b = c; } return 0; } [instruction] | Write a C++ program to generate Fibonacci numbers up to a maximum of n values. [input] | n = 20

[output] | <p>Hello World</p> [instruction] | Given the following HTML, change the text to "Hello World". [input] | <p>Hi there</p>

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