← 목록

Synth · CodeAlpaca일부

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

[output] | for i in range(1, 11): print(i) [instruction] | Edit the code given below to make it print the numbers from 1 to 10 in increasing order. [input] | for i in range(10): print(i)

[output] | """ Write a code to generate a random 7 digit phone number. """ import random def generate_random_phone_number(): # create a list of digits lst = [str(i) for i in range(10)] # randomly select one digit random.shuffle(lst) # generate a 7-digit phone number phone_nu [instruction] | Write a code to generate a random 7 digit phone number. [input] |

[output] | One way to find the longest word which can be constructed from a set of characters is by using a trie data structure. To do this, first create the trie from the given dictionary of words, then traverse it to look for the longest word which can be constructed from the given set of characters. At each [instruction] | Given a dictionary of words and a set of characters, how would you find the longest word which can be constructed from the given set of characters? [input] |

[output] | d = {'name': 'seth', 'age': '30', 'occupation': 'manager'} [instruction] | Parse the given string and return a dictionary with the keys and corresponding values. [input] | s = "name seth age 30 occupation manager"

[output] | res = list_of_words(str) res = ['This', 'is', 'a', 'sentence.'] [instruction] | Convert a sentence into a list of words using the provided function. [input] | str = "This is a sentence."

[output] | for i in lst: if i % 2 == 0: print(i) [instruction] | Create a loop that prints out the even numbers from the given list. [input] | lst = [1, 2, 3, 4, 5]

[output] | String pattern = "[A-Za-z0-9_]+"; [instruction] | Convert this regex expression from python to java syntax. [input] | pattern = r"[A-Za-z0-9_]+"

[output] | def gen_list(n): list = [] for i in range(1, n+1): list.append(i) return list [instruction] | Generate a list of length n containing all numbers from 1 to n. [input] |

[output] | array = list(map(lambda x: x**2, array)) [instruction] | Using an existing function, update the given array of numbers to contain elements which are the square of each original element. [input] | array = [1,2,3,4,5]

[output] | def permutations(array): if len(array) == 0: return if len(array) == 1: return [array] perms = [] for i in range(len(array)): elem = array[i] rem_perms = permutations(array[:i] + array[i+1:]) for perm in rem_perms: perms.append([ele [instruction] | Print all permutations of an input array. [input] | array = [1,2,3]

[output] | def pig_latin(string): vowels = "aeiou" if string[0].lower() in vowels: return string+"way" else: return string[1:]+string[0]+"ay" [instruction] | Convert a given string into Pig Latin. [input] | string = "Hello"

[output] | System Class Diagram: [![system class diagram](https://i.ibb.co/MfXN7xN/system-class-diagram.png)] Database Class Diagram:[![database class diagram](https://i.ibb.co/6WHWKV8/database-class-diagram.png)] [instruction] | Generate the class diagrams for a System class and a Database class. [input] | <nopinput>

[output] | for i in range(1,6): print(i) [instruction] | Construct a for loop in Python to output the numbers from 1 to 5. [input] |

[output] | class Math: def __init__(self, x, y): self.x = x self.y = y def average(self): return (self.x + self.y) / 2 [instruction] | Create a class in Python called Math that can calculate the average of two numbers. [input] |

[output] | Static variables are associated with a class and are shared by all the objects of that class; in other words, they are class-level variables. Instance variables are associated with each object and their values can be different for each object. Static variables exist throughout the execution of the p [instruction] | Compare and contrast the difference between static and instance variables. [input] |

[output] | SELECT * FROM employees; [instruction] | Write a SELECT statement in SQL that retrieves all rows from the table "employees". [input] |

[output] | Language models are used in natural language processing to enable machines to understand and generate natural language. Language models assign a probability to a sequence of natural language words to improve the accuracy of predictions in language processing tasks. They are used for automatic speech [instruction] | Describe how language models can be used in natural language processing. [input] |

[output] | A Python tuple is an immutable sequence of objects which is ordered and indexed. Tuples are usually used to store collections of data that are related, but may be of different data types. Tuples are used instead of lists because they are more memory efficient and can be used as elements of sets and [instruction] | What is a Python tuple? [input] |

[output] | if (num % 2 == 0): print("Number is even") else: print("Number is odd") [instruction] | Write an IF ELSE statement in Python to print either "Number is even" or "Number is odd" depending on the number input. [input] |

[output] | def print_triangle_of_stars(height) (1..height).each do |row| (1..row).each do print "*" end print "\n" end end [instruction] | Create a Ruby method to print a triangle of stars with a given height. [input] |

[output] | SELECT d.DepartmentName, COUNT(e.DepartmentId) AS TotalEmployees FROM Departments d INNER JOIN Employees e ON d.DepartmentId = e.DepartmentId GROUP BY d.DepartmentName [instruction] | Compose a SQL query that returns the total number of employees for each department in a given company. [input] |

[output] | import React from "react"; const Date = () => { const today = new Date(); const currentDay = today.getDay(); const dayList = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; return ( <div> {dayList[currentDay]}, {today.getFullYear()}/{today.getMon [instruction] | Create a React component that displays the current day of the week and date. [input] |

[output] | plot_histogram <- function(data) { hist(data, main = "Histogram of given data set") } [instruction] | Create an R function that plots a histogram of a given data set. [input] |

[output] | def remove_duplicates(x): res = [] for i in x: if i not in res: res.append(i) return res [instruction] | design a functions which removes the duplicate elements from a list [input] |

[output] | """ Extract the name of the given website link """ import re def extract_name(url): return re.search('https://www.(.*?).com', url).group(1) if __name__ == '__main__': url = "https://www.example.com" print(extract_name(url)) [instruction] | Extract the name of the given website link [input] | https://www.example.com

[output] | def return_length(): return 5 [instruction] | update the function to return the length of 5 [input] | def return_length(): return 0

[output] | def print_dict(d): queue = [key for key in d.keys()] while len(queue) > 0: key = queue.pop(0) print(d[key]) if __name__ == '__main__': my_dict = { 'a': 1, 'b': 2, 'c': 3 } print_dict(my_dict) [instruction] | print the values of a dictionary in first-in, first-out order [input] | my_dict = { 'a': 1, 'b': 2, 'c': 3 }

[output] | def is_prime(n): for i in range(2, n): if n % i == 0: return False return True if __name__ == '__main__': n = 13 print("Is {} prime? {}".format(n, is_prime(n))) [instruction] | Identify if the given number is prime [input] | n = 13

[output] | def postfix_to_infix(expression): stack = [] for c in expression.split(): if c in "+-*/": operand1 = stack.pop() operand2 = stack.pop() stack.append("({} {} {})".format(operand2, c, operand1)) else: stack.append(c) return st [instruction] | Write a postfix expression to an infix expression [input] | 3 4 + 5 *

[output] | <form> <label>Name: </label><input type="text" name="name"><br> <label>Age: </label><input type="number" name="age"><br> <label>Gender: </label><input type="text" name="gender"><br> <label>Address: </label><input type="text" name="address"><br> <input type="submit" value="Submit"> </form> [instruction] | Create a HTML form for inputting student data. [input] |

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