← 목록

Synth · CodeAlpaca일부

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

[output] | public class StringSort { public static void sortStringArray(String[] arr) { // Sorting strings Arrays.sort(arr); // Displaying the strings after sorting System.out.println("Strings in sorted order: "); for (int i = 0; i < arr.length; i++) [instruction] | Construct a program in Java to sort an array of String objects. [input] |

[output] | import tweepy CONSUMER_KEY = 'XXXXXXXXXXXXXXXXXXX' CONSUMER_SECRET = 'XXXXXXXXXXXXXXXXXXX' ACCESS_TOKEN = 'XXXXXXXXXXXXXXXXXXX' ACCESS_TOKEN_SECRET = 'XXXXXXXXXXXXXXXXXXXX' # authenticating auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_ [instruction] | Construct a data mining program to mine public internet data. [input] | Twitter datasets

[output] | function remainder(a, b) { return a % b; } [instruction] | Give a function name in JavaScript that takes in two integer numbers as parameters and returns the remainder of the first parameter divided by the second. [input] |

[output] | for(int i=10; i>0; i--) cout << i << " "; [instruction] | Develop a C++ code to print the numbers 1 to 10 in descending order. [input] |

[output] | <link rel="stylesheet" type="text/css" href="style.css" /> [instruction] | Write a code snippet in HTML to include an external style sheet in web page. [input] |

[output] | In Java, threads can be in one of the following states: NEW, RUNNABLE, BLOCKED, WAITING, TIMED_WAITING or TERMINATED. The NEW state means that the thread has been created but not yet started. RUNNABLE means that the thread is running. BLOCKED means that the thread is waiting to acquire a lock. WAITI [instruction] | Describe the different thread states in Java programming. [input] |

[output] | #include <stdio.h> int main() { int length = 10; int width = 15; int area; area = length * width; printf("The area is %d.", area); return 0; } [instruction] | Compile a C program that calculates the area of a rectangle from the given values of length and width. [input] | Length = 10 Width = 15

[output] | In Java, there are four types of inheritance supported: single inheritance, multiple inheritance, hierarchical inheritance, and socioeconomic inheritance. Single inheritance means a class extends only one class. Multiple inheritance is when a subclass extends multiple superclasses. Hierarchical inhe [instruction] | List the types of inheritance supported in Java. [input] |

[output] | In JavaScript, an event is an action that a user performs that causes a change in the state of the program. Events can be generated by a user (e.g. pressing a button, clicking a link), by the browser (e.g. loading a page, scrolling, resizing the window) or by the system (e.g. device orientation chan [instruction] | What is an event in JavaScript? [input] |

[output] | def isAnagram (str1, str2): # Get length of both strings n1 = len(str1) n2 = len(str2) # If length is not same, then strings are not anagrams if n1 != n2: return False # Sort both strings str1 = sorted(str1) str2 = sorted(str2) # Compare [instruction] | You need to develop a code that takes two strings and returns a boolean if the substrings are anagrams. [input] | Strings: "computer" and "computer"

[output] | def rot13(message): output = [] for char in message: char_code = ord(char) if char_code >= ord('A') and char_code <= ord('Z'): # Rotate lower case characters char_code += 13 if char_code > ord('Z'): char_code -= 26 e [instruction] | Develop a function to encode a text string in a ROT13 manner. [input] | String: "Hello World"

[output] | O(n). [instruction] | Write the Big O time complexity of the given algorithm. [input] | Algorithm: Finding the value at a given index of an unordered array.

[output] | def edit_distance(str1, str2): n1 = len(str1) n2 = len(str2) dp = [[0 for x in range(n2 + 1)] for x in range(n1 + 1)] for i in range(n1 + 1): for j in range(n2 + 1): if i == 0: dp[i][j] = j elif j == 0: dp[i][j [instruction] | Given two strings, develop a function to calculate edit distance between them. [input] | Strings: "kitten" and "sitting"

[output] | def is_palindrome(input_string): # Convert string to lower case to ignore capitalization. input_string = input_string.lower() # Reverse input string rev_string = reversed(input_string) # Check if strings are equal or not if (list(input_string) == list(rev_string)): [instruction] | You need to develop a function which checks if a given string is palindrome or not. [input] | String: "redder"

[output] | SELECT title, COUNT(*) AS num_readers FROM books LEFT JOIN readers ON books.id = readers.book_id GROUP BY title ORDER BY num_readers DESC LIMIT 10; [instruction] | Create a SQL query to return the top 10 most popular books. [input] |

[output] | import React from 'react'; import Axios from 'axios'; class App extends React.Component { constructor(props) { super(props); this.state = { data: [], }; } async componentDidMount() { const res = await Axios.get(<api_url>) this.se [instruction] | Create a React app that loads data from a given REST API endpoint. [input] |

[output] | const rp = require('request-promise'); const cheerio = require('cheerio'); async function getTrendingContent(){ const options = { uri: '<url>', }; let trendingContent = []; const htmlResult = await rp(options); const $ = await cheerio.load(htmlResult); const a [instruction] | Write a Node.js program which fetches the top 10 trending news from a given website. [input] |

[output] | def bubble_sort(list): for i in range(len(list)): for j in range(len(list)-1-i): if list[j] > list[j+1]: list[j], list[j+1] = list[j+1], list[j] return list bubble_sort([1,5,-3,0,8]) [instruction] | Create an algorithm that sorts a given list of numbers. [input] | [1, 5, -3, 0, 8]

[output] | <html> <head> <title>Input Form</title> </head> <body> <h1>Input Form</h1> <form action="#"> <p>First name: <input type="text" name="firstname"></p> <p>Last name: <input type="text" name="lastname"></p> <p>Email: <input type="text" name="em [instruction] | Create a HTML form that takes three inputs and print them out when the submit button is clicked. [input] |

[output] | class Stack: def __init__(self): self.queue = [] def push(self, item): self.queue.append(item) # Reverse the queue to implement a stack self.queue.reverse() def pop(self): if self.queue: # Reverse the queue to implement a stack [instruction] | Create an algorithm to implement a stack using a single queue. [input] |

[output] | const net = require('net'); const client = new net.Socket(); client.connect(5000, '127.0.0.1', () => { console.log('Connected'); }); client.on('data', (data) => { console.log('Received: ' + data); }); client.on('close', () => { console.log('Connection closed'); }); [instruction] | Create a JavaScript program to make a TCP connection to the server. [input] |

[output] | SELECT product_name FROM product_table WHERE price = (SELECT MAX(price) FROM product_table); [instruction] | Formulate a SQL query to determine the name of the product with the highest price. [input] |

[output] | public class LargestNumber { public static int getLargestNumber(int num1, int num2, int num3) { int greater; if( num1 > num2 && num1 > num3) greater = num1; else if( num2 > num1 && num2 > num3) greater = num2; else [instruction] | Create a Java program for finding the largest number among three integers. [input] |

[output] | #include<iostream> using namespace std; void reverseArray(int arr[], int start, int end) { while (start < end) { int temp = arr[start]; arr[start] = arr[end]; arr[end] = temp; start++; end--; } } void leftRotate(int arr[], int d, [instruction] | Write a C++ program to rotate an array by 'k' positions. [input] | int arr[] = {1, 2, 3, 4, 5}; int k = 2;

[output] | if 5 <= x <= 10: print('The integer is between 5 and 10.') else: print('The integer is not between 5 and 10.') [instruction] | Write a Python code snippet to check if an integer is between 5 and 10 (including both). [input] | x = 8

[output] | <?php // Connect to the database $db = new mysqli('localhost', 'user', 'password', 'dbname'); // Check connection if($db->connect_errno > 0){ die('Unable to connect to database [' . $db->connect_error . ']'); } // Prepare the statement $sql = "INSERT INTO users (id, name, email) VALUES [instruction] | Write a PHP script to connect to a MySQL database and insert a row in the table with values in given fields. [input] | Table name: users Fields: id, name, email

[output] | # Load libraries library(ggplot2) # Define the data data <- c(1, 4, 6, 8, 12, 16, 20) # Create the histogram ggplot(data.frame(x=data), aes(x)) + geom_histogram(bins = 5, fill = "#0072B2", color = "black") [instruction] | Write an R script to create a histogram of a given array of numeric values. [input] |

[output] | The np.random.seed() function sets the random seed, or starting point, for generating random numbers. This allows users to reproduce the same random numbers each time they run the code, making apps and experiments easier to debug. The seed can be set to an integer value, a list of integers, or None. [instruction] | Explain the purpose of the np.random.seed() function. [input] |

[output] | for row in arr: for elem in row: print(elem, end=' ') print() # Output # 1 2 3 # 4 5 6 # 7 8 9 [instruction] | Given the following nested loop structure, write code to print all elements in the array. [input] | arr = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

[output] | Planck's constant (denoted by h) is a physical constant that has a value of 6.62607015×10-34 kg m2/s. It is the fundamental physical constant that is used to describe the size of quantum effects. It is named after physicist Max Planck, who first proposed it in 1900. [instruction] | Physicists often use the constant, Planck's constant, to measure the frequency of light waves. What is the value of Planck's constant? [input] |

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