← 목록

Synth · CodeAlpaca일부

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

[output] | <?php // Establish a connection to the database $conn = new mysqli('localhost', 'username', 'password', 'database'); // Check the connection if ($conn->connect_error) { die("Connection failed:" . $conn->connect_error); } // Execute the query $sql = "SELECT * FRO [instruction] | Develop a PHP code snippet to retrieve all records from a database table "POSTS". [input] |

[output] | public class MyTask implements Runnable { public void run() { while (true) { System.out.println("This is the task running every 5 seconds."); try { Thread.sleep(5000); } catch (InterruptedException e) { [instruction] | Develop a code snippet in Java to create a thread that runs a simple print statement every 5 seconds. [input] |

[output] | <ul> <li> <div>Navigation Menu</div> <ul> <li> <div>Link 1</div> </li> <li> <div>Link 2</div> <ul> <li> <div>Link 2.1</div> </li> [instruction] | Write a CSS code to create a navigation menu with drop down sub menus. [input] |

[output] | def heapsort(arr): # Build the max heapify n = len(arr) for i in range(n, -1, -1): heapify(arr, n, i) # One by one extract elements for i in range(n-1, 0, -1): arr[i], arr[0] = arr[0], arr[i] # swap heapify(arr, i, 0) def heapify(arr, n, i): [instruction] | Write a code that takes a given list and sorts them using heapsort. [input] | arr = [1, 6, 5, 4, 8, 2]

[output] | flag = False str1 = "Hello World" if flag: print(str1) else: print("The flag is set to False, so nothing is printed") [instruction] | Update the below code with a flag to control the output according to the argument given [input] | flag = False str1 = "Hello World" if flag == False: print(str1)

[output] | def mult_table(arr1, arr2): for i in range(len(arr1)): for j in range(len(arr2[0])): for k in range(len(arr2)): print(arr1[i][k] * arr2[k][j], end=" ") print() arr1 = [ [1,2] , [3,4] ] arr2 = [ [5,6] , [7,8] ] mult_table(arr1, arr2) # Output: 5 12 [instruction] | Create a function to print out a multiplication table of two given multidimensional arrays. [input] | arr1 = [ [1,2] , [3,4] ] arr2 = [ [5,6] , [7,8] ]

[output] | num1 = 5 num2 = 7 output = [num1, num2] print(output) # Output: [5, 7] [instruction] | Change the following code for the output to be a list [input] | num1 = 5 num2 = 7

[output] | words = ['hello', 'world', 'my', 'name', 'is', 'john'] for word in words: print(word[::-1], end=" ") # Output: olleh dlrow ym eman si nhoj [instruction] | Suggest a completion for the following code so that all the words in a list are printed in reverse [input] | words = ['hello', 'world', 'my', 'name', 'is', 'john'] for word in words:

[output] | CREATE TABLE my_table ( name TEXT NOT NULL, age INT NOT NULL, score INT NOT NULL ); INSERT INTO my_table (name, age, score) VALUES ('Tom', 14, 80), ('Mary', 27, 96), ('John', 8, 75); [instruction] | Create a MySQL table with three columns containing values from a given list. [input] | List: Tom, 14, 80 Mary, 27, 96 John, 8, 75

[output] | from bs4 import BeautifulSoup html_str = """ <html> <p>This is a paragraph</p> <div> <span>This is a span</span> <p>This is also a paragraph</p> <p>This is another paragraph</p> </div> </html> """ soup = BeautifulSoup(html_str, 'html.parser') paragraphs = soup.find_all('p') for [instruction] | Parse the following HTML string and get a list of all the <p> tags. [input] | <html> <p>This is a paragraph</p> <div> <span>This is a span</span> <p>This is also a paragraph</p> <p>This is another paragraph</p> </div> </html>

[output] | SELECT * FROM table ORDER BY timestamp DESC LIMIT 10; [instruction] | Write a SQL query that returns the 10 most recently created entries from a table with a timestamp column. [input] |

[output] | public class Movies { private int movieCount; private String genre; public Movies(int movieCount, String genre) { this.movieCount = movieCount; this.genre = genre; } public void printMovieDetails() { System.out.println("The movie count is " + movieCount); System.out.pri [instruction] | Refactor the following Java code to improve readability and dynamism. [input] | public class Movies { private int movieCount = 5; private String genre = "action"; public void printMovieDetails() { System.out.println("The movie count is " + movieCount); System.out.println("The genre is " + genre); } }

[output] | def get_object_details(input_obj): output = [] for key, value in input_obj.items(): if type(value) == list: value = ", ".join(value) output.append(f"{key}: {value}") return "\n".join(output) [instruction] | Create a Python function that takes an object as an input and returns its names and values. [input] | Input: {"name": "John", "age": 25, "cities": ["New York", "Boston"]}

[output] | #include<stdio.h> #include<stdlib.h> struct array_struct { int a[4]; }; int main() { struct array_struct s; s.a[0] = 13; s.a[1] = 5; s.a[2] = 17; s.a[3] = 89; printf("s.a[0]: %d\n", s.a[0]); printf("s.a[1]: %d\n", s.a[1]); printf("s.a[2]: %d\n", s.a[2]); printf("s.a[3] [instruction] | Write a C program that creates an array of 4 elements in a structure and print it. [input] |

[output] | SELECT MAX(salary) as SecondHighestSalary FROM salary WHERE salary NOT IN (SELECT MAX(salary) FROM salary) [instruction] | Write an SQL query that returns the second highest salary from a table with a salary column. [input] |

[output] | for num in reversed([3, 2, 5, 4, 6]): print(num) [instruction] | Construct a for loop in Python to iterate through the list [3, 2, 5, 4, 6] in reverse order. [input] |

[output] | "8, 12, 5, 2" [instruction] | Given a comma-separated string with numbers, remove the max value from it and output a string with comma-separated values [input] | 8, 12, 5, 2, 18

[output] | .bordered { border: 1px solid black; } [instruction] | Write a CSS class that will apply a border around an HTML element. [input] |

[output] | def capitalize_combined_string(str1,str2): combined_str = str1 + str2 return combined_str.upper() [instruction] | Combine the two given strings and capitalize the resulting letters. [input] | Hello World

[output] | def sum_row_in_2d_array(arr): result = [] # iterating through array for sub_arr in arr: sum=0 # iterating through sub array for element in sub_arr: sum += element # Adding sum to result list result.append(sum) return result [instruction] | Given a two-dimensional array, write a Python code to sum each row in the array and store it in a new array. [input] | [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

[output] | public static double FahrenheitToCelsius(double fahrenheitTemperature) { double celsiusTemperature = (fahrenheitTemperature - 32) / 1.8; return celsiusTemperature; } [instruction] | Using C#, write a code to convert a Fahrenheit temperature to its equivalent in Celsius. [input] | 50

[output] | function oddNumbers(arr) { let oddNumbers = arr.filter(function(element) { return element % 2 !== 0; }); return oddNumbers; } [instruction] | Write a code to extract the odd numbers from a given array in JavaScript. [input] | [1, 2, 3, 4, 5, 6, 7, 8, 9]

[output] | #include <iostream> using namespace std; int main() { int n, i, c; for (n = 2; n <= 16; n++) { c = 0; for (i = 1; i <= n; i++) { if (n % i == 0) { c++; } } if (c == 2) { [instruction] | Create a C++ program that finds the first 8 prime numbers. [input] |

[output] | let x = 3 + 4 * 2; console.log(x); [instruction] | Solve the following Problem and display the answer using JavaScript: What is 3+4*2? [input] |

[output] | <table> <tr> <th>Name</th> <th>Age</th> </tr> <tr> <td>John</td> <td>25</td> </tr> <tr> <td>David</td> <td>34</td> </tr> <tr> <td>Sarah</td> <td>22</td> </tr> </table> [instruction] | Generate HTML output for displaying the following table: | Name | Age | | ------- | --- | | John | 25 | | David | 34 | | Sarah | 22 | [input] |

[output] | SELECT name, age, address FROM persons WHERE age > 25; [instruction] | Write a SQL query to get the name, age and address of the people whose age is greater than 25. [input] |

[output] | #include <iostream> using namespace std; int main() { int n, i, c; n = 17; c = 0; for (i = 1; i <= n; i++) { if (n % i == 0) { c++; } } if (c == 2) { cout << n << " is a prime number" << endl; } else { [instruction] | Construct a C++ program that checks whether a number is prime or not. [input] | number = 17

[output] | <h1 id="demo-id">This is a heading</h1> [instruction] | Edit the following HTML code to add an ID attribute with value "demo-id" to the <h1> element. [input] | <h1>This is a heading</h1>

[output] | Tom Johnson. [instruction] | Retrieve the name of the third author from a given list of authors. [input] | Authors: John Doe, Jane Smith, Tom Johnson

[output] | "Hello World!" [instruction] | Find all the string literals in a given C++ program. [input] | #include <iostream> int main(){ std::cout << "Hello World!" << std::endl; return 0; }

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