← 목록

Synth · CodeAlpaca일부

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

[output] | def fibonacci(n): if n == 0: return 0 elif n == 1: return 1 else: return fibonacci(n-1) + fibonacci(n-2) [instruction] | Calculate the Fibonacci sequence up to the n-th number where n is provided as an argument. [input] |

[output] | def is_even(num): return num % 2 == 0 [instruction] | Create a program to check if the input is an even number. [input] |

[output] | def find_first_non_repeating(string): seen = {} for char in string: if char in seen: seen[char] +=1 else: seen[char] = 1 return [char for char in string if seen[char] == 1][0] [instruction] | Find the first non-repeating character in a string. [input] | string: "abcdabcd"

[output] | def count_combinations(string, length): result = 1 for i in range(length): result *= len(string) return result [instruction] | Find the number of combinations of a given length from the characters in a given string. [input] | string: "ABCD" length: 2

[output] | def nth_element(n): if n == 0: return 0 elif n == 1: return 1 else: return nth_element(n-1) + nth_element(n-2) [instruction] | Create a program to find the nth element of the Fibonacci sequence. [input] |

[output] | import random # list of words word_list = ["python", "java", "computer", "programming", "hangman"] # randomly select a word word = random.choice(word_list) # set initial lives lives = 6 # write your code here def hangman(word, lives): return # write your code here [instruction] | Implement a game of Hangman in Python. [input] |

[output] | @app.route('/items', methods = ['GET']) def display_items(): # write your code here items = [] # query the database items = db.session.query(Items).all() # return the list of items return jsonify(items) [instruction] | Create a Flask endpoint for displaying a list of items from a database. [input] | Table name: 'items' Columns: id, name, price

[output] | import React from 'react'; class MessageForm extends React.Component { state = {name: '', message: '' } handleChangeName = evt => { this.setState({ name: evt.target.value }); } handleChangeMessage = evt => { this.setState({ message: evt.target.value }); } handleSubmit = evt = [instruction] | Write a React component for a form to allow users to submit a message. [input] |

[output] | import tensorflow as tf # define the model model = tf.keras.Sequential([ tf.keras.layers.Input(shape=(1,), name="Input_Layer", dtype=tf.float32), tf.keras.layers.Dense(32, activation='relu', name="Hidden_Layer_1"), tf.keras.layers.Dense(32, activation='relu', name="Hidden_Layer_2"), tf.keras.la [instruction] | Use TensorFlow to build a deep learning model for predicting the price of a given stock. [input] |

[output] | class SignupController < ApplicationController def create # write your code here end private def signup_params params.require(:signup).permit(:name, :email, :password, :password_confirmation) end end [instruction] | Write a controller in Ruby for processing user sign up requests. [input] |

[output] | SELECT SUM(amount) AS total_amount FROM transactions; [instruction] | Write a SQL query to compute the sum of a column of a given table. [input] | Table name: 'transactions' Columns: id, amount

[output] | /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][ [instruction] | Read the following text and use a regular expression to extract email addresses. [input] | Please contact john@example.com and lisa@mail.com for more information.

[output] | import smtplib from email.mime.text import MIMEText # write your code here def send_email(recipient, message): sender_email = "<your@email.com>" sender_name = "Daily Reminder" # create the message msg = MIMEText(message) msg['Subject'] = 'Daily Reminder' msg['From'] = sender_name + ' <' + se [instruction] | Create a web service for sending a daily email reminder. [input] |

[output] | SELECT customer_name FROM customers WHERE orders.amount > 100 AND orders.date > NOW() - INTERVAL 1 MONTH; [instruction] | How would you write a query in SQL to return the names of all customers who have purchased over $100 in the last month? [input] |

[output] | #include <iostream> #include <cstdlib> #include <ctime> using namespace std; // Generate a random number between 1 and 20 int randomnumber(int min, int max) { return (rand() % (max - min + 1) + min); } int main() { int num; // Use current time as seed for random generator [instruction] | Get a random number between 1 and 20 using C++. [input] |

[output] | Class 1: BankAccount - Responsible for creating, deleting, and managing bank accounts Class 2: Transaction - Responsible for storing and tracking transaction histories Class 3: User - Responsible for managing user access information Class 4: Customer - Responsible for storing customer data and prov [instruction] | Create four classes for a digital banking application. [input] |

[output] | def contains_palindrome(words): for word in words: if word == word[::-1]: return True return False [instruction] | Given a list of words, write a function to check if the list contains any palindrome words. [input] | words = ["racecar", "level", "tot", "trot"]

[output] | The HTML elements used for formatting include <p>, <hr>, <br>, <b>, <i>, <strong>, <em>, <sup>, <span>, <blockquote>, <pre>, <address>, <div>, <ul>, <ol>, <li>, and <table>. [instruction] | List all the HTML elements which are used for formatting. [input] |

[output] | def findNumbers(N, M): count = 0 for i in range(1, N+1): if i % 10 <= M: count += 1 return count [instruction] | Given two numbers N and M, write a program to find the number of numbers from 1 to N where the last digit is less than or equal to M. [input] | N = 30, M = 7

[output] | Julia's dynamic programming technique uses memoization, which is a method of storing and reusing the result of previous computations. Bottom-up dynamic programming is a type of dynamic programming that begins with the solution to small problem instances and gradually builds up towards larger problem [instruction] | How is the Julia dynamic programming technique different from bottom-up dynamic programming? [input] |

[output] | def findLongestSubsequence(arr): n = len(arr) dp = [1]*n for i in range(1, n): for j in range(i): if arr[i] > arr[j] and dp[i] < dp[j] + 1 : dp[i] = dp[j]+1 return max(dp) [instruction] | Given a sequence of numbers, write a program to find the length of the longest subsequence in which all numbers are in increasing order. [input] | arr = [1, 7, 4, 3, 2, 8]

[output] | There are several approaches for the optimization of a neural network, such as backpropagation, gradient descent, genetic algorithms, simulated annealing, particle swarm optimization, evolutionary computation, and stochastic gradient descent. These approaches are used to improve the accuracy and eff [instruction] | What approaches are available for the optimization of a neural network? [input] |

[output] | The error is "Missing Return Statement". [instruction] | Name the error in the example code. [input] | Example Code: def do_math(): num1 = 5 num2 = 3 sum = num1 + num2 return

[output] | shouted [instruction] | Given a sentence, find the first verb in the sentence. [input] | Sentence: She shouted and cheered when she saw her result.

[output] | You can use the sys module’s "getsizeof()" function to check the memory used by an object. The getsizeof() method returns the memory size of the specified object in bytes. For example, sys.getsizeof(data) will return the size of the data object in bytes. [instruction] | How can you check the memory used by a Python object? [input] |

[output] | for i in range(11): print(i) [instruction] | Write a piece of code that runs a loop from 0 to 10, and prints the loop index each time it runs. [input] |

[output] | The command to delete the "example" directory is "rm -r example". [instruction] | What command can be used to delete the "example" directory? [input] |

[output] | list = [1,4,5,7,2] sum = list[0] + list[1] + list[2] #Result: 10 [instruction] | Given a list of integers, calculate the sum of only the first 3 numbers. [input] | List: [1,4,5,7,2]

[output] | exp = re.compile("\d+-\d+") [instruction] | Create a regular expression that verifies the following pattern: contains one or more digits followed by a hyphen followed by one or more digits. [input] |

[output] | long currentTimeMillis = System.currentTimeMillis(); SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm:ss"); Date resultdate = new Date(currentTimeMillis); System.out.println(sdf.format(resultdate)); //Result: Dec 01,2020 13:55:42 [instruction] | Write a Java code snippet to print out the current system time. [input] |

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