← 목록

Synth · CodeAlpaca일부

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

[output] | print("HELLO WORLD".upper()) [instruction] | Print the "hello world" in uppercase. [input] |

[output] | dict1 = {'a': 'd', 'b': 'e', 'c': 'f'} [instruction] | Convert the given code to use a dictionary instead of lists. [input] | list1 = ['a', 'b', 'c'] list2 = ['d', 'e', 'f']

[output] | def absolute_value(x): if x < 0: return -x else: return x [instruction] | Write a function that takes a single parameter and returns the absolute value of the parameter. [input] |

[output] | str1 = str[:5] str2 = str[6:] print(str1) print(str2) [instruction] | Construct two strings from a given string and print these strings separately. [input] | str = "Hello World!"

[output] | public static int linearSearch(int[] x, int element) { for (int i = 0; i < x.length; i++) { if (x[i] == element) return i; } return -1; } [instruction] | Code a function in Java to search an array for a specific element. [input] | array x = [1, 4, 6, 8, 5] element = 5

[output] | SELECT MAX(price) FROM products; [instruction] | Using SQL, write a query to find the maximum price of a product in the database. [input] |

[output] | <html> <head> <title>Side by Side Paragraphs</title> <style> .column { float: left; width: 50%; } /* Clear floats after the columns */ .row:after { content: ""; display: table; clear: both; } </style> </head> <body> <div class="row"> <div class="colu [instruction] | Create a program in HTML to display the following two paragraphs side by side. [input] | P1: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. P2: Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

[output] | def replace_word(sentence, word, replacement): words = sentence.split(" ") new_sentence = "" for w in words: if w == word: w = replacement new_sentence += w + " " return new_sentence sentence = "I like apples" word = "apples" replacement = "bananas" prin [instruction] | Code a solution in Python to replace all the occurences of a specific word in a string. [input] | sentence = "I like apples" word = "apples" replacement = "bananas"

[output] | public static double avgOfFiveNums(int a, int b, int c, int d, int e) { double avg = (a + b + c + d + e) / 5.0; return avg; } [instruction] | Create an algorithm in Java to calculate the average of five numbers. [input] |

[output] | public static bool CheckChar(String input_string, char character) { bool found = false; foreach (char c in input_string) { if (c == character) { found = true; break; } } return found; } // Driver Code [instruction] | Create a program in C# to check if an input string contains a specific character or not. [input] | input_string = "Hello World" character = 'l'

[output] | def softmax(x): """Compute softmax values for each sets of scores in x.""" e_x = np.exp(x - np.max(x)) return e_x / e_x.sum(axis=0) [instruction] | Create a softmax activation function in Python. [input] |

[output] | for i in range(0,11): print(i) [instruction] | Create a for loop in Python for the range between 0 and 10. [input] |

[output] | import requests r = requests.get(url = "https://www.example.com") data = r.json() [instruction] | Write an API call in Python using the request module to get data from a URL. [input] | https://www.example.com

[output] | for i in range(0,4): for j in range(5,11): print("outer loop at: "+str(i)+" inner loop at: "+str(j)) [instruction] | Create a nested For loop in Python with the outer loop counting from 0 to 3 and the inner loop counting from 5 to 10. [input] |

[output] | CREATE TABLE table_name ( A VARCHAR(255) NOT NULL, B VARCHAR(255) NOT NULL, C VARCHAR(255) NOT NULL ); [instruction] | Write a SQL query to create a table with three columns called A, B, and C, where the data type for each column is defined as string. [input] |

[output] | db.collection.find({}).limit(3) [instruction] | Write a MongoDB query to get the first 3 documents in a collection of documents. [input] |

[output] | h = {} # Add key:value pairs h['key1'] = 'value1' h['key2'] = 'value2' h['key3'] = 'value3' [instruction] | Create a hash table in Python using a dictionary. [input] |

[output] | import json import plotly.graph_objs as go def create_chart(): data = json.load('data.json') males = 0 females = 0 male_ages = [0] * 100 females_ages = [0] * 100 # count males/females and age group for person in data: if person['gender'] == 'male': [instruction] | Create a user interface to display a chart showing the number of people of a certain gender and age group. [input] | Sample JSON data to be used: [ { "name": "John", "age": 25, "gender": "male" }, { "name": "Jane", "age": 22, "gender": "female" }, { "name": "Bob", "age": 28, "gender": "male" }, { "name": "Jill", "age": 24, "gender": "female" } ]

[output] | let favoriteNumber = [7, 9, 42]; const printNumber = (number) => console.log(number); for (let idx = 0; idx < favoriteNumber.length; idx += 1) { printNumber(favoriteNumber[idx]); } [instruction] | Edit the following JavaScript code to remove any warnings given by the linter. [input] | let favoriteNumber = [7,9,42]; const printNumber = (number) => console.log(number); for (let idx = 0; idx < favoriteNumber.length; idx +=1) { printNumber(favoriteNumber[idx]) }

[output] | def get_num_males(data): # create a counter variable num_males = 0 # loop through the data for person in data: if person['gender'] == 'male': num_males += 1 # return the number of males return num_males [instruction] | Use the given JSON data to create a function that returns the number of males in the dataset. [input] | Sample JSON data: [ { "name": "John", "age": 25, "gender": "male" }, { "name": "Jane", "age": 22, "gender": "female" }, { "name": "Bob", "age": 28, "gender": "male" }, { "name": "Jill", "age": 24, "gender": "female" } ]

[output] | class Person { // constructor constructor(name, age) { this.name = name; this.age = age; } // method to get the name getName() { return this.name; } // method to get the age getAge() { return this.age; } // method to set the [instruction] | Create a JavaScript class with 3 methods and a constructor [input] |

[output] | SELECT emp_id, name, department, doj, current_role FROM employees WHERE DATE_SUB(CURDATE(), INTERVAL 4 YEAR) <= doj; [instruction] | Create a SQL query to display the details of all employees who have served more than 4 years in their current role. [input] | Sample table: +------------+----------+------------+--------------+--------------------------+ | emp_id | name | department | doj | current_role | +------------+----------+------------+--------------+--------------------------+ | 101 | John | IT | 2

[output] | add: ; Function to add two integers ; Set stack frame push ebp mov ebp, esp ; Store the arguments on the stack mov eax, [ebp + 8] ; First argument mov ebx, [ebp + 12] ; Second argument ; Add them add eax, ebx ; Retrieve the stack fra [instruction] | Create a function to add two integers in assembly language. [input] |

[output] | for num in range(10): if num % 2 == 0: print(num); [instruction] | Suggest an edit to fix the following code snippet. [input] | for num in range(10): if num % 2 == 0 print(num);

[output] | <!DOCTYPE html> <html> <head> <title>My HTML Page</title> </head> <body> <h1>My Page Heading</h1> </body> </html> [instruction] | Create a new HTML page and add a heading to it. [input] |

[output] | SELECT * FROM Employees WHERE annual_income > 10000 [instruction] | Write a SQL query to find the employees with an annual income greater than 10000. [input] |

[output] | def char_exists_in_string(s1, s2): for char in s2: if char not in s1: return False return True if __name__ == '__main__': s1 = "hello world" s2 = "llo" print(char_exists_in_string(s1, s2)) [instruction] | Create a function in Python that takes two strings and checks if the characters in the second string exist in the first string. [input] | s1 = "hello world" s2 = "llo"

[output] | { "studentInfo": { "firstname": "John", "lastname": "Smith", "age": 18, "interests": ["music", "sports", "reading"] } } [instruction] | Create a JSON object to store student information like name, age, interests. [input] | { "firstname": "John", "lastname": "Smith", "age": 18, "interests": ["music", "sports", "reading"] }

[output] | let array = []; for (let i = 0; i < 10; i++) { let randomNumber = Math.floor(Math.random() * 100); let obj = { name: `element ${i + 1}`, value: randomNumber }; array.push(obj); } console.log(array); [instruction] | Create an array in JavaScript of objects, each with a name key and a value of a random number. [input] |

[output] | function compareDates(date1, date2) { const timeDifference = date1.getTime() - date2.getTime(); if(timeDifference > 0) { // date1 is after date2 return 1; } else { // date2 is after date1 return 0; } } if __name__ == '__main__': date1 = ne [instruction] | Compare two dates in JavaScript and return 1 if the first date is after the second date. [input] | date1 = new Date('August 19, 2025'); date2 = new Date('August 20, 2025');

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