← 목록

Synth · CodeAlpaca일부

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

[output] | <html> <head> <title>Welcome to My Site</title> </head> <body> <h1>Welcome to My Site</h1> </body> </html> [instruction] | Create an HTML page with a heading "Welcome to My Site". [input] |

[output] | A is not a valid code snippet. B is not a valid code snippet. C is not a valid code snippet. D is not a valid code snippet. The correct code snippet is: def calculate_sum(numbers): result = 0 for num in numbers: result += num return result [instruction] | Identify a code snippet from the following four options. [input] | def calculate_sum(numbers): result = 0 for num in numbers: result += num return result for option in ['A', 'B', 'C', 'D']: print(option)

[output] | def check_permutation(string1, string2): if len(string1) != len(string2): # The strings can't be permutations if they are different lengths return False # Convert the strings to lists list1 = list(string1) list2 = list(string2) # Sort the lists to make c [instruction] | Given two strings, find out if one is a permutation of the other. [input] | string1 = "cat" string2 = "act"

[output] | def find_most_populous_country(countries): max_population = 0 most_populous_country = None for country in countries: if country['population'] > max_population: max_population = country['population'] most_populous_country = country return f'The most pop [instruction] | Using the following list of countries and their population, write a program that prints the name and population of the most populous country. [input] | countries = [{'name': 'India', 'population': 1367030000}, {'name': 'China', 'population': 1406918015}, {'name': 'United States', 'population': 327000000}]

[output] | for i in range(5): for j in range(i+1): print("*", end=" ") print("") [instruction] | Print a pyramid of stars that has 5 levels. [input] |

[output] | string = "Hello World" for letter in string: print(letter) [instruction] | Use the following code to print each letter of the string "Hello World" on a separate line. [input] | string = "Hello World"

[output] | from bs4 import BeautifulSoup html = '<html><div><h1>This is a test</h1><p>This is a paragraph</p></div></html>' soup = BeautifulSoup(html, 'html.parser') # Print out all the elements for tag in soup.find_all(): print(f'Tag: {tag.name}') # Print out the content inside the tags for element [instruction] | Parse the following HTML text and print out all of the elements and the content inside them. [input] | <html><div><h1>This is a test</h1><p>This is a paragraph</p></div></html>

[output] | def convert(F): return (F-32)*5/9 [instruction] | Edit the existing Python code to convert Fahrenheit (F) degrees to Celsius (C) degrees. [input] | def convert(F): return F + 32

[output] | <div> <h1>My Web Page</h1> </div> [instruction] | Correct the syntax error in the following HTML structure. [input] | <div> <h1>My Web Page</h> <div/>

[output] | DELETE FROM employees; [instruction] | Write an SQL statement to delete all rows from a table named 'employees'. [input] |

[output] | SELECT * FROM employees ORDER BY age DESC; [instruction] | Write an SQL query to sort the table 'employees' based on their age in descending order. [input] |

[output] | void quickSort(int arr[], int left, int right) { int i = left, j = right; int tmp; int pivot = arr[(left + right) / 2]; /* partition */ while (i <= j) { while (arr[i] < pivot) i++; while (arr[j] > pivot) j--; if (i <= j [instruction] | Write a C++ code to implement quick sort algorithm. [input] |

[output] | # Get all column names all_columns <- names(data_frame) # Create an empty vector uncorrelated_columns <- c() # Iterate each column name in the data_frame for(column_name in all_columns) { # Store the correlations of each column in a vector correlations <- cor(data_frame[column_name], data_frame [instruction] | Write an R code to get the names of all uncorrelated columns in a data frame. [input] |

[output] | a { text-decoration: none; font-weight: bold; color: #0F8CC2; } a:visited { color: #00FFDC; } a:hover { color: #FF0089; } a:active { color: #C30000; } [instruction] | Write a CSS code to style links in a page. [input] |

[output] | import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression # Read the dataset dataset = pd.read_csv('Apple_Historical_Data.csv') # Get target and predictors X = dataset.iloc[:, :-1].values y = dataset.iloc[:, -1].values # Train the Li [instruction] | Train a machine learning model to predict the stock price of a company based on historical data. [input] | Historical data for the company Apple Inc.

[output] | void selectionSort(int arr[], int n) { int i, j, min_idx; // One by one move boundary of unsorted subarray for (i = 0; i < n-1; i++) { // Find the minimum element in unsorted array min_idx = i; for (j = i+1; j < n; j++) { if (ar [instruction] | Write a C++ code to perform selection sort on a given array of numbers. [input] | [2, 6, 4, 1, 7, 9, 8]

[output] | const userInput = prompt("Please enter some text:"); [instruction] | Write a JavaScript program to accept user input and store it in a variable. [input] |

[output] | #include <iostream> using namespace std; void mergeArrays(int arr1[], int arr2[], int n1, int n2, int arr3[]) { int i = 0, j = 0, k = 0; while (i<n1 && j <n2) { if (arr1[i] < arr2[j]) arr3[k++] = arr1[i++]; else arr3[k++] = arr2[j++]; [instruction] | Create a C++ program to merge two arrays of different lengths. [input] |

[output] | <html> <body> <form> <input type="text" name="input"> <input type="submit" value="Submit"> </form> </body> </html> [instruction] | Create an HTML form in which a user can input text and a button to submit. [input] |

[output] | from transformers import GPT2Tokenizer, GPT2LMHeadModel tokenizer = GPT2Tokenizer.from_pretrained('gpt2') model = GPT2LMHeadModel.from_pretrained('gpt2') def generate_text(seed_phrase): input_ids = torch.tensor(tokenizer.encode(seed_phrase)).unsqueeze(0) output_ids = model.generate( [instruction] | Create a GPT-2 model to generate text given a seed phrase. [input] |

[output] | <html> <head> <title>Color Toggle</title> <script> let isRed = true; let toggleButton = document.getElementById('toggle-button'); toggleButton.addEventListener('click', () => { let paragraph = document.getElementsByTagName('p') [instruction] | Create a HTML page with a paragraph and a button to toggle the paragraph's text color between red and blue. [input] |

[output] | public class MyClass { String field1; int field2; public MyClass(String field1, int field2) { this.field1 = field1; this.field2 = field2; } public MyClass() { this.field1 = ""; this.field2 = 0; } } [instruction] | Create a class in java, that has two fields and two constructors. [input] | Field1: String; Field2: int

[output] | In JavaScript, an object can be looped through by using either a for-in loop or by using the Object.keys() method. The for-in loop will iterate through the properties of the object and can be used to access the values associated with the properties. The Object.keys() method returns an array of the o [instruction] | In JavaScript, how do you loop through the properties of an object? [input] |

[output] | #!/bin/bash #Create array from set of numbers arr=(5 10 15 20) #Initialize sum and count sum=0 count=0 #Loop through the array and sum up the values for item in ${arr[@]}; do let sum=sum+$item let count=count+1 done #Calculate mean echo $(echo $sum/$count | bc -l) [instruction] | Write a Bash script to quickly calculate the mean for a set of numbers [input] | 5 10 15 20

[output] | import java.util.HashMap; public class LRUCache { // Custom Doubly Linked List static class CacheNode { CacheNode prev; CacheNode next; int key; int value; } // Map containing the Keys private HashMap<Integer, CacheNode> map [instruction] | Implement a LRU cache in Java [input] |

[output] | def second_largest(list_of_numbers): max_num = max(list_of_numbers) sec_max_num = None for num in list_of_numbers: if num != max_num and (sec_max_num is None or sec_max_num < num): sec_max_num = num return sec_max_num [instruction] | Write a function in Python that takes in a list and returns the second largest element [input] | list_of_numbers = [5, 10, 15, 20]

[output] | dnklkfaxvgpsvpytjimnzt [instruction] | Encrypt the following string using a substitution cipher [input] | thisisasupersecurestring

[output] | def max_subarray_sum(list_of_numbers): max_so_far = 0 max_ending_here = 0 for i in range(0,len(list_of_numbers)): max_ending_here = max_ending_here + list_of_numbers[i] if (max_ending_here < 0): max_ending_here = 0 elif (max_so_far < max_end [instruction] | Write an algorithm to calculate the maximum subarray sum [input] | list_of_numbers = [-2, 3, 1, -4]

[output] | import requests from bs4 import BeautifulSoup # Function to scrape for the specified HTML elements def scrape(url): response = requests.get(url) soup = BeautifulSoup(response.content, 'html.parser') # Use the .find, .find_all, .select and .select_one methods to scrape website titl [instruction] | Write a web scraper using Python [input] |

[output] | <button>Click Here!</button> [instruction] | Generate HTML for a button with the text "Click Here!". [input] |

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