← 목록

Synth · CodeAlpaca일부

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

[output] | def compare_dicts_by_key(dic1, dic2): if len(dic1) != len(dic2): return False for key in dic1: if key not in dic2 or dic1[key] != dic2[key]: return False return True [instruction] | Write a Python program to compare two dictionaries by key. [input] |

[output] | import random import string def random_strings_list(length): alphanumeric_chars = string.ascii_letters + string.digits strings_list = [] for _ in range(length): random_string = ''.join(random.choices(alphanumeric_chars, k=25)) strings_list.append(random_string) retur [instruction] | Generate a list of random alphanumeric strings of length 25. [input] |

[output] | def format_IP_addresses(ip_addresses): return [str(IPAddress(ip)) for ip in ip_addresses] [instruction] | Write a Python program to format the following list of IP addresses. [input] | ip_addresses = ["192.168.1.1", "255.255.255.255","8.8.8.8"]

[output] | multiples_list = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30] [instruction] | Create a list in Python that contains the first 10 multiples of 3. [input] |

[output] | const largestNumber = Math.max(...numbers); [instruction] | Given the following array in JavaScript, write a statement that finds the largest number. [input] | const numbers = [3, 5, 2, 10, 7, 4]

[output] | In Python, strings are immutable which means they can not be changed once created. On the other hand, a list is mutable, meaning the elements can be altered after the list is created. Additionally, strings are sequences of characters, whereas lists are sequences of any type of data. [instruction] | What is the difference between a string in Python and a list? [input] |

[output] | int[] mergedArray = new int[array1.length + array2.length]; System.arraycopy(array1, 0, mergedArray, 0, array1.length); System.arraycopy(array2, 0, mergedArray, array1.length, array2.length); [instruction] | Given two arrays in Java, how would you merge them into one array? [input] | int[] array1 = {1, 2, 3}; int[] array2 = {4, 5, 6};

[output] | SELECT MAX(Age) FROM Employee; [instruction] | Write a SQL statement to fetch the maximum age from the table "employee". [input] |

[output] | if (Object.prototype.hasOwnProperty.call(object, 'property')) { // property exists } [instruction] | Given a Node.js object, how can you check if a property exists in the object? [input] |

[output] | class BulletList extends React.Component { render() { const {data} = this.props return ( <ul> {data.map(item => <li>{item}</li>)} </ul> ); } } [instruction] | Write a React component that accepts an array of strings and renders a bulleted list. [input] | const data = ["dog", "cat", "bird"]

[output] | class User { protected $username; protected $password; protected $email; } [instruction] | Create a PHP class with three protected fields "User Name", "Password", and "Email" [input] |

[output] | SELECT ShippedDate, COUNT(*) FROM ORDERS GROUP BY ShippedDate; [instruction] | Write a SQL query that returns the number of orders shipped on each day. [input] | SELECT * FROM ORDERS

[output] | delete object["key"]; [instruction] | Given a JavaScript object, how can you remove a key from the object? [input] |

[output] | import React from 'react'; function Postcard() { return ( <div> <p>Hello from Paris!</p> <img src="eiffel-tower.jpg" alt="Eiffel Tower" /> <button type="button">Return to Homepage</button> </div> ) } export default Postcard; [instruction] | Create a React component for a Postcard element to display on a webpage. [input] | The postcard should contain a paragraph element containing the text "Hello from Paris!", an image of the Eiffel Tower, and a "Return to Homepage" button below the image.

[output] | let sortArrayByName = (array: string[]) => { array.sort(function (x, y) { if (x < y) { return -1; } if (x > y) { return 1; } return 0; }); return array; }; let names = ["John", "James", "Karl", "Jane", "Jill"]; sortArrayByName(names); console.log(names); [instruction] | Write a TypeScript script to sort an array of names in alphabetical order. [input] | The following array of names: ["John", "James", "Karl", "Jane", "Jill"]

[output] | SELECT customers.name FROM customers JOIN orders ON customers.id = orders.customer_id GROUP BY customers.id HAVING SUM(orders.price) > 100; [instruction] | Write a SQL query for finding the customers with orders of total price of more than $100. [input] |

[output] | <a href="mailto:support@example.com">support@example.com</a> [instruction] | Write an HTML code snippet to create an email link for "support@example.com" [input] |

[output] | <ul> <li>Apples</li> <li>Bananas</li> <li>Cherries</li> <li>Dates</li> <li>Eggplants</li> <li>Figs</li> <li>Grapes</li> <li>Honeydews</li> <li>Ice cream</li> <li>Jelly beans</li> <li>Kiwis</li> <li>Lemons</li> <li>Mangoes</li> <li>Nectarine</li> <li>Oranges</li> <li>P [instruction] | Create a list of 20 words ordered alphabetically in HTML. [input] |

[output] | import random def random_number(): return random.randint(0,99) [instruction] | Create a function to generate random numbers from 0-99. [input] |

[output] | def is_value_in_arr(arr, x): if x in arr: return True else: return False [instruction] | Create a function to check whether a given value is in an array. [input] | arr = [1,2,3,4] x = 2

[output] | function stringLength(str){ return str.length; } [instruction] | In JavaScript, create a function that returns the length of a string. [input] |

[output] | def generateFibonacci(num): a = 0 b = 1 fib_sequence = [] while a < num: fib_sequence.append(a) a, b = b, a + b return fib_sequence [instruction] | Create a function to generate Fibonacci numbers less than 100. [input] |

[output] | class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def append(self, data): new_node = Node(data) if not self.head: self.head = new_node return [instruction] | Suggest a way to create a linked list in python. [input] |

[output] | class WelcomeMessage: def __init__(self): print("Welcome to the world of programming!") [instruction] | Create a class that prints out the following message: "Welcome to the world of programming!" [input] |

[output] | public class Heapsort { public void sort(int arr[]) { int n = arr.length; // Build heap (rearrange array) for (int i = n / 2 - 1; i >= 0; i--) heapify(arr, n, i); // One by one extract an element from heap for (int i=n-1; i>=0 [instruction] | Create a binary heap sort algorithm in Java. [input] |

[output] | import flask app = flask.Flask(__name__) @app.route("/users", methods=("GET",)) def get_users(): users = [ {"name": "John Smith", "age": 45}, {"name": "Tim Jones", "age": 34}, {"name": "Alice Jackson", "age": 24} ] return flask.jsonify(users) [instruction] | How would you create an API endpoint that returns a list of users? [input] |

[output] | def sum_nums(n): total = 0 for i in range(1,n+1): total += i return total print(sum_nums(100)) [instruction] | Write code to output the sum of the numbers 1-100. [input] |

[output] | dict = { "ABC": "ABC", "XYZ": "XYZ", "PQR": "PQR"} [instruction] | Write a script that inputs a list and converts the list of strings into a dictionary. [input] | list = ["ABC", "XYZ", "PQR"]

[output] | <a href="www.example.com/product/apple">www.example.com/product/apple</a> [instruction] | Generate a link of the page given below. [input] | Page URL: www.example.com/product/apple

[output] | ["jump", "jumps"] [instruction] | Extract all instances of a specific word in the given text. [input] | Text: The quick brown fox jumps over the lazy dog. Word: j

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