← 목록

Synth · CodeAlpaca일부

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

[output] | input_str = "The number is 559" output_str = "".join([i for i in input_str if i.isnumeric()]) print(output_str) # prints 559 [instruction] | Keep only the characters from the input string that have a numerical value from 0 to 9. [input] | The number is 559

[output] | radius = 5 import math # calculate the area area = math.pi * radius ** 2 print("The total area of the circle is "+str(area)) # prints The total area of the circle is 78.53981633974483 [instruction] | Calculate the total area of a circle given the radius. [input] | radius = 5

[output] | """ Create a FizzBuzz program """ for num in range(1, 101): if num % 3 == 0 and num % 5 == 0: print("FizzBuzz") elif num % 3 == 0: print("Fizz") elif num % 5 == 0: print("Buzz") else: print(num) [instruction] | Create a FizzBuzz program. [input] |

[output] | from nltk.corpus import wordnet # get the synset object synset = wordnet.synsets('cat')[0] # find the hypernyms and count the number of hypernyms count = len(list(synset.hypernyms())) print("There are {} hypernyms of the word 'cat'.".format(count)) # prints There are 6 hypernyms of the word 'cat [instruction] | How many are hypernyms of the given word? [input] | cat

[output] | def calculate_series(x): """ Calculate the value of the mathematical series """ result = 0 for i in range(1, x + 1): result += (1 / (i * i)) return result if __name__ == "__main__": result = calculate_series(2) print(result) # prints 1.25 [instruction] | Write a function to calculate the value of the mathematical series: [input] | x = 2

[output] | def most_vowels(sentence): # Split sentence into words words = sentence.split(" ") # Keep track of our highest vowel count and the associated word highest_count = 0 most_vowels_word = "" # Count the number of vowels in each word for word in words: num_vowels = 0 [instruction] | Write an algorithm that returns the word with the most vowels in the sentence. [input] | The quick brown fox jumps over the lazy dog.

[output] | my_list = [2, 4, 6, 8] # Create an empty dict my_dict = {} # Add elements to the dict for i in my_list: my_dict[i] = i**2 print(my_dict) # prints {2: 4, 4: 16, 6: 36, 8: 64} [instruction] | Create a dictionary that has the keys and values of a given list. [input] | my_list = [2, 4, 6, 8]

[output] | def find_next_prime(num): # check for all the numbers starting from num for number in range(num+1, num + 1000): # iterate from 2 to number for factor in range(2, number): # check if the number is prime if number % factor == 0: break [instruction] | Write a function to find the first prime number after the given number. [input] | num = 5

[output] | my_string = "This is a test string" delimiter = " " # use str.split() to split the string splitted = my_string.split(delimiter) print(splitted) # prints ['This', 'is', 'a', 'test', 'string'] [instruction] | Split a given string according to the given delimiter. [input] | my_string = "This is a test string" delimiter = " "

[output] | result = a[::-1] [instruction] | Store the output of the following statement into a variable called `result`. [input] | a = [1, 2, 3]

[output] | h1 { font-family: 'Roboto'; } [instruction] | Write a CSS rule to set the font family of all <h1> tags to be "Roboto". [input] |

[output] | A. print(1, 1, 2, 3, 5) B. print(0, 1, 2, 3, 5) C. print(1, 1, 3, 5, 8) D. print(0, 1, 1, 2, 3) D. print(0, 1, 1, 2, 3) [instruction] | Underline the correct option regarding the statement below A Python code to print the first 5 Fibonacci numbers is: [input] |

[output] | public class LinearSearch { // This function returns index of element x in arr[] static int search(int arr[], int x) { int n = arr.length; for(int i = 0; i < n; i++) { if(arr[i] == x) return i; } return -1; [instruction] | Write a Java program to perform a linear search on a given array to find a given number. [input] | array = [23, 54, 12, 64, 76, 13, 45] to_find = 45

[output] | import java.util.HashMap; public class FruitMap { public static void main(String args[]) { // Creating a HashMap of fruit name // and their corresponding prices HashMap<String, Double> fruitMap = new HashMap<>(); // Mapping string values to doub [instruction] | Create a HashMap in Java which contains the name of fruits and their corresponding prices. [input] | Mango - $2.4, Orange - $1.4, Apple - $3.2

[output] | # Boolean expression # Checks to see if x is a multiple of 5 def is_multiple_of_5(x): return x % 5 == 0 [instruction] | Create a Boolean expression in Python to check if a number is a multiple of 5. [input] |

[output] | <!DOCTYPE html> <html> <head> <title>Two columns of numbers from 1 to 10</title> </head> <body> <h1>Two columns of numbers from 1 to 10</h1> <table> <tr> <th>Column 1</th> <th>Column 2</th> </tr> <tr> <td>1</td> <td>6</td> </t [instruction] | Create an HTML page that displays two columns consisting of the numbers 1 to 10. [input] |

[output] | import tensorflow as tf from tensorflow.keras.layers import Dense, Flatten from tensorflow.keras.models import Sequential # Load the MNIST data (x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data() # Normalizing the intensities x_train = x_train/255 x_test = x_test/255 # Buil [instruction] | Create a tensorflow model that recognizes handwritten digits from the MNIST dataset. [input] |

[output] | .myElement { width: 100px; height: 100px; background-color: yellow; } [instruction] | Create a CSS class for an element with the size of 100px X 100px and a background color of yellow. [input] |

[output] | my_list = [2, 4, 6, 8] [instruction] | Manipulate a given list in Python where every element in the list has to be doubled. [input] | my_list = [1, 2, 3, 4]

[output] | $result = 5 * 10 - 3; [instruction] | Calculate the result of the expression 5*10-3 in PHP. [input] |

[output] | div { height: 50px; width: 100px; border-radius: 10px; } [instruction] | Design a CSS layout for a div with height of 50px, width of 100px and a rounded-corner of 10px. [input] |

[output] | SELECT ItemName, ItemPrice FROM Orders; [instruction] | Create a MySQL query to get the item names and their respective prices from the table "Orders". [input] |

[output] | def find_index(list_of_strings, target_string): for i, string in enumerate(list_of_strings): if string == target_string: return i return -1 [instruction] | Generate a Python function to get the index of a given string from a list of strings. [input] | list_of_strings = ["apple", "banana", "cherry"]

[output] | using System; public class Program { public static void Main() { Console.WriteLine(DateTime.Now); } } [instruction] | Make a C# program which prints the current date and time. [input] |

[output] | db.collection.find({"city": "Berlin"}) [instruction] | Write a query in MongoDB to find all documents with the value of field "city" as "Berlin". [input] |

[output] | <html> <head> <title>MyPage</title> </head> <body> <header> <h1>Welcome to My Page</h1> </header> <section> Content in Section 1 </section> <section> Content in Section 2 </section> </body> </html> [instruction] | Design a HTML page with a header and 2 sections [input] |

[output] | function modulus(dividend, divisor) return dividend % divisor end modulus(12, 5) [instruction] | Compute the modulus of 12/5 using a Lua function. [input] |

[output] | class MyClass { var name: String func printName() { print(name) } } [instruction] | Description a Swift class with one variable "name" and one method "printName()". [input] |

[output] | SELECT COUNT(*) FROM table_name; [instruction] | Write a MySQL query statement that find the total number of records in a table. [input] |

[output] | def fahrenheit_to_celsius(temperature): """ This function converts temperatures in Fahrenheit to Celsius. """ celsius = (temperature - 32) * 5/9 return celsius if __name__ == '__main__': temperature = float(input('Enter temperature in Fahrenheit: ')) print('Temperature [instruction] | Create a Python script that converts temperatures from Fahrenheit to Celsius. [input] |

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