← 목록

Synth · CodeAlpaca일부

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

[output] | 1.upto(100) do |i| puts i if i % 5 == 0 end [instruction] | Write a Ruby program to print out all the numbers between 1-100 which are divisible by 5. [input] |

[output] | class Vehicles: def __init__(self, color, price): self.color = color self.price = price [instruction] | Create a class named ‘Vehicles’ with attributes color and price. [input] |

[output] | for i in range(9, 26): print(i) [instruction] | Create a for loop that prints the numbers in the range of 9 to 25 [input] |

[output] | def fibonacci(n): a = 0 b = 1 if n < 0: print("Incorrect input") elif n == 0: return a elif n == 1: return b else: for i in range(2,n): c = a + b a = b b = c return b [instruction] | Create a function ‘fibonacci’ which takes an argument ‘n’ and prints the Fibonacci series up to the nth term. [input] |

[output] | #include<stdio.h> #include<string.h> void reverse_sentence(char *word) { int k; char *c, s[100]; c = word; k = strlen(word); int i = k - 1, j = 0; while (i >= 0) { while (i >= 0 && c[i] != ' ') { s[j++] = c[i--]; } s[j++] = ' [instruction] | Implement an efficient algorithm for reversing a sentence in C. [input] | "This is a sentence."

[output] | public class MaximumPairSum { static int findMaximumPairSum(int arr[]) { int max1 = Integer.MIN_VALUE; int max2 = Integer.MIN_VALUE; int max3 = Integer.MIN_VALUE; int max4 = Integer.MIN_VALUE; for (int i = 0; i < arr.length; i++) { i [instruction] | Find the maximum pair sum of four integers in an array. [input] | [2, 10, -4, 3, 14, 8]

[output] | public class SearchInArray { static int search(int arr[], int n, int x) { for (int i = 0; i < n; i++) { if (arr[i] == x) return i; } return -1; } public static void main(String args[]) { int arr[] = { 1, 2, 3, 4, 5 }; [instruction] | Provide a Java program for searching for a certain element in an array. [input] | [1, 2, 3, 4, 5], element=4

[output] | let str = "This is a sentence."; str = str.substring(0, str.length - 1); console.log(str); [instruction] | Create a script in JavaScript to remove the last character from a given string. [input] | "This is a sentence."

[output] | def cumulative_sum(lst): res = [] sums = 0 for num in lst: sums += num res.append(sums) return res # Example cumulative_sum([1, 2, 3, 4]) # Output: [1, 3, 6, 10] [instruction] | Given a list of numbers, write a function to return a list containing the cumulative sum of all elements in the input list. [input] | [1, 2, 3, 4]

[output] | The binary search algorithm is a divide-and-conquer algorithm that finds a target value in a sorted array by repeatedly dividing the search interval in half. The recursive implementation of the binary search algorithm begins by considering the middle element of the array; if it is the target value, [instruction] | Explain the recursive implementation of the binary search algorithm. [input] |

[output] | def reverse_linked_list(head): if head is None or head.next is None: return head # Get second node current = head.next # Set first node as tail head.next = None # Set next of second node as third node next = current.next while(next): # reverse pointe [instruction] | Given a linked list, write a function to reverse it. [input] |

[output] | The sum of a and b is 15 [instruction] | Compile and Run this program in Python. [input] | a = 10 b = 5 print("The sum of a and b is ", a + b)

[output] | print("The difference of a and b is ", a - b) [instruction] | Change this program to print the difference of a and b [input] | a = 10 b = 5 print("The sum of a and b is ", a + b)

[output] | def segregate_numbers(array): j = 0 for i in range(len(array)): if (array[i] <= 0): array[i], array[j] = array[j], array[i] j+=1 return array [instruction] | Segregate the negative numbers to the left side and positive numbers to the right side of an array. [input] |

[output] | a = 10 b = 5 print("The product of a and b is ", a * b) [instruction] | Edit this program to print the product of two numbers. [input] | a = 10 b = 5 print("The sum of a and b is ", a + b)

[output] | public class SumSquares { public static int sumSquares(int k, int n) { int sum = 0; for(int i = k; i <= n; i++) { if (i % 2 == 0) { sum += (i * i); } } return sum; } } [instruction] | Create a class in Java which computes the sum of squares of even numbers between k and n. [input] |

[output] | Python is a compiled language. //Wrong statement. Python is an interpreted language. [instruction] | Identify the wrong statement. [input] |

[output] | def character_match(str1, str2): match_list = [] for i in range(len(str1)): if str1[i] == str2[i]: match_list.append(str1[i]) return match_list [instruction] | Given a pair of same-length strings, identify character matches in the same position. [input] | str1 = 'Hello' str2 = 'World'

[output] | def printAllKeys(dictionary): if type(dictionary) == dict: for key in dictionary: print(key) printAllKeys(dictionary[key]) [instruction] | Write a function to traverse a dictionary recursively and print all the keys. [input] |

[output] | def compressString(s): comp_string = "" count = 1 for i in range(len(s) - 1): if(s[i] == s[i+1]): count+= 1 else: comp_string += s[i] + str(count) count = 1 comp_string += s[i] + str(count) return comp_string [instruction] | Write a function to compress a string by counting the characters. [input] |

[output] | <body> <head>My Website</head> <div></div> </body> [instruction] | Edit the following markup so that it becomes valid HTML5. [input] | <body> <div><head>My Website</head></div> </body>

[output] | /^[a-zA-Z0-9_\-]+$/ [instruction] | Write a regex expression to validate a username containing only letters, numbers, underscores, and hyphens. [input] |

[output] | p { color: blue; } [instruction] | Write a CSS code that makes the text color blue. [input] |

[output] | for i in range(11): print(i*i) [instruction] | Change the following program so that it prints the squares of numbers from 0 to 10. [input] | for i in range(10): print(i)

[output] | import numpy as np from sklearn.datasets import load_digits from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier # Load the data digits = load_digits() X = digits.data y = digits.target # Split the data X_train, X_test, y_train, y_test = train_tes [instruction] | Train a model to predict the labels of a handwritten digits dataset. [input] |

[output] | import tensorflow as tf # Create array of feature vectors X = tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]) # Create array of labels y = tf.constant([[10.0], [ [instruction] | Create a linear regression model using TensorFlow. [input] |

[output] | string_100 = '' for i in range(100): string_100 += 'x' [instruction] | Create a string of length 100 using a Python loop and save it into a variable named 'string_100'. [input] |

[output] | A simple algorithm to find the maximum value in a given list of integers is to start with the first element and compare it with the subsequent elements. If a larger element is found, update the maximum value and continue comparing. At the end of the loop, the maximum value will hold the maximum valu [instruction] | Describe an algorithm for finding the maximum value in a given list of integers. [input] |

[output] | SELECT * FROM employee WHERE age <= 30; [instruction] | Construct an SQL query to select all employees from the `employee` table whose age is less than or equal to 30. [input] |

[output] | <html> <head> <title>Print Text</title> </head> <body> <input type="text" id="textField" /> <button onclick="printText()">Print</button> <script> function printText(){ let text = document.getElementById("textField").value; console.log(text); } </ [instruction] | Create an HTML page with a button and a text field to print the content of the text field when the button is clicked. [input] |

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