← 목록

Synth · CodeAlpaca일부

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

[output] | class BalancedBraces: def checkBalanced(self, expression): s = [] for i in expression: if i == '(' or i == '[' or i == '{': s.append(i) elif i == ')' or i == ']' or i == '}': if len(s) > 0 and ( (i == [instruction] | Construct a class that can be used to check if the braces in an expression are balanced. [input] | expression = "[(}{)]"

[output] | void deleteNode(struct Node **head_ref, int position) { if (*head_ref == NULL) return; // Store head node struct Node* temp = *head_ref; // If header is removed if (position == 0) { *head_ref = temp->next; // Change head free(temp); [instruction] | Make a C++ program to delete a node from a doubly linked list at a given position. [input] | Linked List: 84 -> 13 -> 25 -> 48 -> 50 Position: 3

[output] | <!DOCTYPE html> <html> <head> <title>Title of the document</title> </head> <body> <h1>This is a Heading</h1> <p>This is a paragraph.</p> </body> </html> [instruction] | Generate a proper HTML page. [input] |

[output] | class Stack: def __init__(self): self.stack = [] def isEmpty(self): return self.stack == [] def push(self, data): self.stack.append(data) def pop(self): data = self.stack[-1] del self.stack[-1] return data [instruction] | Write a class to implement a stack using an array. [input] |

[output] | def contains(string1, string2): return string2 in string1 [instruction] | Create a function in Python which takes two strings as arguments and returns true if the first string contains the second string, false otherwise. [input] |

[output] | db.users.find({birthdate: {$lt: '2020-04-01'}}) [instruction] | Transform the following SQL query into a NoSQL query for MongoDB. [input] | SELECT * FROM users WHERE birthdate < '2020-04-01'

[output] | 144 [instruction] | Calculate the Fibonacci sequence of the number 12. [input] |

[output] | 195 [instruction] | Evaluate the following arithmetic expression with Python. [input] | 15 * (2 + 7)

[output] | .container { width: 500px; } [instruction] | Create a CSS rule to set a width of 500px to the elements having the class "container". [input] |

[output] | function nthFromEnd(arr, n) { return arr[arr.length - n]; } nthFromEnd([2, 5, 8, 6, 9, 0], 2) // returns 6 [instruction] | Implement a function in JavaScript which returns the nth element from the end of an array. [input] | array: [2, 5, 8, 6, 9, 0] n: 2

[output] | "hello world".split(" ") // returns ["hello", "world"] [instruction] | Split the string "hello world" into an array of individual words in JavaScript. [input] |

[output] | SELECT product_name, COUNT(*) FROM products GROUP BY product_name ORDER BY COUNT(*) DESC LIMIT 10; [instruction] | Write a SQL query which returns the top 10 most popular products in the following "products" table. [input] |

[output] | <style> div { list-style-type: disc; } <style> <div>Item 1</div> <div>Item 2</div> <div>Item 3</div> [instruction] | Change the following HTML elements into a bulleted list with CSS. [input] | <div>Item 1</div> <div>Item 2</div> <div>Item 3</div>

[output] | public class Pattern { public static void main(String[] args) { for (int i = 1; i <= 5; i++) { for (int j = 1; j <= i; j++) { System.out.print(i); } System.out.println(); } } } // Output 1 22 333 4444 55555 [instruction] | Create a Java program which will print the following pattern. [input] |

[output] | dict1 = {'a':1, 'b':2} dict2 = {'c':3, 'd':4}; merged_dict = {**dict1, **dict2} print(merged_dict) // returns {'a': 1, 'b': 2, 'c': 3, 'd': 4} [instruction] | Merge the two following dictionaries into one with Python. [input] | dict1 = {'a':1, 'b':2} dict2 = {'c':3, 'd':4};

[output] | SELECT COUNT(*) FROM customers WHERE country = 'France'; [instruction] | Write a SQL query which returns the number of customers from the following "customers" table that are from France. [input] |

[output] | 6 [instruction] | Count the number of employees for a given company in the following list. [input] | company_list = [ ["Apple", "John", "James"], ["Google", "Adam", "Steve", "Joseph"], ["Facebook", "Matt", "Chris"], ]

[output] | SELECT name FROM employees WHERE company = 'Apple'; [instruction] | Write a SQL query to select the names of all employees who work at company 'Apple'. [input] |

[output] | In Python, a dictionary is a collection of unordered key-value pairs. It is a mutable data type which allows users to store data in the form of key-value pairs. A key is an immutable object (like a number, string, or tuple) that is used to access the value stored for the corresponding key. A value c [instruction] | Explain in simple terms what a dictionary is in Python. [input] |

[output] | ^a.*Z$ [instruction] | Write a Regular Expression that matches all strings starting with a lowercase 'a' and ending with an uppercase 'Z'. [input] |

[output] | function printHello() { console.log("Hello!"); } printHello(); [instruction] | Translate the following Ruby code to Javascript [input] | def print_hello puts "Hello!" end print_hello

[output] | public class WordCounter { public static int countWords(String s) { String trimStr = s.trim(); if (trimStr.isEmpty()) return 0; return trimStr.split("\\s+").length; } public static void main(String args[]) { String s = "This is a sample sente [instruction] | Write a Java program that takes a String as parameter and counts how many words are in it. [input] |

[output] | from functools import wraps def logger(func): @wraps(func) def log_function(*args, **kwargs): print('Running "{}" with arguments {}, {}'.format(func.__name__, args, kwargs)) return func(*args, **kwargs) return log_function [instruction] | How would you define a Python decorator called ``logger`` to log the functions being called? [input] |

[output] | class ContactEntry: def __init__(self, name, phone_number, email): self.name = name self.phone_number = phone_number self.email = email [instruction] | Write a class in Python to represent an entry in a contact book. [input] |

[output] | from math import sqrt def prime_numbers(n): primes = [] i = 2 while len(primes) < n: for number in range(2, int(sqrt(i)) + 1): if i % number == 0: break else: primes.append(i) i += 1 yield from primes [instruction] | Using the standard library to construct a generator that returns the first n prime numbers. [input] |

[output] | import requests from bs4 import BeautifulSoup url = 'https://example.com/' response = requests.get(url) html = response.text soup = BeautifulSoup(html, 'html.parser') headlines = [] for tag in soup.find_all('h1', class_='headline'): headline = tag.string headlines.append(headline) [instruction] | Implement a web scraper in Python to extract all headlines from a web page. [input] |

[output] | reg_expr = r"\b(beginning|starting)\b" [instruction] | Compose a regular expression to match the words 'beginning' and 'starting'. [input] |

[output] | int_list = [3, 5, 2, 4, 1] max_value = max(int_list) min_value = min(int_list) [instruction] | Find the maximum and minimum values of a given list of integers in Python. [input] |

[output] | import numpy as np a_3d_array = np.array([[[1,2], [3,4]], [[5,6], [7,8]]]) a_2d_array = a_3d_array.reshape(4,2) [instruction] | Reduce the 3-dimensional numpy array to a 2-dimensional numpy array. [input] |

[output] | for x in range(10): for y in range(10): print("*" if (x + y) % 2 == 0 else " ", end="") print("") [instruction] | Create a Python script to print the following output. [input] |

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