← 목록

Synth · CodeAlpaca일부

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

[output] | The task of the program is to sort a list of integers. The input is a list of integers which needs to be sorted in ascending order. The output is another list with the same elements but sorted in ascending order. [instruction] | Describe the tasks and input of a program to sort a list of integers [input] |

[output] | word_list = [word for word in my_string.split() if len(word)>4] [instruction] | Generate a list of all words in the input string longer than 4 characters. [input] | my_string = "This is a sentence"

[output] | import requests from bs4 import BeautifulSoup def fetch_title(): page = requests.get('http://example.com') content = page.content soup = BeautifulSoup(content, 'html.parser') return soup.title.string [instruction] | Write a code to fetch the title of a web page [input] |

[output] | import numpy as np [instruction] | Import the numpy library into the program [input] |

[output] | x_val = 3 eq_val = x_val**2 + 4*x_val + 5 print(eq_val) # Output: 32 [instruction] | Find the value of $x^2 + 4x + 5$ when $x = 3$ [input] |

[output] | list1 = [] for i in range(1, n+1, 10): list1.append(i) [instruction] | Create a list of integers from 1 to n in steps of 10 [input] | n = 50

[output] | def miles_to_km(miles): return miles * 1.609 converted_km = miles_to_km(7) print(converted_km) [instruction] | Write a function in Python to convert miles to kilometers. [input] | 7

[output] | let num1 = 5; let num2 = 10; let num3 = 3; let maxNum = Math.max(num1, num2, num3); console.log("The maximum number of the three numbers given is " + maxNum); [instruction] | Write a JavaScript program to find the maximum number from the given three numbers. [input] | 5, 10, 3

[output] | public static int calculateCombinations(List<String> items){ int totalCombinations = 0; for(int i = 0; i < Math.pow(2, items.size()); i++){ int count = 0; String combination = ""; for(int j = 0; j < items.size(); j++){ [instruction] | Write a function in Java to calculate the total number of possible combinations of a given list of items. [input] | [‘cat’, ‘dog’, ‘horse’]

[output] | list_nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [instruction] | Create a list in Python of all integers from -5 to 10. [input] |

[output] | #include<stdio.h> int main() { char c = '$'; if ( (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ) { printf("The character is an alphabet."); } else if (c >= '0' && c <= '9') { printf("The character is a digit."); } else { printf("Th [instruction] | Write a code in C to identify the character type of a given character. [input] | $

[output] | let sortedArray = [9, 7, 5, 3, 1]; [instruction] | Sort this numeric array in descending order [input] | Array: [3, 7 ,1, 5, 9]

[output] | let retrievedElements = [50, 70, 90]; [instruction] | Retrieve the elements from the second index to the fourth index in the given array [input] | Array: [10, 20, 50, 70, 90, 100]

[output] | for (let i = 10; i <= 15; i++) { console.log(i); } [instruction] | Construct a for-loop statement to display the numbers counting from 10 to 15 [input] |

[output] | SELECT Name, Address FROM Customers; [instruction] | Formulate a SQL query to select the name and address of the customers from the database [input] |

[output] | let regex = /[aeiou]/i; [instruction] | Generate a regex to check if a given string contains any vowels [input] |

[output] | switch (input) { case "Nick": return "Nick"; break; case "Jack": return "Jack"; break; default: return "Invalid Input"; } [instruction] | Construct a switch statement to return either "Nick" or "Jack" base on the value of the input [input] | Input: "Nick"

[output] | class Circle { constructor(radius) { this.radius = radius; } getArea() { return Math.PI * this.radius * this.radius; } getCircumference() { return 2 * Math.PI * this.radius; } } [instruction] | Design a class to represent a Circle with a radius [input] |

[output] | import random import string def get_random_string(stringLength=10): letters = string.ascii_lowercase return ''.join(random.choice(letters) for i in range(stringLength)) randomString = get_random_string() print(randomString) # outputs a random string of length 10 [instruction] | Produce a Python script that generates a random string of length 10 [input] |

[output] | let num = 80; if (num >= 70) { console.log("Passed"); } else { console.log("Failed"); } [instruction] | Design an if-else statement to print either "Passed" or "Failed" depending on the value of the given number [input] | Number: 80

[output] | class TemperatureConverter: def celsius_to_fahrenheit(self, celsius): fahrenheit = (celsius * 9/5) + 32 return fahrenheit [instruction] | Convert the following code to Python and make it object-oriented. [input] | function celsius_to_fahrenheit(celsius) { let fahrenheit = (celsius * 9/5) + 32 return fahrenheit }

[output] | class Stack(): def __init__(self): self.stack = [] # Inserts an element in the stack def push(self, item): self.stack.append(item) # Return the maximum element in a stack def max_stack(self): max_elem = self.stack[0] for i in range(1,len(self [instruction] | Create a class 'Stack' that has a method 'max_stack' that returns the maximum element in the stack. [input] |

[output] | class MyDict(dict): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) def __getitem__(self, key): if key in self: return super().__getitem__(key) else: return None [instruction] | Create a class "MyDict" that inherits from the Python built-in "dict" class. [input] |

[output] | def print_fibonacci(n): a = 0 b = 1 for i in range(n): print(a, end=' ') temp = a a = b b = temp + b # The output of the function would be # 0 1 1 2 3 5 8 [instruction] | Create a function to print out the Fibonacci numbers starting from 0 to the nth number. [input] | n = 7

[output] | var employees = from e in Employee where e.Age > 30 && e.Country == "United States" select e; [instruction] | Write a LINQ query to find employees whose age is over 30 and are from the United States. [input] |

[output] | import numpy as np # Create a matrix with 5 rows and 7 columns matrix = np.random.rand(5,7) [instruction] | Generate a matrix with 5 rows and 7 columns containing random numbers in it. [input] |

[output] | h1, h2, h3, h4, h5, h6 { font-size: 2em; } [instruction] | Write a CSS code snippet to change the font-size of all the headings to double the original size. [input] |

[output] | var employees = from e in Employee where e.Country == "India" || e.Country == "Canada" select e; [instruction] | Write a LINQ query to retrieve records from employee list which are from either India or Canada. [input] |

[output] | [13, 21] [instruction] | Slice the following array to get the last two numbers. [input] | [2, 3, 9, 12, 13, 21]

[output] | Boolean, Boolean, Integer, String. [instruction] | Identify the type of data present in the given JSON string. [input] | String: [true, false, 0, "Sample String"]

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