← 목록

Synth · CodeAlpaca일부

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

[output] | class BinarySearchTree { Node root; /* Class containing left and right child of current node and key value*/ class Node { int key; Node left, right; public Node(int item) { key = item; left = right = null; } } [instruction] | Create a basic Java program that implements a binary search tree. [input] |

[output] | function removeSpecialCharacters(str) { var pattern = new RegExp("[^a-zA-Z0-9]"); return str.replace(pattern, ''); } [instruction] | Modify the following code to remove all punctuation and special characters. [input] | function removeSpecialCharacters(str) { var pattern = new RegExp("[ `!@#$%^&*()+\-=\[\]{};':\"\\|,.<>\/?~]"); return str.replace(pattern, ''); }

[output] | public class Lyrics { public static void main(String[] args) { System.out.println("Mary had a little lamb,"); System.out.println("Little lamb, little lamb,"); System.out.println("Mary had a little lamb,"); System.out.println("Its fleece was white as snow."); [instruction] | Write a Java program to print out the lyrics of the song “Mary Had a Little Lamb”. [input] |

[output] | class TestResults { // A map containing the question id as key and the selected answer as value Map<Integer, Integer> answers; // A map containing the question id as key and a boolean indicating whether the answer was correct or not as value Map<Integer, Boolean> scores; // [instruction] | How would you design the data structure to store and process results from a 5-choice multiple choice test. [input] |

[output] | <textarea rows="4" cols="50"></textarea> [instruction] | Write an HTML function that renders a Text Area on a website. [input] |

[output] | The website should provide the users with an interface to select their star sign from a drop-down list. When the user selects their star sign, the website should display their daily horoscope. To achieve this, the website should connect to a database which contains the daily horoscopes for each of t [instruction] | How would you create a website that provides users with their daily horoscopes? [input] |

[output] | A dictionary can be used to reverse a string by mapping each character to its reversed counterpart. Create a dictionary with all the characters from the string as keys and their reversed version as the values. To reverse a string, iterate through it and look up each character in the dictionary and a [instruction] | Describe how you would use a dictionary to reverse a string. [input] |

[output] | import random def shuffle(arr): random.shuffle(arr) return arr result = shuffle([1, 2, 3, 4, 5]) print(result) [instruction] | Write a Python script that randomly shuffles the elements of a given array. [input] | list = [1, 2, 3, 4, 5]

[output] | enum Weekday { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }; [instruction] | Convert the following enum type expression in Java for days of the week to equivalent C# syntax. [input] | enum Weekday {SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY};

[output] | SELECT * FROM Table1 INNER JOIN Table2 ON Table1.field2 = Table2.field2 [instruction] | Create a SQL query to join two tables based on their common fields. [input] | Table1 (field1, field2, field3) Table2 (field2, field4, field5)

[output] | x = 10 [instruction] | Convert the given code in Java to an equivalent expression in Python. [input] | int x = 10;

[output] | def is_palindrome(string): left = 0 right = len(string) - 1 while right >= left: if string[left] != string[right]: return False left += 1 right -= 1 return True [instruction] | You need to write a function to check if given input is a palindrome string. [input] | string = "level"

[output] | for num in range(11): if num != 5: print(num) [instruction] | Create a program that prints out a list of all numbers from 0 to 10, except for five. [input] |

[output] | SELECT * FROM Table WHERE Name = 'John' [instruction] | You need to convert the following statement in SQL to equivalent PostgreSQL syntax. [input] | SELECT * FROM Table WHERE Name='John'

[output] | def hcf(x, y): if x > y: smaller = y else: smaller = x for i in range(1, smaller+1): if((x % i == 0) and (y % i == 0)): hcf = i return hcf x = 24 y = 48 print ("The H.C.F. of 24 and 48 is", hcf(x, y)) [instruction] | Create a program to find the largest common factor in two numbers. [input] | 24 and 48

[output] | public class TwoIntegers { private int[] twoIntegers; public TwoIntegers() { twoIntegers = new int[2]; } public int getFirst() { return twoIntegers[0]; } public int getSecond() { return twoIntegers[1]; } public void setFirst [instruction] | Implement a Class in Java that creates a new array of two integers and allows the user to set and get the values of the array. [input] |

[output] | public class Student { private int rollNumber; private String name; private int grade; public Student (int rollNumber, String name, int grade) { this.rollNumber = rollNumber; this.name = name; this.grade = grade; } public int getRollNumber() [instruction] | Design a data structure in Java to store student records which includes Roll Number, Name, and Grade of the student. [input] |

[output] | <html> <head> <style> table { border-collapse: collapse; width: 100%; } th, td { text-align: left; padding: 8px; } tr:nth-child(even) { [instruction] | Use CSS to style an HTML table with a heading and 6 rows and 4 columns. [input] |

[output] | SELECT * FROM students WHERE grade > 8; [instruction] | Create a MySql query to find all the students with a grade above 8. [input] |

[output] | { "_id": ObjectId(), "title": String, "author": String, "ISBN": String } [instruction] | Design a MongoDB schema for a collection to store books with fields for title, author and ISBN. [input] |

[output] | let strArray = ["Hello", "World", "!"]; for(let i = 0; i < strArray.length; i++) { console.log(strArray[i]); } [instruction] | Construct a for loop in JavaScript to iterate through an array of strings and print out each one. [input] |

[output] | <ul> <li>Apple</li> <li>Banana</li> <li>Cherry</li> </ul> [instruction] | Generate an HTML list with the following entries: [input] | Apple Banana Cherry

[output] | def remove_duplicates(list_of_strings): """ This function will take a list of strings and return a list of the same strings without duplicates. """ unique_strings = list(set(list_of_strings)) return unique_strings list_of_strings = ["a", "b", "c", "a", "d"] print(remove_duplicat [instruction] | A function needs to be created that will take a list of strings and return a list of the same strings without duplicates. [input] | list_of_strings = ["a", "b", "c", "a", "d"]

[output] | def validate_date(date): """ This function will validate if a given date is in the correct format. """ try: year, month, day = date.split('/') int(year) int(month) int(day) isValidDate = True except: isValidDate = False return i [instruction] | Create a function that will validate if a given date is in the correct format. [input] | date = '12/04/2021'

[output] | def format_title(title): """ This function will format a given string in proper title case. """ formatted_title = ' '.join([word[0].upper() + word[1:] for word in title.split()]) return formatted_title title = 'the quick brown fox' print(format_title(title)) [instruction] | Write a function that will format a given string in proper title case. [input] | title = 'the quick brown fox'

[output] | def compare_strings(string1, string2): """ This function will compare two strings and return a boolean depending on their equality or inequality. """ is_same = string1 == string2 return is_same string1 = 'hello' string2 = 'world' print(compare_strings(string1, string2)) [instruction] | create a function to compare two strings and return a boolean depending on their equality or inequality. [input] | string1 = 'hello' string2 = 'world'

[output] | import nltk from nltk.sentiment.vader import SentimentIntensityAnalyzer sia = SentimentIntensityAnalyzer() sentiment = sia.polarity_scores(input_text) print(sentiment) # {'neg': 0.404, 'neu': 0.596, 'pos': 0.0, 'compound': -0.7424} [instruction] | Write a Python program to analyze the sentiment of a given text. [input] | The restaurant food was terrible.

[output] | The Fibonacci sequence is a sequence of numbers where each number in the sequence is the sum of the two numbers preceding it. The first two numbers in the sequence are 0 and 1. The sequence starts with 0 and 1 and continues by adding the two previous numbers to get the next number in the sequence. F [instruction] | How does the Fibonacci number sequence work? [input] |

[output] | double num = 3.14159; num = Math.round(num * 100.0) / 100.0; System.out.println(num); // Output: 3.14 [instruction] | Edit the following Java code to round a number to two decimal places. [input] | double num = 3.14159;

[output] | Debugging is the process of identifying and fixing errors in the code. It involves finding the root cause of the error and removing it. The process of debugging involves isolating the offending code, identifying the bug, obtaining an understanding of why the bug occurred, determining if a fix can be [instruction] | Describe the process of debugging a code. [input] |

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