← 목록

Synth · CodeAlpaca일부

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

[output] | def is_perfect(n): s = 0 for i in range(1, n): if n % i == 0: s += i return s == n [instruction] | Write a Python function to check if a number is perfect or not. A number is said to be a perfect number if its sum of divisors is equal to itself. [input] |

[output] | list(filter(lambda x: (x % 5 == 0), mylist)) [instruction] | Use the Python built-in function filter() to find all numbers divisible by 5. [input] | mylist = [10, 21, 32, 45, 56, 77]

[output] | low = 0 high = number answer = (high + low) / 2 #Store the difference between the answer and the number diff = (answer ** 2) - number #Loop until the difference is within a very small tolerance while abs(diff) > 0.00001: if diff > 0: #the answer is too high high = answer else [instruction] | Calculate the square root of a number using bisection search. [input] | number = 9

[output] | 4:47 PM [instruction] | Convert this time to the 12-hour time format. [input] | 16:47

[output] | <?php foreach($myArray as $item) { echo "I like " . $item . "<br>"; } ?> [instruction] | Create a for loop in PHP to iterate over an array and output a result for each item. [input] | myArray = ["apple", "banana", "pear"]

[output] | ^\d{4}$ [instruction] | Create a regular expression pattern to detect valid 4-digit numeric codes [input] |

[output] | SELECT * FROM employees [instruction] | Complete the following code to fetch data from the "employees" table using an SQL query. [input] | SELECT * FROM

[output] | i = 1 while i <= 10: print(i) i += 1 [instruction] | Construct a loop to print numbers from 1 to 10 using a while loop in Python. [input] |

[output] | for i in {1..3}; do for num in $(seq 0 10); do echo "$num" done done [instruction] | Write a Bash script that prints numbers from 0 to 10 three times. [input] |

[output] | <html> <head> <title>Example</title> </head> <body> <h1>Heading</h1> <p>Paragraph 1</p> <p>Paragraph 2</p> </body> </html [instruction] | Design an HTML page using standard HTML tags which contains a heading and two paragraphs [input] |

[output] | ^g\w+ [instruction] | Change the following regular expression so that it matches terms beginning with 'g' [input] | ^g

[output] | sentence_input = "This is a sample sentence." def count_keyword(sentence_input, keyword): return sentence_input.lower().count(keyword.lower()) count = count_keyword(sentence_input, "sentence") print("The word 'sentence' occurs " + str(count) + " times.") [instruction] | Create a Python script that find the number of occurrences of a specific word in a given sentence. [input] | This is a sample sentence.

[output] | <html> <head> <title>Example</title> </head> <body> <div> <input type="text" id="input"> <button type="submit" onclick="output()">Submit</button> </div> <div id="output"></div> <script> function output() { [instruction] | Design a simple HTML page using standard HTML tags which contains an input box, a button and an output section [input] |

[output] | div { border: 2px solid blue; } [instruction] | Create a CSS program to apply a blue border to all <div> elements [input] |

[output] | class BinarySearchTree: def __init__(self, value): self.left = None self.right = None self.value = value def inorder(self): if self.left: self.left.inorder() print(self.value) if self.right: self.right.inorder() [instruction] | Make a class in Python which will represent a binary search tree. [input] |

[output] | function kthSmallest(arr, k) { // Sort the array arr.sort((a, b) => a - b); // Return kth element in the sorted array return arr[k - 1]; } [instruction] | Design a solution in JavaScript to find the kth smallest element in an unsorted array. [input] | arr = [8, 5, 7, 2, 3, 1, 9, 4] k = 3

[output] | def palindromicSubstrings(string): for start in range(len(string) + 1): for end in range(start + 1, len(string) + 1): substring = string[start:end] if substring == substring[::-1]: print(substring) palindromicSubstrings(string) [instruction] | Change the following Python program so that it prints out the palindromic substrings. [input] | string = 'mom'

[output] | #include <stdio.h> #include <string.h> // Fills frequency array with zero void clear(int count[], int n) { int i; for (i = 0; i < n; i++) count[i] = 0; } // Calculate frequency of each character // in a string void calculateFrequency(char *str, int count[], int len) { int i; for (i [instruction] | Rewrite the following C program so that it prints the frequency of each character in a given string. [input] | string = "abcabcabc"

[output] | #include <iostream> using namespace std; int max_sum(int arr[], int n) { if (n == 0) return 0; int max = arr[0]; int sum = arr[0]; for (int i = 1; i < n; i++) { if (arr[i] < 0) return 0; sum = max(sum + arr [instruction] | Change the following C++ program so that it returns 0 if an array contains all negative numbers. [input] | arr = [-2, -3, -4, -1]

[output] | myList.sort() print(myList) [instruction] | Sort a given list of numbers and print the result. [input] | myList = [9, 2, 5, 1, 8]

[output] | print(myArray[0]) [instruction] | Print the first element of a given array. [input] | myArray = [20, 45, 70, 95]

[output] | s = sum(array) print(s) [instruction] | Sum the elements of a given array and print the result. [input] | array = [2, -7, 4, 5]

[output] | def get_integer_between(start, end): return list(range(start, end + 1)) print(get_integer_between(start, end)) [instruction] | Write a code to return the list of integers between two given numbers. [input] | start = 5 end = 9

[output] | mulp = 1 for i in myList: mulp = mulp * i print(mulp) [instruction] | Multiply every element of a list and print the result. [input] | myList = [3, 4, 5]

[output] | CREATE TABLE customers ( id INTEGER NOT NULL AUTO_INCREMENT, name VARCHAR(255), address VARCHAR(255), email VARCHAR(255), PRIMARY KEY (id) ); CREATE TABLE items ( id INTEGER NOT NULL AUTO_INCREMENT, name VARCHAR(255), price DECIMAL(8,2), PRIMARY KEY (id) ); CREATE TABLE purchases ( id [instruction] | Design a database schema for a retail store that tracks customers, purchases, and items. [input] |

[output] | SELECT * FROM employees WHERE name = '<employee_name>'; [instruction] | How do you create a MySQL query to find a specific employee by their name in a table named 'employees'? [input] |

[output] | public static String[] filterArray(String[] array, int n) { List<String> filteredArray = new ArrayList<String>(); for (int i = 0; i < array.length; i++) { if (i < n) { filteredArray.add(array[i]); } } String[] newArray = new String[filteredArray.size()]; [instruction] | Given an array of strings and an integer, write a function in Java to return a new array that contains the strings at each index less than the specified integer. [input] | String[] array = {"one", "two", "three", "four", "five"}; int integer = 3;

[output] | def getDay(num): days = { 0: 'Monday', 1: 'Tuesday', 2: 'Wednesday', 3: 'Thursday', 4: 'Friday', 5: 'Saturday', 6: 'Sunday', } return days[num] [instruction] | Create a function in Python that takes a number as an argument and displays the corresponding day from Monday to Sunday. [input] |

[output] | A deep copy of an object can be obtained by using the Object.clone() method or by serializing and deserializing the object. [instruction] | In Java, what is a good way to make a deep copy of an object? [input] |

[output] | df.loc[(condition1) | (condition2)] [instruction] | What is the syntax for filtering a DataFrame using an OR condition in Pandas? [input] |

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