← 목록

Synth · CodeAlpaca일부

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

[output] | def is_prime(x): if x < 2: return False for n in range(2, x - 1): if x % n == 0: return False return True [instruction] | Create a function to test if an integer is prime or not. [input] |

[output] | #include <iostream> using namespace std; void merge(int arr[], int l, int m, int r) { int i, j, k; int n1 = m - l + 1; int n2 = r - m; int L[n1], R[n2]; for (i = 0; i < n1; i++) L[i] = arr[l + i]; for (j = 0; j < n2; j++) R[j] = arr[m + 1+ [instruction] | Implement Merge Sort algorithm in C++ [input] |

[output] | import tensorflow as tf from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Activation model = Sequential() model.add(Dense(64, input_dim = 8)) model.add(Activation('relu')) model.add(Dense(16)) model.add(Activation('sigmoid')) model.add(Dense(2)) model.add(Ac [instruction] | Generate a classification network in a deep learning framework. [input] |

[output] | 1. Replace <?xmlns> element with <html> 2. Replace <xml> tag with <head> 3. Add a <meta> tag inside the <head> tag containing the charset UTF-8 and the content type text/html 4. Replace all <body> elements with <div> elements 5. Replace all <title> elements with <h1> elements 6. Replace all <ul> ele [instruction] | Create a set of transformation rules to convert a valid XML document to a valid HTML document. [input] |

[output] | import statistics def calculate_std_dev(nums): return statistics.stdev(nums) [instruction] | You are given a list of numbers and you need to calculate the standard deviation of the numbers. [input] | [1, 2, 3, 4, 5]

[output] | The variables are x, y, z, a, b, and c. [instruction] | Read the code and determine all the variables that have been declared or used. [input] | def func(x, y, z): a = x + y + z b = x * y * z c = a / b

[output] | def find_unique_combinations(items): result = [] for i in range(1, len(items) + 1): for combination in itertools.combinations(items, i): result.append(list(combination)) return result [instruction] | We need to find all unique combinations of elements from a given list of items. [input] | [1, 2, 3, 4]

[output] | def generate_permutations(s): results = [] if len(s) == 1: results.append(s) else: for i, c in enumerate(s): for perm in generate_permutations(s[:i] + s[i + 1:]): results.append(c + perm) return results [instruction] | We need to write a program to generate all permutations of a given string. [input] |

[output] | def clear_line_breaks(s): return s.replace("\n", "") [instruction] | You are given a string and you need to clear the line breaks. [input] | "This is a test string"

[output] | def product_of_array(arr): prod = 1 for i in arr: prod *= i return prod [instruction] | We need to build a function to compute the product of the elements of a given array. [input] | [1, 2, 3, 4, 5]

[output] | def find_max(arr): maximum = arr[0] for i in arr[1:]: if i > maximum: maximum = i return maximum [instruction] | We need to find the maximum element in a given array of numbers. [input] | [1, 2, 3, 4, 5]

[output] | def intersect(list1,list2): return [i for i in list1 if i in list2] [instruction] | Create a python function which finds the intersection of two lists [input] | list1=[2, 5, 8, 10] list2=[3, 5, 8, 10]

[output] | def character_at_index(astring): if len(astring) > 4: print(astring[4]) [instruction] | Write a python program that takes a string as a parameter and prints the character at index 4 if the length of the string is greater than 4. [input] | astring = "Python"

[output] | class Student: def __init__(self, name, marks): self.name = name self.marks = marks def get_details(self): return self.name + ": " + str(self.marks) [instruction] | Create a python class that stores the name of the student, their total marks and return the student name with their total marks. [input] | name = 'John' marks = 75

[output] | if num < 10: print("num is less than 10") [instruction] | Write an if statement that checks if an integer, num, is less than 10. [input] | num = 7

[output] | def countWords(word_string): words = word_string.split() count_dict = {} for word in words: count_dict[word] = words.count(word) return count_dict [instruction] | Create a program to take a string of words and return the count of each word. [input] | word_string = "This is a sentence of words"

[output] | def isRotation(string1, string2, length1, length2): if length1 == length2 and len(string1)>0: string1string1 = string1 + string1 return string2 in string1string1 [instruction] | Create a function that takes two strings's, two string length's and returns true if the second string is a rotation of the first. [input] | string1 = "Hello World" string2 = "WorldHello" length1 = 11 length2 = 11

[output] | def getCharactersFromEnd(string, n): return string[-n:] [instruction] | Create a function that takes a string and a number n, then return n characters from the end of the string. [input] | string = "Hello World" n = 3

[output] | SELECT * FROM Customers; [instruction] | Write a SQL query to get the details of all Customers from the database. [input] |

[output] | Methods available in axelrod Python library are constructor method, player_names method, init method, play method, get_history method, reset method, sign_string method, find_conformers method, oppose_strategy method, strategy method, final_score method, cooperation method, defect method, normalised_ [instruction] | List all the methods available in axelrod python library [input] |

[output] | P(A|B) = P(B|A) * P(A) / P(B) = 0.8 * 0.4 / 0.7 = 0.5714286 [instruction] | Compute P(A | B) given that P(B | A) = 0.8, P(A) = 0.4, and P(B) = 0.7 [input] |

[output] | Can you please explain what you mean when you say "I don't know"? [instruction] | Prompt a clarification from the user when the reply provided is unclear [input] | Input Reply: I don't know

[output] | x = (-8 ± √-112) / (2 × 3) = (-8 ± 4√7) / 6 = (-2 ± 2√7) / 3 [instruction] | Solve the quadratic equation 3x^2 + 8x + 4 = 0 [input] |

[output] | def mergeSortedSubarrays(ar1, ar2): # if ar1 is empty if len(ar1) == 0: return ar2 # if ar2 is empty if len(ar2) == 0: return ar1 # compare the first elements of each array if ar1[0] < ar2[0]: # add the smaller element to the result [instruction] | Given an array of integers, write a recursive program to merge two sorted subarrays ar1 and ar2 [input] | ar1 = [1, 4, 7, 9] ar2 = [2, 5, 6, 8]

[output] | total = 0 for ch in 'Python': total += ord(ch) print(total) # Output: 686 [instruction] | Calculate the sum of all characters in a string using a for loop [input] | String: Python

[output] | 9 / \ 5 11 / / \ 1 7 16 [instruction] | Construct a binary search tree from a list of given items [input] | Items: [1, 5, 7, 9, 11, 16]

[output] | def permutations(string): if len(string) <= 1: return set([string]) # get the last character last_char = string[-1] # get all permutations for the remaining characters all_permutations = permutations(string[:-1]) # create permutations for including the last charact [instruction] | Implement an algorithm to generate the permutations of a string [input] |

[output] | import json def json_parser(string): data = json.loads(string) return data [instruction] | Write a Python parser to parse the json string to a dictionary. [input] | {"name": "John", "age": 23}

[output] | def sort_by_last_digit(list): return sorted(list, key=lambda x: x % 10) [instruction] | Suggest a code that sort a list by the last digit of each element. [input] |

[output] | def generate_sequence(starting_number, step): num = starting_number while True: yield num num += step [instruction] | Suggest a completion for the following code that generates a sequence of integers. [input] | def generate_sequence(starting_number, step):

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