← 목록

Synth · CodeAlpaca일부

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

[output] | $fib = array(0, 1); for ($i = 2; $i < 10; $i++) { $fib[$i] = $fib[$i-1] + $fib[$i-2]; } print_r($fib); // [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] [instruction] | Generate the fibonacci sequence for the first 10 numbers using PHP. [input] |

[output] | for (int i=0; i < 3; i++) { Console.WriteLine("Hello, World!"); } [instruction] | Write a C# script to print the string "Hello, World!" three times [input] |

[output] | my_array = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) [instruction] | Create a Numpy array with 3 columns and 4 rows and assign it to the variable "my_array". [input] |

[output] | for x in range(1,11): result = x * x print(result, "*") [instruction] | Construct a for loop that prints the square of each number from 1 to 10 and also prints an asterisk after each square. [input] |

[output] | my_list = [0, 1, 2, 3, 4, 5] [instruction] | Create a list in Python called "my_list" and populate it with five integers ranging from 0 to 5. [input] |

[output] | public class PrimeNumbers { public static void main(String[] args) { System.out.println("Prime numbers between 2 and 1000 are:"); int count; for(int i=2; i<=1000; i++){ count=0; for(int j=2; j<i; j++){ if(i%j==0){ count++; break; } [instruction] | Create a new Java program that prints out all the prime numbers between 2 and 1000. [input] |

[output] | SELECT * FROM Customers WHERE City = 'New York'; [instruction] | Make a SQL statement to select all the customers from the "Customers" table where the customer's city is 'New York'. [input] |

[output] | my_list = [1, 2, 3, 4, 5 ] doubled_list = [] for item in my_list: doubled_list.append(item * 2) [instruction] | Construct a for loop that multiplies each item in a given list of numbers by two and stores the value into a new list. [input] |

[output] | def power(base, exponent): result = 1 for _ in range(exponent): result *= base return result [instruction] | Given an integer 'base' and an integer 'exponent', write a function to calculate the result of 'base' raised to the power of 'exponent'. [input] | base: 2 exponent: 3

[output] | let employeeDetails = { name: "John Smith", age: 26, contactNumber: "123-456-7890" }; [instruction] | Write a JavaScript Object that contains employee data such as name, age and contact number. [input] |

[output] | import time t = time.localtime() if t.tm_hour >= 17: print("Good Evening!") else: print("Good Morning!") [instruction] | Construct an if-else statement to print "Good Evening" if the time is past 5pm and print "Good Morning" otherwise. [input] |

[output] | True [instruction] | Compare two array and output the result in Boolean. [input] | arr1 = [1, 2, 3, 4] arr2 = [4, 3, 2, 1]

[output] | class Stream: def __init__(self): self.stream = [None, None, None, None, None] # This function adds a number to the start (index 0) of the stream and then shifts the other elements to the right def add(self, num): for i in reversed(range(1, len(self.stream))): [instruction] | Create a data structure for a streaming interface that holds a maximum of 5 numbers. [input] |

[output] | def reverse_string(s): # Initialize empty string rev_string = "" # Traverse over each letter in the string in reverse order for letter in s[::-1]: # Append the current letter to the end of rev_string rev_string = rev_string + letter # Return the reversed string [instruction] | Construct an algorithm for reversing a string. [input] |

[output] | CREATE TABLE StudentInformation ( Name VARCHAR (50) NOT NULL, Age INT NOT NULL, Year INT NOT NULL, GPA DECIMAL (3, 2) NOT NULL ); [instruction] | Create a database table for student information with the following attributes: Name, Age, Year, and GPA. [input] |

[output] | def dfs(graph, start, end): # create a visited array visited = [False] * len(graph) # create a stack stack = [] # mark the starting node as visited and push it in the stack stack.append(start) while stack: # get the current node node = stack.pop() [instruction] | Develop a DFS algorithm in Python. [input] |

[output] | import random def randomString(n): # Choose a character set charSet = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" # Generate a string of length n myString = "" for i in range(n): myString += random.choice(charSet) return myString [instruction] | Write an algorithm to generate a random string of length n. [input] | 8

[output] | print_dataframe<- function(data){ print(data) } [instruction] | Write an R function to print the contents of a dataframe. [input] |

[output] | SELECT AVG(age) FROM students WHERE course_id = 101; [instruction] | Generate a query to find the average age of students enrolled in a course with given course ID. [input] | course_id = 101

[output] | struct Node{ int data; struct Node *next; }; // Function to print the elements of the linked list void printList(struct Node *node) { while (node != NULL) { printf("%d ", node->data); node = node->next; } } [instruction] | Develop a code in C for printing the elements of a linked list. [input] |

[output] | def factorial(num): if num <= 1: return 1 else: return num * factorial(num-1) num = int(input('Enter number to find factorial: ')) factorial = factorial(num) print('Factorial of', num, 'is', factorial) [instruction] | Develop a program to accept one number from the user and display its factorial using a Python function. [input] | 5

[output] | function rgbToHex(arr) { let hex = '#'; for (let i = 0; i < 3; i++) { let val = arr[i]; if (val < 16) { hex += '0'; } hex += val.toString(16); } return hex; } [instruction] | Create a function in JavaScript to convert RGB values to HEX values. [input] |

[output] | The maximum number of elements that can be stored in an array in C++ is determined by the size of the array's data type, usually the maximum number of elements is 2^32-1 (4,294,967,295). [instruction] | What is the maximum number of elements that can be stored in an array in C++? [input] |

[output] | def filter_negative_numbers(nums): # return only positive numbers return [num for num in nums if num >= 0] print(filter_negative_numbers([2, 3, -1, 4, -5, 6])) [instruction] | Develop a function in Python to filter out all negative numbers in a given list. [input] | [2, 3, -1, 4, -5, 6]

[output] | angular.module("app").factory("register", function($http) { return { registerUser: function(userData) { return $http.post("/api/register", { userData: userData }); } }; }); [instruction] | Implement a function in AngularJS to register a new user. [input] |

[output] | The best way to sort an array in C# is to use the Array.Sort() method, which implements the Quicksort algorithm. This algorithm is efficient and typically uses O(n log n) complexity. [instruction] | What is the best way to sort an array in C#? [input] |

[output] | function longestItem(arr) { // Initializing the longest item to the first item in the array for comparison let longest = arr[0]; for (let item of arr) { // Comparing the length of each item to the longest if (item.length > longest.length) { longest = item; [instruction] | Write a function in JavaScript that returns the longest item in the array. [input] | ["a", "ab", "abc", "abcd"]

[output] | #include <iostream> using namespace std; // Function to calculate average double getAverage(int nums[], int n) { int sum = 0; for (int i = 0; i < n; i++) { sum += nums[i]; } double average = double(sum) / n; return average; } int main() { int nums[1 [instruction] | How would you create a program in C++ to calculate the average of 10 numbers? [input] |

[output] | def print_table(n): for i in range(1, 11): table = n * i print(f"{n} X {i} = {table}") [instruction] | Create a python function that takes a single integer as an argument and prints out the corresponding multiplication table. [input] |

[output] | SELECT * FROM Students WHERE Age > 25; [instruction] | Create an SQL statement to select the records of students whose age is greater than 25. [input] |

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