← 목록

Synth · CodeAlpaca일부

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

[output] | function convertMilesToKilometers(miles) { return miles * 1.60934; } [instruction] | Create a JavaScript function that can convert miles to kilometers. [input] |

[output] | if(n % 2 == 0) { console.log("Number is even!"); } else { console.log("Number is odd!"); } [instruction] | Determine if a number is even or odd using JavaScript. [input] | n = 7

[output] | <table> <tr> <td>Name</td><td>Age</td><td>Gender</td><td>Address</td> </tr> <tr> <td>John Doe</td><td>24</td><td>Male</td><td>123 Main Street</td> </tr> </table> [instruction] | Create a HTML table to present student information. [input] |

[output] | import json data = json.loads(json_string) print(data['name']) [instruction] | Parse this JSON string and print the value of the "name" field. [input] | json_string = '{"name":"John", "age":25}'

[output] | def example_function(a, b): c = 0 for i in range(a, b+1): c += i return c [instruction] | Make changes to this code to fix the bug. [input] | def example_function(a, b): c = 0 for i in range(a, b+1): c -= i return c

[output] | camelCaseString = ''.join(x.capitalize() or '_' for x in snake_case_string.split('_')) [instruction] | Convert this string from snake_case to CamelCase. [input] | snake_case_string = "example_string"

[output] | class Person: def __init__(self, name, age): self.name = name self.age = age def intro(self): print("Hi, my name is %s and I am %d years old." % (self.name, self.age)) [instruction] | Add this method to the Person class. [input] | class Person: def __init__(self, name, age): self.name = name self.age = age

[output] | result = [x*2 for x in list] [instruction] | Create a list comprehension in Python to double each element in the list. [input] | list = [1, 2, 3, 4, 5]

[output] | numbers = [] num = 0 while len(numbers) < 10: num += 1 if (num % 4 == 0) and (num % 7 == 0): numbers.append(num) print(numbers) [instruction] | Find the first 10 numbers that are divisible by 4 and 7 [input] |

[output] | public class Factorial { public static void main(String[] args) { for (int i = 1; i <= 10; ++i) { System.out.println(i + "! = " + factorial(i)); } } public static long factorial(int n) { if (n == 0) return 1; else return [instruction] | Create a Java program to print out factorials from 1 to 10. [input] |

[output] | The information can be stored in a user class using the following structure: class User { string username; string password; string dateOfBirth; string emailAddress; } The information can then be accessed and modified using getter and setter methods. [instruction] | Design a data structure to store user information such as username, password, date of birth and email address. [input] |

[output] | import random results = [] for i in range(10): if random.random() < 0.5: results.append('heads') else: results.append('tails') print(results) [instruction] | Simulate a coin toss in Python and get the results in a list. [input] |

[output] | SELECT customer_id, SUM(cost) AS total_spending FROM orders WHERE order_date >= CURDATE() - INTERVAL 12 MONTH GROUP BY customer_id ORDER BY total_spending DESC LIMIT 5 [instruction] | Create a MySQL query to select the top 5 customers with the highest total spending in the last 12 months. [input] |

[output] | def fahrenheit_to_celsius(f): celsius = (f - 32) * 5/9 return celsius [instruction] | Design a function to convert Fahrenheit to Celsius in Python. [input] |

[output] | def scale(vector): scaled_vector = [] for i in vector: scaled_vector.append(i/10*10) return scaled_vector [instruction] | Scale a vector of 10 numbers from 0 to 10. [input] | [2.5, 3.5, 5.5, 7.5, 1.5, 8.5, 0.5, 4.5, 6.5, 9.5]

[output] | def traverse_tree(node): print(node.data) if node.left: traverse_tree(node.left) if node.right: traverse_tree(node.right) [instruction] | Create a loop to traverse through a tree using depth-first search. [input] |

[output] | def edit_vec(vec): for i in range(len(vec)): if vec[i] <= 5: vec[i] = 5 return vec [instruction] | Edit the vector below such that all elements are greater than five. [input] | [1, 5, 3, 7, 6, 4]

[output] | def calculate(a, b): """This function can be used to calculate the result of two parameters regardless of their type (int, float, etc)""" return a + b [instruction] | Transform the following function definition so it can be used for all type of data [input] | def calculate(int a, int b):

[output] | Hello World [instruction] | Capitalize all the words in a string [input] | hello world

[output] | function longestPalindrome(str) { let longest = ""; for (let i = 0; i < str.length; i++) { let temp = helper(str, i, i); if (temp.length > longest.length) { longest = temp; } temp = helper(str, i, i + 1); if (temp.length > longest.length) { longest = temp; } [instruction] | Write a JavaScript function which will return the longest palindrome string from a given strinb [input] | "abacdaaadccb"

[output] | d3 = {**d1, **d2} [instruction] | Create a new dictionary using the values of two given dictionaries [input] | d1 = {1:10, 2:20} d2 = {3:30, 4:40}

[output] | public int foo(int a, int b) { return a * b; } [instruction] | Convert the given Python code to Java [input] | def foo(a, b): return a*b

[output] | from random import Random def RandomSample(number_of_samples): sample = [] random_generator = Random() for i in range(number_of_samples): sample.append(random_generator.random()) return sample [instruction] | Generate a data set using RandomSample() [input] |

[output] | students = [ { "name": "John Smith", "role": "student" }, { "name": "Alice Johnson", "role": "student" }, { "name": "Bob Williams", "role": "teacher" }, { "name": "Cecilia Brown", "role": "teacher" } ] teachers = [] students_list = [] for student in [instruction] | Rearrange the code to print the hierarchy of students in a Python class [input] | students = [ { "name": "John Smith", "role": "student" }, { "name": "Alice Johnson", "role": "student" }, { "name": "Bob Williams", "role": "teacher" }, { "name": "Cecilia Brown", "role": "teacher" } ]

[output] | ["Cherry", "Banana", "Apple"] [instruction] | Reverse the order of the following list: ["Apple", "Banana", "Cherry"] [input] | ["Apple", "Banana", "Cherry"]

[output] | The sum of all the prime numbers between 45 and 65 is 458. [instruction] | Find the sum of all the prime numbers between 45 and 65. [input] |

[output] | [5, 10, 15, 20, 25, 30, 35] [instruction] | Generate an array of all the multiples of 5 that are less than 40. [input] |

[output] | The regular expression to search for "carrot" in a given string is /carrot/. [instruction] | Write a regular expression to search for the pattern "carrot" in a given string. [input] |

[output] | def same_characters(str1, str2): return sorted(str1) == sorted(str2) [instruction] | Create a program that takes two strings as arguments and returns true if the two strings contain the same characters. [input] |

[output] | The regular expression to search for all occurrences of the substring "cat" in the string is /\bcat\b/g. [instruction] | Using regex, search for all occurrences of the substring "cat" in the following string: [input] | The dog ran away, but the cat stayed

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