← 목록

Synth · CodeAlpaca일부

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

[output] | def determine_triangle_type(triangle_sides): if triangle_sides[0] == triangle_sides[1] and triangle_sides[1] == triangle_sides[2]: return 'equilateral' elif triangle_sides[0] == triangle_sides[1] or triangle_sides[1] == triangle_sides[2] or triangle_sides[2] == triangle_sides[0]: [instruction] | Create a program to determine the type of triangle given 3 side lengths [input] | [5, 4, 3]

[output] | int num1 = 0, num2 = 1, fibo = 0; while(fibo <= 10) { fibo = num1 + num2; num1 = num2; num2 = fibo; System.out.print(fibo +" "); } [instruction] | Create a while loop in Java to calculate the Fibonacci numbers up to the number 10. [input] |

[output] | let stringLength = "Hello World".length; console.log(stringLength); // output 11 [instruction] | Using only JavaScript, determine the length of a given string "Hello World". [input] |

[output] | SELECT * FROM Employees WHERE age BETWEEN 25 and 30 AND department = 'Marketing'; [instruction] | Write a query to find all employees whose age is between 25 and 30 and whose department is Marketing. [input] |

[output] | <button onclick="alert('Hello World!')"> Click me! </button> [instruction] | Using HTML, create a button that displays a message when clicked. [input] |

[output] | \b[A-Z]\w+ [instruction] | Construct a regex statement to select all words starting with a capital letter. [input] |

[output] | SELECT COUNT(*) FROM library_catalog; [instruction] | Write a SQL query to find the count of all the books listed in a library catalog. [input] |

[output] | """ Create a method to sort a given array of integers without using any of the built-in sorting functions in JavaScript Input: array = [5, 4, 3, 2, 1] """ // bucket sort function bucketSort(arr) { let buckets = new Array(arr.length); let result = []; for (let i = 0; i < arr.length; i++) [instruction] | Create a method to sort a given array of integers without using any of the built-in sorting functions in JavaScript. [input] | array = [5, 4, 3, 2, 1]

[output] | """ Write a code to get the current exchange rate between two currency using the OpenExchangeRates API. Input: fromCurrency = "USD" toCurrency = "GBP" """ import requests import json def get_exchange_rate(fromCurrency, toCurrency): baseUrl = 'https://openexchangerates.org/api/latest.j [instruction] | Write a code to get the current exchange rate between two currency using the OpenExchangeRates API. [input] | fromCurrency = "USD" toCurrency = "GBP"

[output] | """ Create a method which receives a list of names and outputs the name which occurs the most in that list. Input: list = ['Jon', 'Arya', 'Jon', 'Tyrion', 'Cersei', 'Jon'] """ def getMostFrequent(list): frequency = dict() holder = None max_count = 0 for name in list: if na [instruction] | Create a method which receives a list of names and outputs the name which occurs the most in that list. [input] | list = ['Jon', 'Arya', 'Jon', 'Tyrion', 'Cersei', 'Jon']

[output] | """ Create a JavaScript code that takes a number as input and returns its factorial. Input: num = 5 """ function factorial(num) { if (num === 0) { return 1; } else { return num * factorial(num-1); } } console.log(factorial(5)) [instruction] | Create a JavaScript code that takes a number as input and returns its factorial. [input] | num = 5

[output] | """ Create a code in Python to get the current stock price of a company from yahoo finance. Input: ticker = "AAPL" """ import requests def get_stock_price(ticker): url = 'https://finance.yahoo.com/quote/' + ticker response = requests.get(url) data = response.text.split('"regularMarket [instruction] | Create a code in Python to get the current stock price of a company from yahoo finance. [input] | ticker = "AAPL"

[output] | """ Create a method to join an array of strings together. Input: arr = ['one', 'two', 'three'] """ function joinStrings(arr) { let joinedStr = ''; for (let i = 0; i < arr.length; i++) { joinedStr += arr[i] if (i < arr.length - 1) { joinedStr += ' '; } } return joine [instruction] | Create a method to join an array of strings together. [input] | arr = ['one', 'two', 'three']

[output] | for i in range(1, 6): print(i) [instruction] | Edit the code so it displays the numbers 1 to 5. [input] | for i in range(2, 10): print(i)

[output] | def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) [instruction] | Calculate the factorial of n using a recursive function. [input] |

[output] | def has_pair_with_sum(arr, k): temp_set = set() for i in range(len(arr)): temp = k - arr[i] if temp in temp_set: return True temp_set.add(arr[i]) return False [instruction] | Given the following array and a number k, write a program to determine if it contains a pair of numbers that add up to k. [input] | arr = [1, 2, 3, 4, 5] k = 7

[output] | Chicago residents face treacherous icy streets during the month of January due to average daily temperatures below zero degrees Celsius. [instruction] | Summarize the following text using an algorithm. [input] | The average daily temperature in Chicago during the month of January is usually below zero degrees Celsius. As such, the streets become icy and treacherous for the residents.

[output] | def perimeter(a, b, c): return a + b + c [instruction] | Write the definition of function to calculate the perimeter of a triangle. [input] |

[output] | Machine learning is the process of teaching a machine to recognize patterns in data and make decisions based on those patterns. It involves feeding a machine large amounts of data, which it can then use to learn, develop and form predictions based on patterns it identifies. [instruction] | Explain what is meant by the term ‘machine learning’. [input] |

[output] | Big data analysis can provide companies with data-driven insights that can be used to improve services and products. By accurately analyzing customer trends, companies can build targeted marketing campaigns and make decisions on which services and products to focus on, helping them reach their desir [instruction] | How could Big data analysis be used to provide better services and products ? [input] |

[output] | #include <stdio.h> int main() { int i, j, k, rows; printf("Enter the number of rows \n"); scanf("%d",&rows); for(i=1; i<=rows; i++ ) { for(k=rows; k >= i; k--) printf(" "); for(j=1; j<= (2*i-1) ; j++ ) printf("*"); printf("\n"); } return 0; } [instruction] | Develop a C program to print a pattern like a pyramid. [input] |

[output] | My approach to sorting a variety of data would involve using a single sorting algorithm. Depending on the type of data, I would select the most appropriate sorting algorithm which would involve understanding the complexity of the data and the type of sorting required. Generally, I would use quick so [instruction] | Describe your approach to sorting a variety of data with a single sorting algorithm. [input] |

[output] | #include <stdio.h> int main() { int length, width; printf("Enter the length : "); scanf("%d", &length); printf("Enter the width : "); scanf("%d", &width); printf("The Perimeter of rectangle is : %d \n", 2*(length + width)); printf("The Area of rectangle is : %d \n [instruction] | Edit a program to show the area of the rectangle [input] | #include <stdio.h> int main() { int length, width; printf("Enter the length : "); scanf("%d", &length); printf("Enter the width : "); scanf("%d", &width); printf("The Perimeter of rectangle is : %d \n", 2*(length + width)); return 0; }

[output] | class NoMenuItemsError(Exception): def __init__(self, message): super().__init__(message) self.message = message def raise_error(): raise NoMenuItemsError("No menu items are available") [instruction] | Create a custom exception class for a restaurant that has no menu items. [input] |

[output] | def get_char_count(string): char_count = {} for char in string: if char not in char_count: char_count[char] = 1 else: char_count[char] += 1 return char_count [instruction] | Create a dictionary in which keys are characters and values are the occurences of that character in a given string. [input] | string = "apple"

[output] | def calculate_paths(matrix): rows = len(matrix) cols = len(matrix[0]) dp = [[0 for _ in range(cols)] for _ in range(rows)] dp[0][0] = 1 for i in range(rows): for j in range(cols): if i-1 >= 0: dp[i][j] = dp[i][j] + dp[i-1][j] [instruction] | Write a function to calculate all the possible paths for a N x N matrix. [input] |

[output] | import random def init_matrix(): matrix = [[0 for _ in range(10)] for _ in range(10)] for i in range(len(matrix)): for j in range(len(matrix[0])): matrix[i][j] = random.randint(0,100) return matrix [instruction] | Write a Python code to initialize a 10 x 10 matrix with random values. [input] |

[output] | Recursive approach is an approach wherein a problem is broken down into multiple subproblems until the base case is reached. Once the base case is reached, the results of each sub-problem are combined to obtain a solution to the original problem. It is used when the problem exhibits the self-similar [instruction] | Describe the recursive approach for solving a problem. [input] |

[output] | function toPigLatin(str) { const vowels = ['a', 'e', 'i', 'o', 'u']; let result = ''; str.split(' ').forEach(word => { if (vowels.includes(word[0])) { result += `${word}ay `; } else { result += `${word.substring(1)}${word[0]}ay `; } }); return result; } [instruction] | Create a JavaScript function to convert a string to pig-latin. [input] |

[output] | import React from 'react' const AlertMessage = () => { return ( <div className="alert-message"> <p>This is an alert message!</p> </div> ) } export default AlertMessage; [instruction] | Using React, create a component to display an alert message. [input] |

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