← 목록

Synth · CodeAlpaca일부

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

[output] | SELECT ItemName, Price FROM Items ORDER BY Price DESC LIMIT 5; [instruction] | Create an SQL query that returns the top five most expensive items in the table. [input] |

[output] | // Insert 8 after 4 public static Node insertNode(Node head, int data) { Node node = new Node(data); // Empty List if (head == null) { node.next=null; head = node; return head; } Node CurrNode = head; while (CurrNode.data != 4) [instruction] | Write a Java program to insert a new node into a singly linked list. [input] | head -> 3 -> 4 -> 6 -> null

[output] | true [instruction] | Create an array of numbers and check if a given number exists in the array. Output true if it exists, output false if it does not. [input] | arr = [1,2,3,4,5] n = 4

[output] | 3.0 [instruction] | You receive an array of numbers as input and you need to calculate the median number. [input] | arr = [3, 2, 4, 1, 5]

[output] | mysqli_close($connection); [instruction] | Create a PHP script that closes a MySQL connection. [input] |

[output] | <div class="logo"> <img src="logo.png" alt="Company Logo"> </div> [instruction] | A website requires a logo to be displayed in the header. Design a logo and write the HTML code to display it. [input] |

[output] | false [instruction] | Read the provided code and determine whether it is using object-oriented programming or not. Output true if it is and false if it is not. [input] | function displayName(name) { console.log(name); }

[output] | function validatePassword(password) { if(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/.test(password)) { return true; } else { return false; } } [instruction] | You need to write a function that validates a given password. It should only be valid if it contains at least one lowercase letter, one uppercase letter, one number, and one special character. [input] |

[output] | struct StoreInventory { char itemName; //Name of the item int itemCode; //Unique identifier for each item float itemPrice; //Price of the item int itemQuantity; //Quantity of the item }; [instruction] | Devise a data structure to store an inventory of items in a store. [input] |

[output] | [4, 3, 2, 1] [instruction] | Reverse a given array without using a loop. [input] | arr = [1,2,3,4]

[output] | # Import the random module import random # Generate 1000 random numbers random_numbers = [random.randint(1, 1000) for i in range(1000)] # Calculate mean of the random numbers mean = sum(random_numbers)/len(random_numbers) # Print mean of random numbers print("The mean of 1000 random numbers is: [instruction] | Write a code to generate 1000 random numbers and print the mean of these random numbers. [input] |

[output] | # Define the function to raise a number to a given power def power(x, p): # The base case is when power is 0 if p == 0: return 1 # if power is not 0, then recursively call the function power return x * power(x, p-1) # Get the number x = 2 # Get the power p = 3 # Calculate the result [instruction] | Create a code to raise a number to a given power p. [input] | 2

[output] | # Define the function to print array in reverse def print_reverse(arr): # Base case if len(arr) == 0 : return # Print the last value print(arr.pop()) # Recursive call with array - 1 return print_reverse(arr) # Get the array arr = [1,2,3,4] # Print the array in reverse print("The array [instruction] | Create a code to print the items from a given array in reverse. [input] | [1,2,3,4]

[output] | # Define a function to print elements column-wise def print_columnwise(arr): # Get the number of rows and columns num_rows = len(arr) num_cols = len(arr[0]) # Initialize the columns k = 0 # Iterate through the rows while k < num_cols : # Iterate through the columns for i in range(nu [instruction] | Given a two-dimensional array, write a code to print the elements column-wise. [input] | [[1, 2], [3, 4], [5, 6]]

[output] | my name is john [instruction] | Change the following text from uppercase to lowercase. [input] | MY NAME IS JOHN

[output] | .increase-font-size { font-size: 2rem; } [instruction] | Write a CSS class that will make the font size of all elements 2 times larger. [input] |

[output] | "1,2,3,4,5" [instruction] | Convert the given list of integers to a string of comma separated values. [input] | [1, 2, 3, 4, 5]

[output] | public static int countVowels(String... strings) { int count = 0; for (String str : strings) { for (char c : str.toCharArray()) { switch (c) { case 'a': case 'e': case 'i': case 'o': case [instruction] | Create a function to find the total number of vowels in a series of strings. [input] | string1: "Hello" string2: "World"

[output] | def average(nums): """ Takes a list of numbers and returns the average. """ total = 0 for num in nums: total += num return total / len(nums) [instruction] | Write an algorithm to calculate the average of a list of integers given as input. [input] |

[output] | .mobile-table { width: 100%; border-collapse: collapse; overflow-x: scroll; } .mobile-table td { padding: 10px; vertical-align: top; overflow-y: hidden; overflow-x: auto; } [instruction] | Create a css class for a table to be displayed on a mobile device. [input] |

[output] | string = 'This is a test string' words = string.split() filtered_words = [] for word in words: if len(word) >= 4: filtered_words.append(word) print(filtered_words) # Output: # ['This', 'test', 'string'] [instruction] | Split the given string into words and remove any words that have less than 4 characters. [input] | string = 'This is a test string'

[output] | function toRoman(num) { // store roman equivalents of numbers var romanNumerals = { 1: 'I', 4: 'IV', 5: 'V', 9: 'IX', 10: 'X', 40: 'XL', 50: 'L' }; // array to store roman numeral var roman = []; // loop to check f [instruction] | Write a JavaScript function to convert a given number to its Roman numeral equivalent. [input] |

[output] | def contains_A(strings): for string in strings: if 'a' in string: return True return False [instruction] | Write a function that takes in a list of strings and returns True if any of the strings contains the letter `a`. [input] |

[output] | public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } [instruction] | Write a Java program to remove comments from the Java program. [input] | public class HelloWorld { /* This is a multiline comment. */ public static void main(String[] args) { System.out.println("Hello World!"); // This is a single line comment. } }

[output] | #!/bin/bash echo "Checking disk usage of the /tmp directory" # Get the current disk usage du -sh /tmp/ [instruction] | Create a bash script to check the disk usage of the "/tmp" directory. [input] |

[output] | <?php function sort_array_ascending($array) { sort($array); return $array; } ?> [instruction] | Create a PHP function that sorts the elements of an array in ascending order. [input] |

[output] | arr = [1, 2, 3, 4, 5]; for (let i = 0; i < arr.length; i++) { console.log(arr[i]); } [instruction] | Write a loop to iterate through the following array and prints each element. [input] | arr = [1, 2, 3, 4, 5]

[output] | arr = [1, 2, 3, 4, 5]; const filteredArray = arr.filter(item => item % 2 === 0); console.log(filteredArray); # Output: # [2, 4] [instruction] | Filter the array based on the given condition and return a new array of elements that satisfy the condition. [input] | arr = [1, 2, 3, 4, 5]

[output] | db.collection.find( { "items": { $elemMatch: { "name": "pen" } } } ) [instruction] | Create a MongoDB query to find all documents that have an array "items" with a field "name" equal to "pen". [input] |

[output] | y = x < 0 ? -1 : 1; [instruction] | Refactor the following condition to use the ternary operator instead of an if-else statement. [input] | if (x < 0) { y = -1; } else { y = 1; }

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