← 목록

Synth · CodeAlpaca일부

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

[output] | int count_occurrences(char *str, char c) { int count = 0; // Traverse the string and check // for occurrences of character. for (int i=0; str[i] != '\0'; i++) if (str[i] == c) count++; return count; } [instruction] | Create a function in C that takes a string as input and returns an integer, which represents the number of occurences of a given character in the string. [input] | "Hello, World!", 'o'

[output] | public static int[] RemoveElement(int[] arr, int element) { List<int> result = arr.ToList(); for (int i = 0; i < result.Count; i++) if (result[i] == element) result.RemoveAt(i); return result.ToArray(); } [instruction] | Write C# code to remove a specific element from an array. [input] | {1,2,3,4,5,6}, 4

[output] | $('element').addClass('classname'); [instruction] | Write a jQuery command to add a classname to an element. [input] |

[output] | int array[10]; [instruction] | Edit the following code to store 10 numbers in an array. [input] | int array[]

[output] | sum = 30 [instruction] | Determine the sum of the integers in the following list. [input] | list = [2, 4, 6, 8, 10]

[output] | DELETE FROM Table WHERE id = 4; [instruction] | Delete the forth row from the following table using an SQL query. [input] | Table: id | name ------------------- 1 | John 2 | Jane 3 | Jacob 4 | Jill

[output] | h2 { color: blue; } [instruction] | Write a CSS code to set the text colour of the h2 element to blue. [input] |

[output] | console.log(arr[2]); [instruction] | Write a JavaScript expression that prints the value of the array at index 2. [input] | let arr = [2, 4, 6, 8, 10];

[output] | The quick brown fox jumps over the lazy dog. Answer: The,quick, brown, and over. [instruction] | Select all words that start with 'a' from the following text. [input] | The quick brown fox jumps over the lazy dog.

[output] | average <- function(numbers) { sum <- 0 for (i in numbers) { sum <- sum + i } return(sum/length(numbers)) } [instruction] | Write an R function that determines the average value of an integer array. [input] |

[output] | import socket def get_IPv6_address(domain_name): """ Function to get the IPv6 address of a given domain name """ # get the ip_addres ip_address = socket.getaddrinfo(domain_name, 0, socket.AF_INET6) # return the ip address return ip_address[0][4][0] [instruction] | Write a function in Python to get the IPv6 address of a given domain name. [input] |

[output] | my_list.remove(4) [instruction] | Write a single line of code to remove an item from a list. [input] | my_list = [1, 2, 3, 4]

[output] | The maximum value of a byte in a binary system is 255. This is because there are 8 bits in a byte, and the maximum value each bit can have is 1, giving a maximum value of 8 ones, or 255 in the denary system. [instruction] | What is the maximum value of a byte in a binary system? [input] |

[output] | # Create a new set to store the missing numbers missing_numbers = set(list1).difference(set(list2)) # Print the missing numbers print("Missing numbers:", *missing_numbers) [instruction] | Compare two lists to find missing numbers. [input] | list1 = [1, 2, 3, 4, 5] list2 = [2, 3, 4]

[output] | import random def random_letter(string): """ Function to return a random letter from a given string """ # Get the length of the string length = len(string) # Get a random index # from 0 to length - 1 index = random.randint(0, length - 1) [instruction] | Create a function to return a random letter from a given string. [input] |

[output] | # Check if item exists in list if 4 in my_list: print("Exists") else: print("Doesn't Exist") [instruction] | How to check if an item exists in a list in Python? [input] | my_list = [1, 2, 3, 4]

[output] | class Animal: def __init__(self): pass def is_mammal(self): """Return True if animal is a mammal, False otherwise""" pass def is_reptile(self): """Return True if animal is a reptile, False otherwise""" pass def is_amphibian(self): [instruction] | Create a class named Animal with a few methods describing different attributes of animals. [input] |

[output] | """ Fetch the last ten news headlines from HackerNews using their API """ import requests def get_headlines(): url = "https://hacker-news.firebaseio.com/v0/topstories.json" ids = requests.get(url).json() headlines = [] for id in ids[:10]: item = requests.get(f"https://hacke [instruction] | Write a code to fetch the last ten news headlines from HackerNews using their API. [input] |

[output] | """ Prompt the user for an integer and output the summation from 1 to that integer """ #include <iostream> using namespace std; int main() { int input; cout << "Please enter a positive integer: "; cin >> input; int sum = 0; for (int i = 1; i <= input; i++) { sum += i; [instruction] | Write a code in C++ to prompt the user for an integer and output the summation from 1 to that integer. [input] |

[output] | """ Implement quicksort """ def quicksort(arr): if len(arr) < 2: return arr else: pivot = arr[0] less = [i for i in arr[1:] if i <= pivot] greater = [i for i in arr[1:] if i > pivot] return quicksort(less) + [pivot] + quicksort(greater) if __name__ = [instruction] | Write a code to implement quicksort. [input] | arr = [6, 1, 8, 4, 9, 5]

[output] | """ Extract the phone number from given string and output it as an integer """ def extract_phone_number(s): s = s.replace('+', '') numbers = "" for c in s: if c.isdigit(): numbers += c return int(numbers) if __name__ == '__main__': s = "Hi, my number is +1-3 [instruction] | Extract the phone number from given string and output it as an integer. [input] | Hi, my number is +1-345--678-9012

[output] | SELECT userid, SUM(purchase_price) as total_purchase FROM Customer_orders GROUP BY userid; [instruction] | Write a SQL query to retrieve the total amount of purchase each customer has made. [input] | Table:Customer_orders |userid|product |purchase_price| |------|--------|--------------| |1 |shoes |50 | |2 |socks |30 | |1 |pants |20 |

[output] | class BasicForm extends React.Component { constructor(props) { super(props); this.state = { name: '', age: '', }; } render() { return ( <form> <label>Name: <input type="text" name="name" value={this.state.name} onChange={this.handleChange} [instruction] | Using ReactJS, develop a basic form component with two input fields, one for a Name and the other for Age. [input] |

[output] | const inputArray = [1, 2, 3, 4, 4, 2, 5]; const outputArray = inputArray.filter((arrayVal, indexVal) => { return inputArray.indexOf(arrayVal) === indexVal; }); console.log(outputArray); // [1, 2, 3, 4, 5] [instruction] | What would be the JavaScript code to remove duplicate values from an array? [input] | [1, 2, 3, 4, 4, 2, 5]

[output] | public static List<string> FilterByLetterA(string[] s) { List<string> list = new List<string>(); foreach (string item in s) { if (item.Contains("a")) { list.Add(item); } } return list; } [instruction] | Using C#, write a method that returns a list of strings containing only elements of an input string array containing the letter 'a'. [input] | string[] s = {"apple", "banana", "cat"};

[output] | function combineArrays(array1, array2){ let result = array1.concat(array2); return result; } let array1 = [1, 2, 3] let array2 = [4, 5, 6] let combinedArray = combineArrays(array1, array2); console.log(combinedArray) // [1, 2, 3, 4, 5, 6] [instruction] | Write a function that takes two arrays and returns a new array with all the items of the first array followed by all the items of the second array. [input] | array1 = [1, 2, 3] array2 = [4, 5, 6]

[output] | arr = [1, 2, 3, 4, 5, 6] first_column = arr[:len(arr)//2] second_column = arr[len(arr)//2:] [instruction] | Interpret the following array of numbers consisting of 6 elements and divide it into 2 columns. [input] | [1, 2, 3, 4, 5, 6]

[output] | import json parsed_data = {} data = { "name": "John Doe", "age": 33, "locations": ["NYC", "LA"] } for key, val in data.items(): parsed_data[key] = str(val) [instruction] | Parse the following JSON objects, convert all the values to strings and create a dictionary named "parsed_data". [input] | { "name": "John Doe", "age": 33, "locations": ["NYC", "LA"] }

[output] | SELECT * FROM table_name ORDER BY id DESC; [instruction] | Create a MySQL query to print all records from a specific table in descending order of their id. [input] |

[output] | import tensorflow as tf model = tf.keras.Sequential([ # First convolutional layer tf.keras.layers.Conv2D(64, (3, 3), activation='relu', padding='same', input_shape=(64, 64, 3)), tf.keras.layers.MaxPooling2D((2, 2)), # Second convolutional layer tf.keras.layers.Conv2D(128, (3, 3) [instruction] | Design a neural network for facial recognition using TensorFlow. [input] |

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