← 목록

Synth · CodeAlpaca일부

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

[output] | def has_duplicates(list): seen = set() for item in list: if item in seen: return True seen.add(item) return False [instruction] | Using Python, write code to check if a list contains duplicates or not. [input] | list = [10, 20, 30, 40, 50]

[output] | The last element of the list can be accessed using the index -1 or using the list method pop(): last_element = list[-1] or last_element = list.pop() [instruction] | How can I get the last element of this list? [input] | list = [1, 2, 3, 4, 5]

[output] | url = 'https://www.google.com/search?q=' + query.replace(' ', '+') [instruction] | Construct a URL to search for a given query on Google [input] | query = 'Python programming'

[output] | person = { "name": "John Smith", "age": 32, "address": { "street": "123 Main Street", "city": "Chicago", "state": "IL" }, "hobbies": ["golf", "reading", "fishing"] } [instruction] | Create a JSON object that contains person data. [input] |

[output] | The time complexity for this loop is O(n) where n is the length of the list. [instruction] | What is the time complexity for this for loop? [input] | nums = [1,2,3,4,5] for num in nums: print(num)

[output] | The main difference between lists and tuples is that lists are mutable, meaning they can be changed, while tuples are immutable and cannot be changed. Lists are used when the data is expected to change, while tuples are used when the data is expected to stay the same. In addition, a list can contain [instruction] | Describe the difference between lists and tuples [input] |

[output] | SELECT S.name FROM Student S INNER JOIN Course C ON S.course_id = C.course_id WHERE C.course_name = 'Maths 101'; [instruction] | Write a SQL query to list the names of all students registered for Maths 101. [input] |

[output] | The sum of the numbers in the list is 51. [instruction] | Using the following list of prime numbers, calculate their sum. [input] | [2, 3, 5, 7, 11, 13]

[output] | { "shoes": [ { "name": "Nike Air Zoom", "color": "Black", "size": 10.5 }, { "name": "Skechers GoWalk", "color": "Grey", "size": 11 } ] } [instruction] | Construct a JSON object to represent the following shoes array. [input] | [ { "name": "Nike Air Zoom", "color": "Black", "size": 10.5 }, { "name": "Skechers GoWalk", "color": "Grey", "size": 11 } ]

[output] | The average monthly temperature in Fahrenheit is 84.9. [instruction] | Using the given data, find the average monthly temperature in Fahrenheit. [input] | June: 78.1, July: 87.8, August: 90

[output] | class Cube(object): def __init__(self, side_length): self.side_length = side_length def calculate_volume(self): return self.side_length * self.side_length * self.side_length [instruction] | Construct a class in Python that can calculate the volume of a cube given its side length. [input] |

[output] | The object with the highest age is {name: "Jack", age: 50}. [instruction] | Using the given array of objects, find the object with the highest age. [input] | [{name: "John", age: 25}, {name: "Jack", age: 50}, {name: "Jill", age: 30}]

[output] | The above PHP code first initializes two string variables, $string1 and $string2, with the strings "Hello" and "World" respectively. Then, it uses the string concatenation operator (.) to combine the two strings together, separated by a space, and prints the result using the echo function. The resul [instruction] | Explain the following PHP code. [input] | $string1 = "Hello"; $string2 = "World"; echo $string1 . " " . $string2;

[output] | ∀x(Animal(x) → Mammal(x)) [instruction] | Turn the statement into a valid predicate in first-order logic. [input] | "All animals are mammals"

[output] | <table> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> </tr> </table> [instruction] | Write an HTML tag to create a table with three columns and two rows. [input] |

[output] | Function Fibonacci(n) Declare f0, f1, fn f0 = 0 f1 = 1 if n = 0 fn = f0 else if n = 1 fn = f1 else for i = 2 to n fn = f0 + f1 f0 = f1 f1 = fn end for return fn End Function [instruction] | Generate pseudocode to solve the Fibonacci sequence. [input] |

[output] | SELECT TOP 5 SUBSTRING(Email, LEN(Email) - CHARINDEX('@', REVERSE(Email)) + 2, LEN(Email)) AS Domain FROM Customers GROUP BY SUBSTRING(Email, LEN(Email) - CHARINDEX('@', REVERSE(Email)) + 2, LEN(Email)) ORDER BY Domain DESC [instruction] | Create a SQL query to get a list of the top 5 email domains from a customer table. [input] |

[output] | <?php function printPrimes() { $n = 2; while (1000--) { $isPrime = 1; for ($i = 2 ; $i <= sqrt($n); $i++) { if ($n % $i == 0) { $isPrime = 0; break; [instruction] | Create a PHP function to print the first 1000 prime numbers. [input] |

[output] | def random_number rand end puts random_number [instruction] | Create a Ruby function to generate a number between 0 and 1. [input] |

[output] | import sqlite3 conn = sqlite3.connect('database.db') c = conn.cursor() # Create table c.execute('CREATE TABLE Course (course_name TEXT, course_id TEXT, course_description TEXT, course_instructor TEXT)') # Save (commit) the changes conn.commit() # Close the connection conn.close() [instruction] | Design a key-value database with Python for storing course information. [input] | The database should contain the following fields: Course Name, Course ID, Course Description and Course Instructor.

[output] | public static int countOnes(int num) { int count = 0; while (num != 0) { num = num & (num - 1); count++; } return count; } [instruction] | Implement an algorithm in Java to count the number of ones in a binary number [input] |

[output] | int sumRange(int start, int stop) { int sum = 0; for (int i = start; i <= stop; i++) sum += i; return sum; } [instruction] | Create a function in C++ to calculate the sum of range [input] |

[output] | SELECT c.customer_id, c.name, SUM(o.price) as total_spending FROM customers c JOIN orders o ON c.customer_id = o.customer_id GROUP BY c.customer_id, c.name ORDER BY total_spending DESC LIMIT 10; [instruction] | Write a SQL query to get the top 10 customers with highest overall spending [input] |

[output] | SELECT e.first_name, e.last_name, e.birth_date FROM Employees e ORDER BY e.birth_date ASC LIMIT 1; [instruction] | Design a MySQL query to find out the youngest employee [input] |

[output] | def break_down(n): digit_list = [int(x) for x in str(n)] return digit_list [instruction] | Create a function in Python to break down the number into its digits [input] |

[output] | SELECT * FROM employees WHERE department = 'R&D'; [instruction] | Write an SQL query to display all employees who work in the R&D department. [input] |

[output] | const JString = JSON.stringify(JObj); console.log(JString); // { “name” : “John”, “age” : 42 } [instruction] | Using JavaScript, convert the following JSON object into a string. [input] | JObj = { “name” : “John”, “age” : 42 }

[output] | function displayEvenNumbers($n) { for($i = 2; $i <= $n; $i++) { if($i % 2 == 0) { echo $i." "; } } } [instruction] | Implement a function in PHP to display all even numbers between 2 and the given number n. [input] |

[output] | SELECT salary FROM employees ORDER BY salary DESC LIMIT 3 [instruction] | Write a query in MySQL to display the top 3 highest salaries. [input] |

[output] | public class Student{ String firstName; String lastName; int age; //constructor Student(String firstName, String lastName, int age){ this.firstName = firstName; this.lastName = lastName; this.age = age; } } [instruction] | Create a class in Java called Student with 3 instance variables - firstName, lastName, and age. [input] |

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