← 목록

Synth · CodeAlpaca일부

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

[output] | def functional_programming(lst): return list(map(lambda x : x*2, filter(lambda x : x % 2 == 0, lst))) print(functional_programming([1,2,3,4,5])) # Output: [4, 8] [instruction] | Create a functional programming paradigm in Python. [input] |

[output] | function findMax(arr) { let max = arr[0]; // Loop through array elements // and compare with max for (let i = 1; i < arr.length; i++) if (arr[i] > max) max = arr[i]; // return max element return max; } // let arr = [4,7,2,1,0,6,5] // conso [instruction] | Design an algorithm in JavaScript to find maximum element within an array. [input] | [4,7,2,1,0,6,5]

[output] | Data structures used to implement a stack data structure are as follows - linked lists, arrays, dynamic arrays, and resizable arrays. Linked lists are used when the stack size needs to change frequently as this ensures that space is not wasted. Whereas, for a fixed stack size, arrays can be used. A [instruction] | Describe the data structures used to implement a stack data structure. [input] |

[output] | The network should include a server to send data, and a client to receive data. The server should have a dedicated IP address and listening port to receive instructions from the client, such as HTTP requests. The client should have a unique IP address, and should connect to the server to request dat [instruction] | Design a network for sending data from a server to a client. [input] |

[output] | // Create and open a connection string connString = "Data Source=localhost;Database=A;User ID=ads;Password=adspassword;"; SqlConnection conn = new SqlConnection(connString); conn.Open(); // Create a SQL command string Sql = "SELECT * FROM Customer"; // Execute a basic SQL query SqlCommand command [instruction] | Execute a basic SQL query using C#. [input] |

[output] | In Linux, permission levels are used to control access to various files and directories. The permission levels are represented by a triplet of numbers set for user (owner), group, and others. An effective way of applying these permission levels is to first assign an appropriate permission level (i.e [instruction] | Explain the concept of permission levels in Linux. [input] |

[output] | HTML (Hyper Text Markup Language) is the standard markup language for structuring content for the web. It includes features such as support for images, multimedia (audio, video, animations), tables, forms, lists, direct linking of multimedia content and external documents. HTML also supports the int [instruction] | Describe the features of HTML. [input] |

[output] | list = [1, 2, 3, 4, 5] for x in list: print(x) [instruction] | In Python, write a script that prints out the elements of a list. [input] | list = [1, 2, 3, 4, 5]

[output] | <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul> [instruction] | Write a line of HTML code to set a bulleted list. [input] |

[output] | int array[5][5]; [instruction] | Write a line of C code to declare a 2D array of size 5x5. [input] |

[output] | SELECT name, id FROM customers WHERE state = 'California'; [instruction] | Write a SQL statement to select the names and IDs of customers from the customers table that live in California. [input] |

[output] | #include <stdio.h> int main() { printf("Hello World!"); return 0; } [instruction] | Can you make some changes so that the following C code compiles correctly? [input] | #include <stdio.h> int main() { printf("Hello World!") return 0 }

[output] | <?php $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "myDB"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // sql to [instruction] | Write a PHP script that creates a MySQL database table with three fields: "ID", "name", and "age". [input] |

[output] | def generate_sum_array(s): res = [int(s[0])] for i in range(1, len(s)): res.append(int(s[i-1]) + int(s[i])) res.append(int(s[-1])) return res # Output: [3, 8, 11, 13] [instruction] | Given a string of integers, create a method to generate an array in which each integer is added to the sum of its neighbors. [input] | s = "3456"

[output] | def sort_by_price(arr): arr.sort(key=lambda item: item['price']) return arr # Output: [{'name': 'Mouse', 'price': 50}, {'name': 'Monitor', 'price': 500}, {'name': 'Laptop', 'price': 1200}] [instruction] | Given an array of objects, write a function that sorts the array in ascending order of its "price" property. [input] | [ {'name': 'Laptop', 'price': 1200}, {'name': 'Monitor', 'price': 500}, {'name': 'Mouse', 'price': 50} ]

[output] | SELECT COUNT(*) FROM users [instruction] | Create a SQL query that counts the number of users in a given table. [input] | Table name: users

[output] | def delete_empty_elements(arr): return [e for e in arr if e] # Output: ["a", "b", "c"] [instruction] | Create a method that deletes all the empty elements from a given array of strings. [input] | arr = ["a", "", "b", "", "c"]

[output] | def convert_matrix_to_array(matrix): res = [] for row in matrix: for element in row: res.append(element) return res # Output: [1,2,3,4,5,6] [instruction] | Write an algorithm to convert a given 2D matrix into a 1D array. [input] | matrix = [[1,2,3],[4,5,6]]

[output] | #!/bin/bash for proc in $(ps aux | awk '{ print $2 }') do ps axo pid,ppid,args | egrep -i "^[[:space:]]*$proc" done [instruction] | Write a bash script to print all processes currently running on the system. [input] |

[output] | SELECT country, COUNT(*) AS NumCustomers FROM customers GROUP BY country; [instruction] | Write a SQL query to count the number of customers in each country in the 'customers' table. [input] |

[output] | // Define a polygon class public class Polygon { // An array of Points to represent the vertices of a polygon private Point[] vertices; // A constructor that takes an array of Points public Polygon(Point[] vertices) { this.vertices = vertices; } // A method that returns the area [instruction] | Create a class that implements a polygon using an array of Point objects. [input] |

[output] | <html> <head> <title>HTML Document</title> </head> </html> [instruction] | Edit this HTML code to only display the title. [input] | <html> <head> <title>HTML Document</title> </head> <body> <h1>Hello World!</h1> </body> </html>

[output] | def reduceArray(arr): if not arr: return 0 result = arr[0] for num in arr[1:]: result = result + num return result print(reduceArray([2, 4, 6, 8, 10])) # Outputs: 30 [instruction] | Write a function that reduces an array of numbers to a single number. [input] | [2, 4, 6, 8, 10]

[output] | let data = { "name": "John Smith", "age": 35, "location": "Online" }; let name = data.name; let age = data.age; let location = data.location; console.log(name); // Outputs: John Smith console.log(age); // Outputs: 35 console.log(location); // Outputs: Online [instruction] | Parse this JSON data using JavaScript. [input] | { "name": "John Smith", "age": 35, "location": "Online" }

[output] | function isFibonacci(num) { let a = 0, b = 1; while (a <= num) { if (a == num) return true; let c = a + b; a = b; b = c; } return false; } console.log(isFibonacci(5)); // Outputs: true [instruction] | Write a JavaScript function to check if a number is in the Fibonacci sequence. [input] |

[output] | function leapYears() { for (let year = 2014; year <= 2050; year++) { if (year % 4 == 0) { console.log(year); } } } leapYears(); [instruction] | Implemet a JavaScript function to print all the leap year between 2014 and 2050. [input] |

[output] | def fibonacci(n): if n < 2: return n return fibonacci(n - 1) + fibonacci(n - 2) print(fibonacci(7)) # Outputs: 13 [instruction] | Re-implement this Ruby code in Python [input] | def fibonacci(n) return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2) end

[output] | def extractString(string, n): return string[:n] [instruction] | Given a string and an int n, write a function to extract the subsequence of length n from the string. [input] | s = "hello world", n = 6

[output] | def select_columns(table, columns): output = [table[0]] + [[row[i] for i in columns] for row in table[1:]] return output [instruction] | Given a data table, write a function to select the columns. [input] | table = [['Name', 'Age', 'Score', 'City'], ['Alice', '21', '85', 'New York'], ['Bob', '23', '92', 'Los Angeles'], ['Cathy', '20', '73', 'London']]

[output] | def add_calculation_column(dataframe, calculation, column_name): dataframe[column_name] = dataframe.eval(calculation) return dataframe [instruction] | Given a dataframe, write a function to add a new column that contains the results of a calculation between two columns. [input] | dataframe = Pandas DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]], columns=['A', 'B', 'C'])

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