← 목록

Synth · CodeAlpaca일부

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

[output] | """ Calculate the number of days since January 1st, 1971 until the given date """ import datetime as dt def num_days(date_str): datetime_object = dt.datetime.strptime(date_str, "%B %d, %Y").date() ref_date = dt.datetime(1971, 1, 1).date() return (datetime_object - ref_date).days if __ [instruction] | Compute the number of days since January 1st, 1971 until the given date. [input] | May 3rd, 2012

[output] | """ Select records from the database where the country name is identical to the input """ import sqlite3 country = 'Australia' conn = sqlite3.connect('database.db') c = conn.cursor() query = "SELECT * FROM countries WHERE name = ?" c.execute(query, (country,)) data = c.fetchall() conn.close() [instruction] | Write a code to select records from a database where the country name is identical to the input. [input] | Australia

[output] | """ Devise a function that converts a number represented in the binary system to a decimal number """ def binary_to_decimal(number): decimal = 0 power = 0 while number != 0: last_digit = number % 10 decimal += last_digit * pow(2, power) power += 1 number [instruction] | Devise a function that converts a number represented in the binary system to a decimal number. [input] | 1100

[output] | """ Design a program that prints out the multiplication table up to 12 x 12 """ for i in range(1, 13): for j in range(1, 13): print('{} x {} = {}'.format(i, j, i * j)) print("") [instruction] | Design a program that prints out the multiplication table up to 12 x 12. [input] |

[output] | """ Find the maximum element in a given array (unsorted) using a linear search approach """ def linear_search_max(arr): max_element = arr[0] for elem in arr[1:]: if elem > max_element: max_element = elem return max_element if __name__ == '__main__': arr = [10, 5 [instruction] | Find the maximum element in a given array (unsorted) using a linear search approach. [input] | [10, 5, 15, 80, 25]

[output] | """ Rewrite this code in a more efficient way making use of the built-in sort functions """ my_list = [3, 2, 1] my_list.sort() [instruction] | Rewrite this code in a more efficient way making use of the built-in sort functions. [input] | my_list = [3, 2, 1] for i in range(len(my_list)): for j in range(len(my_list)-1): if my_list[j] > my_list[j+1]: my_list[j], my_list[j+1] = my_list[j+1], my_list[j]

[output] | Microsoft used their own programming language called ChakraCore to create the Edge browser. ChakraCore is a JavaScript engine which is optimized for Edge. It is based on the Chakra engine which was originally developed to power Microsoft's Internet Explorer browser. [instruction] | What programming language did Microsoft use to create its Edge browser? [input] |

[output] | example_dict = {'Alice': 28} [instruction] | Create a Python dictionary with the key-value: "Alice": 28 [input] |

[output] | <table id="exampleTable"> <tr> <th>Name</th> <th>Age</th> <th>Country</th> </tr> </table> <script> const exampleTable = document.getElementById('exampleTable'); const rows = []; const columns = ["Name", "Age", "Country"]; columns.forEach((columnName) => { const newRow = [instruction] | Create a table using JavaScript with three columns, "Name", "Age", and "Country". [input] |

[output] | difference = 1587798320 - 1587797520 = 800 seconds [instruction] | Find the difference between two given Unix timestamps. [input] | 1587797520, 1587798320

[output] | <form> <label for="name">Name:</label> <input type="text" name="name" id="name"> <input type="submit" value="Submit"> </form> [instruction] | Create an HTML form with one text field and one submit button. [input] |

[output] | <p>Welcome to our website!</p> [instruction] | Create part of an Angular component that shows a message "Welcome to our website!" [input] |

[output] | def power(base, exponent): result = 1 while exponent > 0: result *= base exponent -= 1 return result result = power(2, 3) print(result) # 8 [instruction] | Implement an algorithm to find the power of a number. [input] | Base: 2, Exponent: 3

[output] | SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = '<database_name>'; [instruction] | Generate a SQL query to find all the table names in a database. [input] |

[output] | #!/bin/bash echo $(java -version 2>&1) [instruction] | Create a shell script to print the version of a given program. [input] | Program: java

[output] | df.dropna(inplace=True) [instruction] | Write a Pandas code to drop all rows with missing values from a given dataframe. [input] | Dataframe name: df

[output] | <div> <p>Hello! <a href="https://www.example.com" target="_blank">Visit my website</a></p> </div> [instruction] | Edit the following HTML code to add a link to an external website. [input] | <div> <p>Hello!</p> </div>

[output] | public class Fibonacci { public static void main(String[] args) { int n1 = 10, n2 = 0, n3, i; System.out.print(n1 + " "); for (i = 1; i <= 8; ++i) { n3 = n1 + n2; System.out.print(n3 + " "); n1 = n2; n2 = n3; [instruction] | Write a Java program to print the Fibonacci sequence starting from given number. [input] | Starting Number: 10

[output] | public static int findSumOfHourglass(int[][] arr){ int sum = 0; for(int i = 0; i < arr.length - 2; i++){ for(int j = 0; j < arr[i].length - 2; j++){ int tempSum = arr[i][j] + arr[i][j+1] + arr[i][j+2] + arr[i+1][j+1] + arr[i+2][j] + ar [instruction] | Given a 2D array of integers, write a Java method to find the sum of an hourglass pattern. [input] | The 2D array of integers are: [[1, 1, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0], [0, 0, 2, 4, 4, 0], [0, 0, 0, 2, 0, 0], [0, 0, 1, 2, 4, 0]]

[output] | You can create a new dataframe by using the concat() or merge() functions of pandas. With concat(), you can create a new dataframe by stacking the existing two dataframes on top/bottom of one another. With merge(), you can combine two dataframes by joining them on a key of your choice. [instruction] | How do you create a new dataframe from existing two pandas dataframes? [input] |

[output] | You can connect to PostgreSQL database using Java by using the JDBC driver. First, import the PostgreSQL JDBC driver class. Then, create an instance of the driver using a connection string and username and password. Finally, use the DriverManager class's getConnection() method to obtain a java.sql.C [instruction] | How do you connect to PostgreSQL database using Java? [input] |

[output] | The Set interface in Java provides an unsorted, unordered collection of objects that cannot contain duplicates. The Set interface is part of the Java Collection Framework and provides methods such as add(), remove() and contains() which allow you to manipulate the set. The Set interface is implement [instruction] | How do you use the Set structure in Java? [input] |

[output] | SELECT COUNT(*) FROM students WHERE course = 'Coding 101'; [instruction] | Write a MySQL query to count the number of students enrolled in a course called "Coding 101". [input] |

[output] | def print_reverse(str): for i in range(len(str)-1, -1, -1): print(str[i], end="") print() [instruction] | Define a function that takes a string and prints it in reverse order. [input] |

[output] | 1. Java 2. Python 3. C++ 4. JavaScript 5. C# [instruction] | Create a list of the top 5 programming languages currently in use. [input] |

[output] | public static ListNode mergeLinkedLists(ListNode head1, ListNode head2) { if(head1 == null) return head2; if(head2 == null) return head1; ListNode mergedList; if(head1.val < head2.val) { mergedList = head1; mergedList.next = merge [instruction] | Given two linked lists, write a Java program to merge them. [input] | The two linked lists are: List1 (1 -> 4 -> 5 -> 8 -> 10) List2 (2 -> 3 -> 6 -> 7 -> 9)

[output] | <form> Name: <input type="text" name="name"><br> Age: <input type="number" name="age"><br> Email: <input type="email" name="email"><br> <input type="submit" value="Submit"> </form> [instruction] | Write an HTML code to create a form with input fields for name, age and email address. [input] |

[output] | public class Average { public static void main(String args[]) { double nums[] = {8, 5, 10, 3, 9}; double result = 0; int i; for (i=0; i<5; ++i) { result = result + nums[i]; } System.out.println("Average is " + result / 5 [instruction] | Generate a code in Java to compute the average of 5 numbers. [input] | Compute the average of 8, 5, 10, 3 and 9

[output] | int array[4] = {5, 3, 10, 8}; for(int i = 1; i < 4; i++) array[i] = array[i+1]; //Decrement the size of array int n = sizeof(array)/sizeof(array[0]); n = n - 1; [instruction] | Generate a correct C++ code to delete the second item from an array. [input] | Delete the second item from the array [5, 3, 10, 8]

[output] | SELECT AVG(age) FROM employees; [instruction] | Generate an SQL query to calculate the average age of all employees from the table 'employees'. [input] |

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