← 목록

Synth · CodeAlpaca일부

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

[output] | 6 [instruction] | How many elements are in list1 after executing the following Python code? [input] | list1 = [1, 2, 3] list2 = [4, 5, 6] list1.extend(list2)

[output] | def largest(arr): max = arr[0] for i in arr: if i > max: max = i return max [instruction] | Write a function that finds the largest number in an array of integers. [input] |

[output] | 2 [instruction] | How many elements will the array arr have after executing the following Python code? [input] | arr = [1, 2, 3] arr.pop(1)

[output] | int x = 4, y = 5; int sum = x + y; std::cout<<sum; [instruction] | Add the two following numbers in C++. [input] | x = 4 y = 5

[output] | def calculateTotalEarnings(arr): totalEarnings = 0 for i in range(1, len(arr)): totalEarnings += max(arr[i] - arr[i - 1], 0) return totalEarnings arr = [5, 7, 15.5, 6, 10, 11] totalEarnings = calculateTotalEarnings(arr) print("Total earnings: ", totalEarnings) # Output # Total [instruction] | Implement a function to calculate the total amount of money earned from a given array of stock prices. [input] | arr = [5, 7, 15.5, 6, 10, 11]

[output] | def random_num(lower_bound, upper_bound): import random return random.randint(lower_bound, upper_bound) lower_bound = 10 upper_bound = 20 print(random_num(lower_bound, upper_bound)) # Output # [random number between 10 and 20] [instruction] | Create a Python function that generates a random number between two specified numbers. [input] | lower_bound = 10 upper_bound = 20

[output] | pattern = r"^\w{2}-\w{3}-\w{3}$" [instruction] | Construct a regular expression pattern to match a single word with the format "XX-XXX-XXX". [input] |

[output] | def findEvenNumbers(numbers): even_list = [] for number in numbers: if number % 2 == 0: even_list.append(number) return even_list numbers = [2, 3, 4, 5, 6, 7, 8, 9] print(findEvenNumbers(numbers)) # Output # [2, 4, 6, 8] [instruction] | Write a function that takes in a list of numbers and creates a new list with only the even numbers from the list. [input] | numbers = [2, 3, 4, 5, 6, 7, 8, 9]

[output] | def findMissingNumber(arr): n = len(arr) + 1 total = n * (n+1) / 2 sum_of_elements = sum(arr) missing_element = total - sum_of_elements return int(missing_element) arr = [1, 2, 4, 6, 7, 8, 10, 11, 12, 13, 15] print(findMissingNumber(arr)) # Output # 3 [instruction] | Assume an array contains elements from 1 to 100. You need to find the missing element. [input] | arr = [1, 2, 4, 6, 7, 8, 10, 11, 12, 13, 15]

[output] | def reverseString(s): rev = s[::-1] return rev s = "Hello World" print(reverseString(s)) # Output # dlroW olleH [instruction] | Create a function that takes in a string and returns a new string in which all the characters are reversed. [input] | s = "Hello World"

[output] | def findPrimeNumbers(arr): prime_list = [] for number in arr: isPrime = True for i in range(2, number): if number % i == 0: isPrime = False if isPrime: prime_list.append(number) return prime_list arr = [2, 11, 9, 5, 4, 7] print(findPrimeNumbers(arr)) # Output # [2, 11, 5 [instruction] | Produce a function that takes in an array of integers and returns an array with all the prime numbers in it. [input] | arr = [2, 11, 9, 5, 4, 7]

[output] | function spreadArray(arr, size) { let subarrays = []; while (arr.length) { subarrays.push(arr.splice(0, size)); } return subarrays; } arr = [1, 2, 3, 4, 5, 6] size = 3 console.log(spreadArray(arr, size)); # Output # [[1, 2, 3], [4, 5, 6]] [instruction] | Create a JavaScript program to spread a given array into subarrays of the given size. [input] | arr = [1, 2, 3, 4, 5, 6] size = 3

[output] | def checkArray(array1, array2): for element in array2: if element not in array1: return False return True array1 = [1, 2, 3, 4] array2 = [1, 2, 3] print(checkArray(array1, array2)) # Output # True [instruction] | Create a function that takes an array and returns true if it contains all the elements in an another array. [input] | array1 = [1, 2, 3, 4] array2 = [1, 2, 3]

[output] | pattern = r"^(0[1-9]|[12][0-9]|3[01])[\/](0[1-9]|1[012])[\/](19[0-9][0-9]|20[0-9][0-9])$" [instruction] | Write a regular expressipon pattern to match the following date format "DD/MM/YYYY". [input] |

[output] | num = int(input("Enter a number: ")) print(num * 2) [instruction] | Change the given code to allow the user to input a number and print it twice. [input] |

[output] | SELECT title, price FROM books WHERE rating = 5; [instruction] | Write a SQL query to select the title and price of books with a rating of 5. [input] | SELECT title, price FROM books WHERE rating = 5;

[output] | array = [0, 1, 2, 3, 4] [instruction] | Create an array of integers with values 0, 1, 2, 3, 4. [input] |

[output] | const express = require('express'); const app = express(); app.get('/', (req, res) => { res.send('Hello World!'); }); app.listen(3000, () => { console.log('Server is running on port 3000'); }); [instruction] | Create a Node.js web server with the Express module. [input] |

[output] | mydict = {} for i in range(len(mylist)): mydict[i] = mylist[i] [instruction] | Change the following Python code to convert the list to a dictionary of key-value pairs. [input] | mylist = [1, 2, 3, 4, 5]

[output] | def is_in_list(element, input_list): return element in input_list [instruction] | Write a Python function to check if an element is present in a given list or not. [input] |

[output] | SELECT CURRENT_DATE; [instruction] | Create an SQL query that returns the current date. [input] |

[output] | Python and Java are both popular programming languages with different features that make them suitable for different tasks. Python is an interpreted, high-level, and general-purpose programming language that emphasizes code readability and has simple, easy-to-use syntax. Java, on the other hand, is [instruction] | Compare and contrast the features of the two programming languages: Python and Java. [input] |

[output] | def elements_greater_than_x(arr, x): result = [] for el in arr: if el > x: result.append(el) return result [instruction] | Create a method that returns all elements in an array that are larger than the given value x. [input] | [2, 3, 5, 7, 11, 13] and x = 4

[output] | Quick Sort > Binary Search Tree > Bubble Sort. Quick Sort has the best time complexity of O(nlogn). Binary Search Tree has the time complexity of O(logn) for insertion and searching. Bubble Sort has the worst time complexity of O(n^2). [instruction] | Rank the following algorithms based on time complexity: Quick Sort, Binary Search Tree, and Bubble Sort. [input] |

[output] | str1 = str(54) str2 = str(32) [instruction] | Convert the following integers into strings. [input] | 54 and 32

[output] | import random arr = [] while len(arr) < 10: rand = random. randint(0, 10000) if rand not in arr: arr.append(rand) arr [instruction] | Create an array of 10 non-repeating random integers. [input] |

[output] | import datetime date_time = datetime.datetime.now() print(date_time.strftime("%A %d %B, %Y, %I:%M %p")) # Output: Tuesday 12 November, 2019, 11:17 PM [instruction] | Print the current system date and time in a readable format [input] |

[output] | const a = []; for (let i = 1; i <= 10; i++) { a.push(i); } console.log(a); [instruction] | Write a JavaScript program that creates an array with all the numbers from 1 to 10. [input] |

[output] | name | age ------------ John | 20 Laura | 30 Harry | 25 [instruction] | Create a table of data about each object in the list. [input] | my_list = [{"name": "John", "age": 20}, {"name": "Laura", "age": 30}, {"name": "Harry", "age": 25}]

[output] | my_list.sort() print(my_list) [instruction] | Sort the items in the list alphabetically [input] | my_list = ['bird', 'cat', 'turtle', 'dog']

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