← 목록

Synth · CodeAlpaca일부

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

[output] | function printPattern(n) { for (var i = 1; i <= n; i++) { for (var j = 1; j <= i; j++) { document.write(j + " "); } document.write("<br>"); } } printPattern(7); [instruction] | Write a JavaScript function to print a specific pattern. [input] |

[output] | def find_next_prime_numbers(num): """This function takes a number as an input and returns the first two prime numbers after it""" prime_numbers = [] # Increment num to the first prime number while not is_prime(num): num += 1 # Append num to prime_numbers (first prime [instruction] | Using any programming language, write a program which takes a number as an input and outputs the first two prime numbers after it. [input] | 7

[output] | boats\tcars\tplanes [instruction] | Replace the following comma-separated values with tabs. [input] | boats,cars,planes

[output] | def character_frequency(lst): """Function to count the frequency of each character in a list""" frequencies = {} for c in lst: if c in frequencies: frequencies[c] += 1 else: frequencies[c] = 1 return frequencies print(character_frequency(["a", [instruction] | Design a function in Python which takes a list of characters and returns the frequency of each character as a dictionary. [input] | ["a", "b", "c", "a", "a", "b", "d"]

[output] | def replace_e_with_x(s): """Function to replace all instances of the letter "e" with "X""" return s.replace('e', 'X') print(replace_e_with_x("Hello world")) # Output: "HXllo world" [instruction] | Create a program which takes a string and replaces all instances of the letter "e" with "X". [input] | "Hello world"

[output] | public static int[] deleteByThree(int[] arr) { int[] result = new int[arr.length]; int index = 0; for(int i = 0; i < arr.length; i++) { if(arr[i] % 3 != 0) { result[index++] = arr[i]; } } return Arrays.copyOf(result, index); } System.out.println(Arrays.toString(deleteByThree [instruction] | Write a function in Java to delete all numbers from an array which are divisible by three. [input] | [1, 2, 3, 4, 5, 6, 7, 8, 9]

[output] | function avgDate(dates) { let sum = 0; const dateLen = dates.length; for (let i = 0; i < dateLen; i++) { sum += Date.parse(dates[i]); } const avgDate = Date(); avgDate.setTime(sum / dateLen); return avgDate; } console.log(avgDate(["2018-01-01", "2018-01-05", "2018-01-10"])); // [instruction] | Create a JavaScript program which takes an array of dates and returns the average date. [input] | [2018-01-01, 2018-01-05, 2018-01-10]

[output] | SELECT category, product_id, MAX(rating) FROM Products GROUP BY category ORDER BY rating DESC [instruction] | Write a SQL query to find the most popular product by category. [input] | Table name: Products Columns: category (String), product_id (Integer), rating (Integer)

[output] | function sortByColumn3Ascending(array) { array.sort(function(a, b) { return a[2] - b[2]; }); return array; } console.log(sortByColumn3Ascending(array)); [instruction] | Construct a JavaScript program to sort a two-dimensional array by column 3 in ascending order. [input] | const array = [ [7, 0, 5], [3, 2, 1], [2, 5, 9], [0, 6, 8] ]

[output] | public class Fruits { String name; int quantity; String colour; public Fruits(String name, int quantity, String colour) { this.name = name; this.quantity = quantity; this.colour = colour; } } [instruction] | Define a Java class 'Fruits' with three instance variables - name(String), quantity(int), and colour(String). [input] |

[output] | const array = [1, 2, 3, 4]; const sum = array[1] + array[2]; console.log(sum); // 5 [instruction] | Modify the following array to output the sum of the second and third items in the array. [input] | const array = [1, 2, 3, 4];

[output] | def is_multiple_of(num, multiple): if num % multiple == 0: return True return False [instruction] | Write a function to check if an integer is a multiple of another integer. [input] |

[output] | #include <iostream> using namespace std; int findMax(int array[], int array_size) { int max_value = array[0]; for (int i = 1; i < array_size; i++) if (array[i] > max_value) max_value = array[i]; return max_value; } int main() { int array[] = {1, -2, 3, 4, [instruction] | Construct a C++ program to find the maximum value in an array of integers. [input] | int array[] = {1, -2, 3, 4, 7, 5}

[output] | is_ascending <- function(x) { sorted_x <- sort(x) if (sorted_x == x) { return TRUE } else { return FALSE } } [instruction] | Write an R program to check if an array is in ascending order. [input] | x <- c(2, 4, 8, 10, 15)

[output] | public class AddNumbers { public static void main(String[] args) { int a = 3; int b = 5; int sum = a + b; System.out.println("Sum is: " + sum); } } [instruction] | Complete the program written in Java to add two numbers and print out the sum. [input] | int a = 3; int b = 5;

[output] | var express = require("express"); var app = express(); // API to get user details app.get("/user/:id", function(req,res) { var id = req.params.id; var user = { name: "John Doe", age: 30 }; res.status(200).send(JSON.stringify(user)); }); app.listen(3000); [instruction] | Create an API in node.js to get the details of a user using an ID [input] | id = "12345"

[output] | <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Login Form</title> </head> <body> <form> <label>Username:</label> <input type="text" name="username" required> <label>Password:</label> <input type [instruction] | Design a user interface in HTML for a login form. [input] |

[output] | public class Student { private String studentId; private String name; private int age; private String school; private String address; private String phoneNumber; //Getters and Setters public String getStudentId() { return studentId; } public voi [instruction] | Design a data structure in Java for storing student information. [input] |

[output] | import requests # Gets the current temperature from an external API def get_current_temperature(): response = requests.get('https://weather.com/api/current-temperature') response_json = response.json() return response_json['current_temperature'] [instruction] | Implement a web service in Python to retrieve the current temperature from an external API. [input] |

[output] | <!DOCTYPE html> <html> <head> <title>My Web Page</title> </head> <body> <h1>This is my title</h1> <p>This is some content.</p> <button>Click Me!</button> </body> </html> [instruction] | Design a web page in HTML5 with a heading, a paragraph and a button. [input] |

[output] | SELECT MAX(length) FROM Movies; [instruction] | Write an SQL query to find the longest length of movies in a database called "Movies". [input] |

[output] | var getDateInfo = (function() { var today = new Date(); var day = today.getDate(); var month = today.getMonth() + 1; return { day : day, month : month }; })(); module.exports = getDateInfo; [instruction] | Create a JavaScript module to get the current day and month. [input] |

[output] | import math def split_list(a_list): mid_point = int(math.floor(len(a_list) / 2)) first_half = a_list[:mid_point] second_half = a_list[mid_point:] return first_half, second_half [instruction] | Determine what header is needed for the following function. [input] | def split_list(a_list): mid_point = int(len(a_list) / 2) first_half = a_list[:mid_point] second_half = a_list[mid_point:] return first_half, second_half

[output] | for i in range(1, 11): print(i**2) [instruction] | Express the following in a for loop [input] | Print the squares of all the numbers from 1 to 10

[output] | def fibonacci(n): fib_list = [1] if n == 1: return fib_list else: fib_list.append(1) while len(fib_list) < n: fib_list.append(fib_list[-1] + fib_list[-2]) return fib_list [instruction] | Write a function which takes a number and returns the Fibonacci sequence up to that number. [input] | n = 10

[output] | def remove_at_index(my_list, index): del my_list[index] return my_list [instruction] | Develop a program to remove an element from a list at the specified index. [input] | my_list = [4, 5, 6, 7] index = 2

[output] | def swap_elements(my_list, index1, index2): my_list[index1], my_list[index2] = my_list[index2], my_list[index1] return my_list [instruction] | Create a function which swaps the values of two list elements at a specific index. [input] | my_list = [1, 2, 3] index1 = 0 index2 = 2

[output] | def find_max(my_list): max_num = 0 for num in my_list: if num > max_num: max_num = num return max_num [instruction] | Create an algorithm to determine the maximum element in a given list. [input] | my_list = [3, 6, 4, 1]

[output] | def string_format(my_string): my_string = my_string.lower() my_string = my_string.capitalize() return my_string [instruction] | Generate a program to perform string formatting on a given string. [input] | my_string = "Hello, World!"

[output] | def find_index(my_list, element): for i in range(len(my_list)): if my_list[i] == element: return i [instruction] | Develop a function which returns the position of a given element in a list. [input] | my_list = [1, 2, 3, 4] element = 3

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