← 목록

Synth · CodeAlpaca일부

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

[output] | DELETE FROM students WHERE major = 'Computer Science'; [instruction] | Generate the necessary SQL query to delete records from the table 'students' where the student's major is 'Computer Science'. [input] |

[output] | var a = 10 var b = 20 (a, b) = (b, a) print(a) // Outputs 20 print(b) // Outputs 10 [instruction] | How would you write a Swift program to swap the values of two variables? [input] |

[output] | h1 { font-family: Arial, Helvetica, sans-serif; font-size: 28px; font-style: normal; font-weight: bold; line-height: 32px; letter-spacing: 0.5px; color: #000000; text-align: center; padding-top: 10px; padding-bottom: 10px; margin-bottom: 0px; } [instruction] | Create a CSS page for styling a header. [input] |

[output] | ['apple', 'orange'] [instruction] | You need to delete an item from a list. Output the modified list. [input] | ['apple', 'orange', 'banana']

[output] | import bs4 html = """<html> <body> <table> <tr> <td>Name</td> <td>Age</td> </tr> <tr> <td>John Doe</td> <td>30</td> </tr> <tr> <td> Jane Smith</td> <td>25</td> </tr> </table> </body> </html>""" data = bs [instruction] | Parse the following HTML page and extract the data from each table. [input] | <html> <body> <table> <tr> <td>Name</td> <td>Age</td> </tr> <tr> <td>John Doe</td> <td>30</td> </tr> <tr> <td> Jane Smith</td> <td>25</td> </tr> </table> </body> </html>

[output] | [50, 40, 30, 10] [instruction] | Given a set of numbers, you need to output them in descending order. [input] | [30, 50, 10, 40]

[output] | def sum_numbers(): number_list = [] input_numbers = input("Please enter the numbers you want to sum up (enter q to exit): ") while input_numbers != "q": number_list.append(int(input_numbers)) input_numbers = input("Please enter the numbers you want to sum up (enter q to e [instruction] | Modify the following code so that it takes a user input for the numbers for which to calculate the sum. [input] |

[output] | a = [1,3,2,2,3,4] output = [] for i in range(len(a)): output.append(a[i - 1]) print(output) # [3, 2, 2, 3, 4, 1] [instruction] | Consider a list ``a = [1,3,2,2,3,4]``. What would be the output of the following code? [input] | a = [1,3,2,2,3,4] for i in range(len(a)): a[i] = a[i -1]

[output] | def join_string_in_middle(string1 , string2): return string1 + string2 + string1 # Usage result = join_string_in_middle("Hello", "World") print(result) # HelloWorldHello [instruction] | Write a function that takes two strings as input and returns a join of both strings as a single string, with the second string in the middle. [input] | string1 = "Hello" string2 = "World"

[output] | The data structure to use for key-value pairs in Python is a dictionary. A dictionary is a data type that consists of key-value pairs, and is denoted by {} in Python. Each key has a unique value associated with it that can be accessed using the key. For example, a dictionary called "person" could lo [instruction] | What type of data structure would you use to store key-value pairs in a Python program? [input] |

[output] | def factorial(num): # base case if num == 0: return 1 else: return num * factorial(num-1) # Usage print(factorial(3)) # 6 [instruction] | Generate a recursive function for calculating the factorial of a number. [input] |

[output] | def get_all_palindromes(input_string): palindromes = [] for substring_length in range(len(input_string)): for i in range(len(input_string) - substring_length + 1): sub_string = input_string[i: i + substring_length] if sub_string == sub_string[::-1]: [instruction] | Find all substrings of a string that are palindromes in Python. [input] |

[output] | np.array([0, 0, 0, 1, 1, 1]) [instruction] | Create a NumPy array containing three zeros and three ones. [input] |

[output] | DataFrame: col1 col2 col3 1 a 3 2 b 4 [instruction] | Given a dataframe, remove any rows containing missing values. [input] | DataFrame: col1 col2 col3 1 a 3 2 b 4 3 NaN 5 4 c NaN

[output] | {"red": "red", "blue": "blue", "green": "green"} [instruction] | Create a dictionary of colors containing the values red, blue and green. [input] |

[output] | [1, 2, 3, 4] [instruction] | Given a list, remove the duplicates from it. [input] | [1, 2, 3, 1, 4, 2]

[output] | {"d": 1, "b": 2, "c": 3, "a": 4} [instruction] | Sort a dictionary by its values. [input] | {"a": 4, "b": 2, "c": 3, "d": 1}

[output] | SELECT SUM(price) FROM Products; [instruction] | Output a SQL query that returns the sum of all values in the ‘price’ column of the ‘Products’ table. [input] |

[output] | .largerFont { font-size: 120%; } [instruction] | Create a CSS class to raise the font size of the text from the default size. [input] |

[output] | const censoredText = (text, wordsToHide) => { const wordsArr = text.split(' '); wordsArr.forEach((word, index) => { if (wordsToHide.includes(word)) { wordsArr[index] = '*'.repeat(word.length) } }); return wordsArr.join(' '); } censoredText("The quick brown fox jumped over th [instruction] | Create an application to hide certain words in a text. [input] | Text: "The quick brown fox jumped over the lazy dog." Words to hide: ["fox", "dog"]

[output] | public static boolean isPrime(int n) { // Corner cases if (n <= 1) return false; if (n <= 3) return true; // This is checked so that we can skip // middle five numbers in below loop if (n % 2 == 0 || n % 3 == 0) return false; for ( [instruction] | Write an algorithm in Java to check if a number is a prime number. A prime number is an integer greater than 1 that is only divisible by 1 and itself. [input] |

[output] | const findLongestWord = (str) => { let longestWord = ""; let wordsArr = str.split(" "); for(let i = 0; i < wordsArr.length; i++){ if (wordsArr[i].length > longestWord.length) { longestWord = wordsArr[i]; } } return longestWord.length; } findLongestWord(str); //6 [instruction] | Write an algorithm in JavaScript to return the length of the longest word in a string. [input] | let str = "The quick brown fox jumped over the lazy dog."

[output] | @Directive({ selector: '[validateInput]' }) export class InputValidationDirective { @Input() validateInput: string; constructor(private el: ElementRef) { } @HostListener('keyup') onKeyup() { let value = this.el.nativeElement.value if(!this.validateInput || this.validateInput === [instruction] | Write an Angular directive to validate input fields. [input] |

[output] | def compound_interest(principal, rate, time): # Calculates compound interest CI = principal * (pow((1 + rate / 100), time)) return CI # Driver Code principal=8000 rate=3 time=5 print("Compound interest is", compound_interest(principal, rate, time)) [instruction] | Create an algorithm in Python to calculate the compound interest [input] |

[output] | for i in range(10, 0, -1): print(i) [instruction] | Create a loop in Python that counts down from 10 to 0. [input] |

[output] | def print_square(length): for i in range(0, length): for j in range(0, length): print("*", end="") print("") [instruction] | Add a function to the existing code that takes an integer value as input and prints a square of '*' characters. [input] | def print_square(length):

[output] | total = 0 for num in [1, 3, 5, 7, 9]: total += num print(total) [instruction] | Use a for loop to compute the sum of the list [1, 3, 5, 7, 9]. [input] | [1, 3, 5, 7, 9]

[output] | for char in “Hello World!”: print(char) [instruction] | Use a for loop to print the characters of the string "Hello World!". [input] |

[output] | public int sum(int a, int b) { return (a + b); } [instruction] | Write a Java code that adds two numbers, a and b, and returns their sum. [input] | int a = 2 int b = 3

[output] | Integer [instruction] | Print the type of the data stored in the variable 'a'. [input] | int a = 15

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