← 목록

Synth · CodeAlpaca일부

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

[output] | query { products { id name price quantity category } } [instruction] | Create a GraphQL query to get the list of products from a database. [input] |

[output] | [ 'email10@example.com', 'email11@example.com', 'email12@example.com', 'email13@example.com', 'email14@example.com', 'email15@example.com', 'email16@example.com', 'email17@example.com', 'email18@example.com', 'email19@example.com', 'email20@example.com', [instruction] | Generate a list of email addresses using the given range. [input] | Range: 10-100

[output] | Area = pi * r^2 Area = 3.14 * 8^2 Area = 201.06 cm^2 [instruction] | Find the area of the following circle [input] | Radius: 8 cm

[output] | class Person: def __init__(self, name, age, gender): self.name = name self.age = age self.gender = gender def get_details(self): return f"Name: {self.name}, Age: {self.age}, Gender: {self.gender}" [instruction] | Implement a class to create an object with the given characteristics [input] | Characteristics: Name, Age, Gender

[output] | CREATE TABLE medical_records ( record_id INT AUTO_INCREMENT PRIMARY KEY, patient_name VARCHAR(255) NOT NULL, doctor VARCHAR(255) NOT NULL, diagnosis TEXT, test_results TEXT, notes TEXT ); [instruction] | How would you set up a database table to store medical records [input] |

[output] | def calculate_sum(numbers): total = 0 for num in numbers: total += num return total numbers = [2, 3, 5] result = calculate_sum(numbers) print(f'Sum of {numbers} is {result}.') [instruction] | Fix the bug in the following code that causes the output to be incorrect. [input] | def calculate_sum(numbers): total = 0 for num in numbers: total += num return total numbers = [2, 3, 5] result = calculate_sum(numbers) print(f'Sum of {numbers} is {result}')

[output] | nums = [1,2,3,4,5] i = 0 while i < len(nums): print(nums[i]**2) i = i + 1 [instruction] | Take the following code and convert it from a for loop to a While loop. [input] | nums = [1,2,3,4,5] for num in nums: print(num**2)

[output] | def number_to_word(n): tens_words = { 0: '', 2: 'twenty', 3: 'thirty', 4: 'forty', 5: 'fifty', 6: 'sixty', 7: 'seventy', 8: 'eighty', 9: 'ninety', } ones_words = { 1: 'one', 2: 'two', 3: 'thre [instruction] | Write a code that takes a number and prints it out in words. [input] | 25

[output] | def sum_numbers(numbers): total = 0 for num in numbers: total += num return total print(sum_numbers(numbers)) [instruction] | Take the following array and add up all of the numbers [input] | numbers = [4,15,7,10,45]

[output] | def reverse_string(string): return string[::-1] print(reverse_string('hello')) [instruction] | Write a Python code take a given string and return the string in reverse. [input] | hello

[output] | def find_longest_substring(list1, list2): string1 = list1[0] string2 = list2[0] min_length = min(len(string1), len(string2)) longest_substring = "" for i in range(min_length): if string1[i] == string2[i]: longest_substring += string1[i] else: [instruction] | Write a code that takes two lists and find the longest common starting substring [input] | list1 = ['cat', 'car', 'camel'] list2 = ['carry', 'cap', 'caterpillar']

[output] | import re def replace_non_alphanum(string, character): return re.sub(r'\W', character, string) string = 'Hello, world!' character = '#' print(replace_non_alphanum(string, character)) [instruction] | Write a Python code that takes a string and replace all the non-alphanumeric characters with a given character. [input] | string = 'Hello, world!' character = '#'

[output] | def common_elements(list1, list2): return set(list1).intersection(list2) list1 = [1, 2, 3, 4, 5] list2 = [2, 4, 6, 8, 10] print(common_elements(list1, list2)) [instruction] | Identify common elements between two given lists [input] | list1 = [1, 2, 3, 4, 5] list2 = [2, 4, 6, 8, 10]

[output] | def multiply_elements(numbers, multiply): new_list = [] for num in numbers: new_list.append(num * multiply) return new_list numbers = [2, 4, 6] multiply = 5 print(multiply_elements(numbers, multiply)) [instruction] | Generate a new list from an old list by multiplying each element of the old list with a given number [input] | numbers = [2, 4, 6] multiply = 5

[output] | def sort_alphabetical(words): return sorted(words) words = ['daisy', 'apple', 'cat', 'zebra'] print(sort_alphabetical(words)) [instruction] | Take the following list of words and return the words in alphabetical order [input] | words = ['daisy', 'apple', 'cat', 'zebra']

[output] | for item in some_list: print("{:>20}".format(item)) [instruction] | Find the code snippet to format the output of a List. [input] |

[output] | for i in range(1, 10): print(i) [instruction] | Select the correct code for a for-loop for a sequential array of numbers. [input] |

[output] | x = float(5) [instruction] | Modify the code to declare a variable as a float. [input] | x = 5

[output] | def delete_element(list1, pos): del list1[pos] print("After deleting the element at position {0} the list is: {1}".format(pos, list1)) delete_element(my_list, pos) [instruction] | Delete the elements at a specified position of the given list. [input] | my_list = [1, 2, 3, 4, 5] pos = 3

[output] | def remove_duplicates(list): # sort the list list.sort() new_list = [] for element in list: if element not in new_list: new_list.append(element) return new_list [instruction] | What command should be added to the function to make sure the input list is sorted? [input] | def remove_duplicates(list): # TODO: add command new_list = [] for element in list: if element not in new_list: new_list.append(element) return new_list

[output] | num = 20 while num >= 0: print(num) num -= 1 [instruction] | Write a while loop to print all numbers from 20 to 0. [input] |

[output] | def maximum_of_three(x, y, z): if x > y and x > z: max = x elif y > x and y > z: max = y else: max = z return max [instruction] | Write a code to find the maximum of three numbers using if else. [input] |

[output] | def find_max(list): # base condition if len(list) == 1: return list[0] else: # compare the current element to the next element max_element = max(list[0], list[1]) # remove the compared element list.pop(1) # call the function on the remaini [instruction] | Generate a recursive function for the following task: [input] | Given a list of integers, "find the max element present in the list".

[output] | class Employee: def __init__(self, name, salary, id_number): self.name = name self.salary = salary self.id_number = id_number [instruction] | Create a class to represent an Employee, which includes a name, salary, and ID number [input] |

[output] | Yes [instruction] | What should be the output for the given code? [input] | a = 7 b = 2 if a % b == 0: print("Yes") else: print("No")

[output] | array = [1, 2, 3, 4, 7] [instruction] | You are passed an array and a value. Write a Python program to insert the value in the array at the end. [input] | array = [1, 2, 3, 4], value = 7

[output] | def get_freq_table(string): char_freq_dict = dict() for char in string: if char in char_freq_dict.keys(): char_freq_dict[char] += 1 else: char_freq_dict[char] = 1 print ("Frequency table of given string is : \n",char_freq_dict) get_freq_tabl [instruction] | Create a function in Python that takes a string and prints the frequency table of all its characters. [input] | string = “Hello world"

[output] | #include <iostream> using namespace std; // Function to find maximum and minimum of an array void minMax(int arr[], int n) { int max = arr[0]; int min = arr[0]; for (int i = 1; i < n; i++) { if (arr[i] > max) max = arr[i]; if (arr[i] < min) [instruction] | Create a program in C++ to find the max and min of an array of fixed size. [input] | array = [3, 5, 8, 6, 10, 1]

[output] | #!/bin/bash for num in {0..100} do echo "$num" done [instruction] | Create a bash script that prints out a sequence of numbers between 0 and 100. [input] |

[output] | public class Main { public static void main(String[] args) { System.out.println(10 % 3); } } [instruction] | In the given Java program replace the line number 3 with a line that outputs the remainder of dividing 10 by 3. [input] | public class Main { public static void main(String[] args) { // Code to be replaced } }

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