← 목록

Synth · CodeAlpaca일부

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

[output] | def format_date(date): date_list = date.split('-') formatted_date = date_list[2] + '-' + calendar.month_name[int(date_list[1])] + '-' + date_list[0] return formatted_date [instruction] | Write a function in Python to format a given date according to the format "Day-Name, Month Name, Day, Year". [input] | "2019-06-27"

[output] | # Class to store student and grades class StudentGrades: def __init__(self, student_name): self.student_name = student_name self.grades = {} def add_grade(self, course_name, grade): self.grades[course_name] = grade def get_total_grade(self): to [instruction] | Write a class in Python to store the objects of student and their grades. [input] |

[output] | The given text is translated into Japanese language. [instruction] | Identify the language into which the given text is translated. [input] | Text: いつもありがとう。

[output] | // Object to calculate the area of rectangular with length and width const rectangular = { length: 0, width: 0, area: function() { return this.length * this.width; } }; [instruction] | Create an object in JavaScript for calculating the area of rectangular with length and width. [input] |

[output] | Adverb: slowly Noun: frog Verb: kick [instruction] | Classify the following words as noun, verb, adverb or adjective. [input] | Words: slowly, frog, kick

[output] | import random hex_arr = [] for i in range(5): rand_hex = random.randint(0, 255) hex_arr.append(hex(rand_hex)) print(hex_arr) [instruction] | Generate an array of 5 random hexadecimal numbers. [input] |

[output] | 3 [instruction] | Count the number of lines of code in the following code snippet. [input] | def add(num1, num2): return num1 + num2

[output] | sum = a + b + c result = sum + 5 [instruction] | Find the sum of three numbers and add five to it. [input] | a = 4, b = 7, c = 10

[output] | arr = [[1,2], [3,4], [5,6]] [instruction] | Create a 2D array with three rows and two columns and assign different value to each element. [input] |

[output] | if x > y: print("x is greater than y") [instruction] | Compare the values of x and y, and print out "x is greater than y" if x is greater. [input] | x = 5, y = 3

[output] | log2(32) = 5 [instruction] | Calculate the base-2 logarithm of 32. [input] |

[output] | len(text.split()) # 4 [instruction] | Find the count of words in the following string. [input] | text = "This is a sample text"

[output] | if re.search('[a-zA-Z]', str) and re.search('[0-9]', str): print(True) else: print(False) [instruction] | Check if the input string contains both number and alphabets and return true if it does. [input] | str = "hello123"

[output] | SELECT * FROM Users WHERE age > 24; [instruction] | Create a PostgreSQL query to fetch all the rows from the table ‘Users’ where the users’ age is greater than 24. [input] | Table name: Users Columns: Id, age, name

[output] | <table> <tr> <th>Fruits</th> </tr> <tr> <td>Banana</td> </tr> <tr> <td>Apple</td> </tr> <tr> <td>Pineapple</td> </tr> <tr> <td>Mango</td> </tr> </table> [instruction] | Write a fragment in HTML to display the values of an array in a table. [input] | array = ["Banana", "Apple", "Pineapple", "Mango"]

[output] | SELECT * FROM Users WHERE name = 'John Smith'; [instruction] | Write an SQL query to find a user with the name ‘John Smith’. [input] | Table name: Users Columns: Id, name

[output] | public class VariableAssignment { private String variable; public VariableAssignment(String variable) { this.variable = variable; } public String getVariable() { return variable; } public void setVariable(String variable) { this.variable = variable; } } [instruction] | Create a class in Java that assigns a value to a given variable. [input] | String variable = "Hello world"

[output] | let topFiveCountries = ['China', 'India', 'United States', 'Indonesia', 'Brazil']; [instruction] | Create a list in JavaScript containing the names of the five most populous countries in the world. [input] |

[output] | app.get('/user/:username', async (req, res) => { let username = req.params.username; let userInfo = await User.findOne({ username }); res.json(userInfo); }); [instruction] | Create an API endpoint in ExpressJS that receives a username and returns the user’s information. [input] | User with the username "johnsmith"

[output] | SELECT * FROM Products WHERE price < 100; [instruction] | Write an SQL query to select all products where the price is less than 100 dollars. [input] | Table name: Products Columns: Id, name, price

[output] | <a href="http://example.com"><button>Go to example.com</button></a> [instruction] | Create a fragment of HTML that displays a button which redirects the user to a given URL. [input] | URL = "http://example.com"

[output] | public static boolean isPalindrome(String str) { int n = str.length(); for (int i = 0; i < n/2; i++){ if (str.charAt(i) != str.charAt(n-i-1)) return false; } return true; } [instruction] | Write a method in Java for checking if a String is a palindrome. [input] |

[output] | public static void printProduct(int n1, int n2){ System.out.println(n1 * n2); } [instruction] | Create a function in Java that takes two numbers as arguments and prints their product. [input] | 10 and 8

[output] | def heapsort(A): # step 1: create the heap heapify(A) # step 2: sort the heap for size in range(len(A), 1, -1): A[0], A[size - 1] = A[size - 1], A[0] sift_down(A, 0, size - 1) # step 3: return the sorted result return A [instruction] | Sort an array of integers using a heapsort algorithm. [input] | [3, 6, 2, 9, 1]

[output] | function reverseArray(arr) { let reversedArr = []; let index = arr.length - 1; while (index >= 0) { reversedArr.push(arr[index]); index--; } return reversedArr; } [instruction] | Write a function in JavaScript that takes a given array and prints its elements in reverse order. [input] | [1, 2, 3, 4]

[output] | SELECT MAX(value) AS max2 FROM mytable WHERE value < (SELECT MAX(value) FROM mytable); SELECT MAX(value) AS max3 FROM mytable WHERE value < (SELECT MAX(value) FROM mytable WHERE value < (SELECT MAX(value) FROM mytable)); [instruction] | Create a SQL query that selects the second and third largest values in a table. [input] |

[output] | #list of Weekdays weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] #print Weekdays for weekday in weekdays: print(weekday) [instruction] | Generate a program in Python that prints all days of the week [input] |

[output] | public static boolean charInString(char c, String str) { for (int i = 0; i < str.length(); i++) if (str.charAt(i) == c) return true; return false; } [instruction] | Implement a function in Java that takes a character and a string as arguments and determines whether the character is present in the string or not. [input] | 'c' and "programming"

[output] | p { font-size: 2em; font-weight: bold; color: orange; } [instruction] | Create a CSS program that formats the text in a paragraph so that it has the following characteristics: font size is 2em, font weight is bold, font color is orange. [input] |

[output] | function reverseString(str) { return str.split('').reverse().join(''); } [instruction] | Generate a program in JavaScript that reads a given string from user input and prints the characters of the string in reverse order. [input] |

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