← 목록

Synth · CodeAlpaca일부

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

[output] | <header> <div></div> <div></div> <div></div> <div></div> <div></div> </header> [instruction] | Create an HTML structure that mimics the mockup given below. Mockup: header | ____ | | | | | | | | |-----| [input] |

[output] | def generate_key_value(arr): key_val_pairs = {k:v for k,v in enumerate(arr)} return key_val_pairs print(generate_key_value(arr)) Output: {0: 1, 1: 2, 2: 3, 3: 4} [instruction] | Write a Python function that generates a key-value pair for the given array. [input] | arr = [1, 2, 3, 4]

[output] | db.collection.find({name: /.*Hi.*/}) [instruction] | Create a MongoDB query that retrieves all the documents whose 'name' field contains the given string. [input] | String: Hi

[output] | #include <stdio.h> #include <string.h> int main(){ char str1[] = "ab"; char str2[] = "cd"; int i, j; for(i=0; i<strlen(str1); i++){ for(j=0; j<strlen(str2); j++){ printf("%c%c ", str1[i], str2[j]); } } printf("\n"); return 0; } Output: ac ad bc bd [instruction] | Create a C program that prints all distinct combinations of characters from two given strings. [input] | Strings: ab and cd

[output] | UPDATE collection SET price = 200; [instruction] | Write an SQL query that updates the 'price' field for all documents in the collection to 200. [input] |

[output] | How: 3 are: 3 you: 3 doing: 6 ? :1 [instruction] | You are given a text and the task is to output each individual word in the text along with its character count. [input] | Text: How are you doing?

[output] | import { Component } from '@angular/core'; @Component({ selector: 'app-root', template: ` <h1>{{ dateTime | date:'dd/MM/yyyy HH:mm:ss' }}</h1> ` }) export class AppComponent { dateTime = new Date(); } [instruction] | Develop an Angular application that displays the current date and time. [input] |

[output] | <html> <head> <title>Fruit List</title> </head> <body> <ul> <li>Apple</li> <li>Orange</li> <li>Banana</li> <li>Pear</li> <li>Mango</li> </ul> </body> </html> [instruction] | Using HTML and CSS, create a web page that lists all of the fruits in the given array. [input] | fruits = ["apple", "orange", "banana", "pear", "mango"]

[output] | def compute_sum(arr): sum = 0 for num in arr: sum += num return sum print(compute_sum(arr)) Output: 10 [instruction] | Compute the sum of a given array using a Python function. [input] | arr = [1, 2, 3, 4]

[output] | def largest_negative_number(arr): largest = float('-inf') for i in range(len(arr)): if arr[i] > largest: largest = arr[i] return largest # Driver Code arr = [-10, -20, -50, -30] print(largest_negative_number(arr)) [instruction] | Write a code to print the largest element of an array if the array contains all negative numbers. [input] | arr = [-10, -20, -50, -30]

[output] | def merge_lists(list1, list2): final_list = [] i, j = 0, 0 while i < len(list1) and j < len(list2): if list1[i] < list2[j]: final_list.append(list1[i]) i += 1 else: final_list.append(list2[j]) j += 1 while i < [instruction] | Write a function to merge two sorted lists into one sorted list. [input] | list1 = [3, 5, 7] list2 = [1, 4, 6]

[output] | def sort_numbers_desc(arr): for i in range(len(arr)): max_element = arr[i] max_index = i for j in range(i+1, len(arr)): if arr[j] > max_element: max_element = arr[j] max_index = j arr[i], arr[max_index] [instruction] | Given an input of numbers, sort the numbers in descending order. [input] | arr = [6, 2, 5, 3, 9]

[output] | def print_binary(number): binary_string = "" while number != 0: remainder = number % 2 binary_string = str(remainder) + binary_string number = number // 2 return binary_string print(print_binary(number)) [instruction] | Create a function that prints the binary representation of a number. [input] | number = 5

[output] | def remove_duplicates(list): new_list = [] for element in list: if element not in new_list: new_list.append(element) return new_list print(remove_duplicates(list)) [instruction] | Write code to remove duplicates and maintain the order of elements in a given list. [input] | list = [3, 1, 7, 5, 3, 8, 7]

[output] | The mean value of a function can be calculated by integrating the function from 0 to infinity and dividing the integral by infinity. Mathematically, this is expressed as: mean = ∫∞0f(x)dx/∞ [instruction] | Explain how to calculate the mean value of a function defined from 0 to infinity. [input] |

[output] | import re address_string = "#38 number street, new york city, san jose, CA" pattern = r'(?:,|^)([\s\w]*)(?:,|$)' result = re.findall(pattern, address_string) print(result) // ['new york city', 'san jose'] [instruction] | Write a regular expression to extract the city names from the following string. [input] | address: #38 number street, new york city, san jose, CA

[output] | Merge sort is an efficient sorting algorithm that uses divide and conquer approach. It divides the array into two halves, recursively sorts them and then merges them. Merge sort has a time complexity of O(nlog(n)) and is efficient for large arrays. [instruction] | Suggest a better algorithm than Bubble sort for sorting a large array. [input] |

[output] | *args and **kwargs are special syntax in Python used to pass a variable number of arguments to a function. *args denotes positional arguments, while **kwargs represents keyword arguments. The syntax allows functions to take arbitrary number of arguments and provide flexibility for functions to handl [instruction] | Explain the use of *args and **kwargs in Python. [input] |

[output] | The error is in line 6 while using the range function. The range function expects the start and end parameters to be int type, but in this case the parameter passed to the range function is a list. This should be changed to range(len(my_list)) so that the code will iterate over the elements of the l [instruction] | Identify the error in the code given below. [input] | # Sum of elements in a list my_list = [1, 2, 3] sum = 0 for i in range(my_list): sum += i print(sum)

[output] | import random my_list = [1, 2, 3, 4, 5] random.shuffle(my_list) print(my_list) [instruction] | Write a code to shuffle a list randomly in Python [input] |

[output] | The longest common substring can be found by traversing the two strings simultaneously and comparing the characters. If the characters match, we will increase the substring length by 1 and check for the next characters. In the case of a mismatch, the substring length is set back to 0. We will find t [instruction] | Given two string, how would you find the longest common substring? [input] |

[output] | A dictionary would be a suitable data structure to store a collection of countries and their corresponding population. The country name could be used as the key and the population could be used as the value. For example: countries_population = { 'United States': 329_467_000, 'Canada': 36_32 [instruction] | Suggest a data structure for storing a collection of countries and their corresponding population. [input] |

[output] | name | age | address -----|-----|--------- John Doe|29|123 Main Street [instruction] | Write a JSON parser to read the following data and output it in a 3-column table. [input] | {"name": "John Doe", "age": 29, "address": "123 Main Street"}

[output] | #!/bin/bash lpr -P [instruction] | Create a shell script to list all available printer models. [input] |

[output] | SELECT grade, COUNT(*) FROM students GROUP BY grade; [instruction] | Write a SQL query to count how many students are in each grade. [input] |

[output] | 1 x 5 = 5 2 x 5 = 10 3 x 5 = 15 4 x 5 = 20 5 x 5 = 25 6 x 5 = 30 7 x 5 = 35 8 x 5 = 40 9 x 5 = 45 10 x 5 = 50 [instruction] | Ask the assistant to print a multiplication table for the number 5. [input] |

[output] | <html> <head> <script> // JavaScript code </script> </head> <body> <form> <input type="text" name="field1" /> <input type="text" name="field2" /> <input type="text" name="field3" /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> [instruction] | Use JavaScript and HTML to create a form with 3 input fields and a submit button. [input] |

[output] | #navbar { ... } [instruction] | Write a CSS selector to select the horizontal navigation bar with ID "nav-bar". [input] |

[output] | Input [instruction] | Classify whether the following statement is an input or an output. [input] | Print the sum of the two numbers.

[output] | function isPrime(n) { if (n === 2) return true; if (n % 2 === 0) return false; for (let i = 3; i <= Math.sqrt(n); i += 2) { if (n % i === 0) return false; } return true; } function primeFilter(array) { let result = []; for (let i = 0; i < array.length; i++) { [instruction] | Design a JavaScript function to filter out the prime numbers from an array. [input] | [1, 2, 3, 4, 5, 6]

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