← 목록

Synth · CodeAlpaca일부

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

[output] | def add_two_numbers(a, b): return a + b [instruction] | Update the following code to fix a syntax error. [input] | def add_two_number(a,b): return a + b;

[output] | dic[key] = value [instruction] | Insert 'value' into the dictionary 'dic' at the key 'key'. [input] | dic = {'a':1, 'b':2} key = 'c' value = 3

[output] | def play_game(): options = ['rock', 'paper', 'scissors'] computer_choice = random.choice(options) user_choice = input('Choose "rock", "paper", or "scissors": ') if user_choice == computer_choice: print('It is a tie!') elif user_choice == 'rock': if computer_choic [instruction] | Write a function 'play_game' that plays a simple game of rock paper scissors. [input] |

[output] | class Fruit: def __init__(self, name, color, weight): self.name = name self.color = color self.weight = weight def print_info(self): print(f'Name: {self.name}') print(f'Color: {self.color}') print(f'Weight: {self.weight}') [instruction] | Create a class 'Fruit' to define a fruit. [input] |

[output] | <html> <body> <input type="text" id="myInput" autofocus /> <script type="text/javascript"> document.getElementById('myInput').focus(); </script> </body> </html> [instruction] | Edit the existing code to focus the cursor in the input field. [input] | <html> <body> <input type="text" id="myInput" /> <script type="text/javascript"> document.getElementById('myInput').focus(); </script> </body> </html>

[output] | x.append('z') [instruction] | Write a code snippet to add a new element 'z' at the end of list 'x'. [input] | x = [1, 2, 3]

[output] | s = 0 for num in l: s += num [instruction] | Write a loop to sum all the elements in list 'l'. [input] | l = [1, 2, 3, 4]

[output] | import numpy as np np.mean(arr) [instruction] | Using numpy, find the mean of array 'arr'. [input] | arr = [1, 2, 3, 4, 5]

[output] | CREATE DATABASE products; USE products; CREATE TABLE products ( id INTEGER UNIQUE, name VARCHAR(255), price DECIMAL(10, 2) ); [instruction] | Create a MySQL database and table based on the given information. [input] | Table name: products Fields: id (integer, unique), name (varchar), price (decimal)

[output] | print("kiwi") print("orange") print("banana") print("apple") [instruction] | Print the given array of strings in reverse order. [input] | ["apple", "banana", "orange", "kiwi"]

[output] | https://mypage.google.com/search [instruction] | Create a URL for the given information. [input] | Protocol: https Subdomain: mypage Domain: google Path: search

[output] | def parseJSON(input_json): book_record = input_json["products"]["book"] movie_record = input_json["products"]["movie"] book_title = book_record["title"] book_author = book_record["author"] movie_title = movie_record["title"] movie_director = movie_record["director"] [instruction] | Design a function to retrieve the records from a nested json structure. [input] | { "products": { "book": { "title": "Alice in Wonderland", "author": "Lewis Carol" }, "movie": { "title": "The Godfather", "director": "Francis Ford Coppola" } } }

[output] | #include<iostream> #include<algorithm> using namespace std; int main() { string s = "HELLO WORLD"; // Convert string s to lowercase letters transform(s.begin(), s.end(), s.begin(), ::tolower); cout << s << endl; return 0; } [instruction] | Modify the code so that it prints the given string in lowercase letters. [input] | String: "HELLO WORLD" Code: #include<iostream> using namespace std; int main() { string s = "HELLO WORLD"; cout << s << endl; return 0; }

[output] | #include <iostream> using namespace std; int main () { cout << "Hello World" << endl; return 0; } [instruction] | Debug the code and make sure it successfully prints out "Hello World". [input] | #include <iostream> using namespace std; void main () { cout << "Hello World" << endl; return 0; }

[output] | def findThreeHighest(arr): arr.sort() return arr[-1], arr[-2], arr[-3] [instruction] | Using the given data structure, find and return the 3 highest numbers. [input] | [2, 4, 8, 10, 6, 5, 7, 11]

[output] | String myString = "Hello"; String myCopyString = new String(myString); [instruction] | Create an object for making a copy of a string. [input] | String: "Hello"

[output] | def longestString(arr): longest_str = '' for s in arr: if len(s) > len(longest_str): longest_str = s return longest_str [instruction] | Find and return the longest string in the given array. [input] | ["hello", "how", "are", "you", "doing"]

[output] | for item in ["Apple", "Banana", "Orange"]: print(item) [instruction] | Create a for loop for looping through the elements of a given array. [input] | ["Apple", "Banana", "Orange"]

[output] | import matplotlib.pyplot as plt items = [x[0] for x in data] values = [x[1] for x in data] plt.bar(items, values) plt.show() [instruction] | Use the input data to create a bar chart. [input] | Data: [("Apple", 20), ("Samsung", 16), ("Google", 11), ("Sony", 14)]

[output] | def calculate_the_total(fruit_list): total = 0 for item in fruit_list: total += item import pdb; pdb.set_trace() return total [instruction] | Insert a breakpoint just before the return statement. [input] | def calculate_the_total(fruit_list): total = 0 for item in fruit_list: total += item return total

[output] | 4 lines of code. [instruction] | How many lines of code are in the given snippet? [input] | def print_list(my_list): for item in my_list: print(item)

[output] | def get_user_data(): username = input('Enter your desired username: ') email = input('Enter your email address: ') password = input('Enter a password: ') confirm_password = input('Confirm your password: ') # check if the passwords match if password != confirm_password: [instruction] | Create a program to enter the data for user registration. [input] |

[output] | for num in range(10, 30 + 1): # prime numbers are greater than 1 if num > 1: for i in range(2, num): if (num % i) == 0: break else: print(num) [instruction] | Print prime numbers in the given range. [input] | Lower range: 10 Upper range: 30

[output] | def sort_ascending(my_list): sorted_list = sorted(my_list) return sorted_list my_list = [4, 9, 8, 1, 5] sorted_list = sort_ascending(my_list) print(sorted_list) [instruction] | Create a program that sorts the integers in the input list into ascending order. [input] | List: [4, 9, 8, 1, 5]

[output] | The number of lines of code to print Fibonacci sequence of 30 numbers is 5. [instruction] | How many lines of code to print Fibonacci sequence of 30 numbers? [input] |

[output] | print("hello world") [instruction] | Print a message to the console " hello world ". [input] |

[output] | my_dict={ "webpage1": { "url": "https://www.example1.org", "title": "Example1.org" }, "webpage2": { "url": "https://www.example2.com", "title": "Example2.com" }, "webpage3": { "url": "https://www.example3.net", "title": "Example3.ne [instruction] | Create a nested dictionary with URLs and titles of 3 different webpages. [input] |

[output] | The reason for the failure of a unit test can be any number of things, including incorrect expectations, incorrect or missing test data, or a problem with the code being tested. It can also be due to a lack of suitable code coverage. In any case, it is important to identify the source of the failure [instruction] | What is the reason for the failure of a unit test? [input] |

[output] | # adding two matrices res = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] # iterating through rows for i in range(3): # iterating through columns for j in range(3): res[i][j] = mat1[i][j] + mat2[i][j] # printing the result for i in range(3): for j in range(3): print(res[i][j], en [instruction] | Add two matrices of size 3x3. [input] | mat1 = [[1,2,3], [4,5,6], [7,8,9]] mat2 = [[10,11,12], [13,14,15], [16,17,18]]

[output] | The best way to test for memory leaks in a C++ program is to use a memory profiler. Memory profilers can help identify memory leaks by monitoring how much memory is allocated, how often it is allocated, and whether or not the same or similar memory is being allocated multiple times. They can also tr [instruction] | What is the best way to test for memory leaks in a C++ program? [input] |

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