← 목록

Synth · CodeAlpaca일부

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

[output] | my_dict = {} for item in my_list: my_dict[item['name']] = item['age'] print(my_dict) [instruction] | Create a dictionary for the attributes of each object in the list. [input] | my_list = [{"name": "John", "age": 20}, {"name": "Laura", "age": 30}, {"name": "Harry", "age": 25}]

[output] | my_words = my_string.split(' ') my_words = list(dict.fromkeys(my_words)) new_string = " ".join(my_words) print(new_string) [instruction] | Remove the duplicate words in the given string [input] | my_string = "this this is a a sentence"

[output] | def to_uppercase(str): return str.upper() new_string = to_uppercase(my_string) print(new_string) [instruction] | Create a function which returns a string of the given string in uppercase [input] | my_string = "this is a string"

[output] | def prepend_list_items(str, lst): for item in lst: print(str + item) prepend_list_items(my_string, my_list) [instruction] | Create a function which takes two arguments, a string and a list, and prints out the list with each element preceded by the string [input] | my_string = "Example: " my_list = ["a", "b", "c"]

[output] | import numpy as np from sklearn.linear_model import LinearRegression # fit the model model = LinearRegression() model.fit(X, y) # print the coefficients coeff = model.coef_ print(coeff) [instruction] | Run a regression on the given dataset and print the coefficients [input] |

[output] | <table> <thead> <tr> <th>Name</th> <th>Age</th> <th>Designation</th> </tr> </thead> <tbody> <tr> <td>John</td> <td>30</td> <td>Software engineer</td> </tr> <tr> <td>Alex</td> <td>35</td> <td>Tech lead</td> </tr> [instruction] | Create an HTML table from a list of dictionaries. [input] | [ {'name':'John','age':30, 'designation':'Software engineer'}, {'name':'Alex','age':35, 'designation':'Tech lead'}, {'name':'Jim','age':27, 'designation':'QA engineer'} ]

[output] | SELECT customers.customer_id, customers.name FROM customers INNER JOIN orders ON orders.customer_id = customers.customer_id WHERE orders.store_id = ? GROUP BY customers.customer_id HAVING COUNT(*) > 5; [instruction] | Write a SQL query to find all customers who purchased more than 5 items from a specific store. [input] |

[output] | class TwoInputsComponent extends React.Component { constructor(props) { super(props); this.state = { value1: '', value2: '' }; this.handleChange1 = this.handleChange1.bind(this); this.handleChange2 = this.handleChange2.bind(this); } handleChange1(e) { this. [instruction] | Create a React component with the following features: - Has two inputs - On entering content in the first input, it will automatically update the content in the second input [input] |

[output] | def analyze_text(text): text = text.lower().split() freqDict = {} for word in text: if word in freqDict: freqDict[word] += 1 else: freqDict[word] = 1 return freqDict if __name__ == '__main__': text = "This is a sample text to analyze the f [instruction] | Analyze a given text and generate a dictionary of frequency of each word in the text. [input] | text = "This is a sample text to analyze the frequency of the words"

[output] | The programming language used for the project is Python with Django web framework. Django is an open source framework for developing web applications. It uses the Model-View-Template architecture pattern for developing web applications. It provides useful features like built-in admin interface, secu [instruction] | Describe the programming language used for the given project [input] | Project: Building an e-commerce website using Django.

[output] | We can improve the code by adding an additional parameter to multiply() to check for a zero value of y. This additional "check" parameter will immediately return 0 if the value of y is 0, reducing the time complexity. Additionally, we can also remove the for loop and replace it with a multiplication [instruction] | How can we improve the following code? [input] | def multiply(x, y): z = 0 for i in range(y): z += x return z

[output] | func FindDuplicates(arr: [Int]) -> [Int] { var seenNumbers = Set<Int>() var duplicateValues = [Int]() for number in arr { if seenNumbers.contains(number) { duplicateValues.append(number) } else { seenNumbers.insert(number) } } return duplicateValues } [instruction] | Construct a loop in Swift to find duplicate numbers in an array. [input] |

[output] | class Node<T> { var value: T weak var parent: Node? var left: Node? var right: Node? init(value: T) { self.value = value } } class BinarySearchTree<T: Comparable> { fileprivate var root: Node<T>? init(elements: [T]) { for element in elements { [instruction] | Construct a generic BST in Swift [input] |

[output] | The result of the algorithm is [1, 2, 3]. This can be verified by manually sorting the array in an ascending order. [instruction] | Verify the result of the following algorithm [input] | Array: [3, 2, 1] Algorithm: Sort the array in ascending order

[output] | public class ReverseNumber { public static int reverseNumber(int num) { int reversed = 0; while(num > 0) { reversed *= 10; reversed += num % 10; num /= 10; } return reversed; } } [instruction] | Implement a method in Java to reverse a number [input] |

[output] | def binarySearch(list, item): low = 0 high = len(list) - 1 while low <= high: mid = (low + high) // 2 guess = list[mid] if guess == item: return mid if guess > item: high = mid - 1 else: low = mid + 1 ret [instruction] | Convert the following pseudocode into code that implements a binary search [input] | Input: Array, Item Set low to the first index of the array Set high to the last index of the array while low is less than or equal to high set mid to the average of low and high if the item is found at mid, then return mid else if the item is less than what is found at mid, set high to m

[output] | SELECT * FROM table_name; [instruction] | Construct a simple MySQL query [input] |

[output] | let sum = 0; for (let i = 2; i <= 6; i++) { sum += i * i; } console.log(sum); [instruction] | Construct a for loop in Javascript to measure the sum of the squares of integers from 2 to 6 [input] |

[output] | <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> <li>Item 4</li> </ul> [instruction] | Generate HTML code for displaying a list of items [input] |

[output] | import json data = [1,2,3] with open('my-json-file.json', 'w') as outfile: json.dump(data, outfile) [instruction] | How would you add the following list to a JSON document using Python? [1,2,3] [input] |

[output] | let animals = ["cat", "dog", "fish", "wolf"]; [instruction] | Build an array in JavaScript containing the words: "cat", "dog", "fish", and "wolf". [input] |

[output] | Classes are typically used to represent a database table in an object-oriented programming language. Each of the database table's columns can be represented as fields in the class. The values for those fields can then be accessed though the class' accessor methods. [instruction] | How do you represent a database table and its columns in an object-oriented programming language? [input] |

[output] | Multithreading in Java is a process which allows multiple threads to run concurrently, allowing applications to utilize multiple CPU cores and execute operations simultaneously. It helps to improve the performance of applications by allowing them to complete operations quickly and efficiently. [instruction] | What is multithreading in Java and why is it used? [input] |

[output] | SELECT name FROM Customers WHERE address = "London"; [instruction] | Create a SQL query to select the column "name" from the table "Customers" where the "address" column contains the value "London". [input] |

[output] | To delete an item from a linked list in Java, you would first need to traverse the list until you reach the item. Once you find the item, delete the reference to the node immediately before it by pointing the previous node's 'next' pointer to the node after the current one. Finally, delete the node [instruction] | How would you delete an item from a linked list in Java? [input] |

[output] | <form action="survey.php" method="post"> <label>Name:</label> <input type="text" name="name"><br> <label>Age:</label> <input type="number" name="age"><br> <label>What did you think of your school experience?</label> <input type="text" name="experience"><br> <label>Would you recommend y [instruction] | Write an HTML form for a survey about a school. [input] |

[output] | b { font-weight: bold; } [instruction] | Write a CSS code snippet to make all the <b> tags bold. [input] |

[output] | #include <iostream> using namespace std; int main() { int num1, num2, sum; cout << "Enter two numbers: "; cin >> num1 >> num2; sum = num1 + num2; cout << "Sum = " << sum; return 0; } [instruction] | Create a C++ program to input two numbers and print their sum. [input] |

[output] | def is_equal(parameter, string): if parameter == string: return True else: return False [instruction] | Generate a function to check if parameter is equal to a specific string. [input] |

[output] | SELECT * FROM customers WHERE country = 'France'; [instruction] | Write a SQL query to find all customers from France. [input] |

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