← 목록

Synth · CodeAlpaca일부

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

[output] | class HelloWorld { public static void main(String args[]) { System.out.println("Hello world!"); } } [instruction] | Modify the following Java program to print "Hello world!" without using a System.out.print statement. [input] | class HelloWorld { public static void main(String args[]) { System.out.print("Hello world!"); } }

[output] | console.log("Hello world!"); [instruction] | Write a line of code to display a text message in the console saying "Hello world!". [input] |

[output] | def find_two_numbers(my_list, sum): for i in range(len(my_list)): for j in range(i + 1, len(my_list)): if my_list[i] + my_list[j] == sum: return my_list[i], my_list[j] find_two_numbers(my_list, sum); [instruction] | Write a code to find the first two numbers in a list that add up to a given number. [input] | my_list = [1, 2, 5, 6, 10] sum = 8

[output] | import string import random def generate_password(): password_characters = string.ascii_uppercase + string.ascii_lowercase + string.digits password_length = 16 return ''.join(random.choice(password_characters) for i in range(password_length)) generate_password() [instruction] | Create a script to generate a random password using uppercase, lowercase and numerics. [input] |

[output] | function findObject(list, find_name) { for(let i = 0; i < list.length; i++){ if(list[i].name == find_name){ return list[i]; } } return null; } findObject(list, find_name) [instruction] | Write a JavaScript code to find a value in an array of objects and return the object with that value. [input] | list = [{name:"John", age:"22"}, {name:"Peter", age:"40"}, {name:"Anne", age:"32"}]; find_name = "John"

[output] | let john = { name: 'John', }; [instruction] | Create an object that holds the property 'name', assigned to the value "John". [input] |

[output] | let inputString = "HELP! Is it me you're looking for??"; let outputString = inputString.replace(/[.,\/#!$%\^&\*;:{}=_`'"<>~]/g,"").toLowerCase(); console.log(outputString); // help is it me youre looking for [instruction] | Take the following input string and remove the punctuation and convert it to lowercase. [input] | HELP! Is it me you're looking for??

[output] | SELECT AVG(Height) FROM Employees; [instruction] | Compute the average height of the employees in the table. [input] |

[output] | def longest_common_substring(list1, list2): longest_substring = 0 for i in range(len(list1)): for j in range(len(list2)): if list1[i] == list2[j]: current_substring = 1 k, l = i+1, j+1 while k < len(list1) and l < len(list2) [instruction] | Generate a function in python that takes two lists and returns the product of their longest common substrings. [input] | list1 = [1, 2, 3, 4, 5] list2 = [2, 3, 5, 7]

[output] | def area(shape): if shape == "rectangle": length = float(input("Please enter the length: ")) width = float(input("Please enter the width: ")) return length * width elif shape == "triangle": base = float(input("Please enter the base: ")) height = float [instruction] | Suggest a code in Python that will calculate the area of any given shape. [input] |

[output] | pattern = r"[^\d]+" [instruction] | Create a regular expression pattern to match strings that contain any character except digits. [input] |

[output] | def is_balanced(expression): open_paratheses = 0 for char in expression: if char == '(': open_paratheses += 1 elif char == ')': open_paratheses -= 1 if open_paratheses < 0: return False return open_paratheses == 0 expression = "((A+B)-C)*D+((E-F)*G" [instruction] | Write a function to check if the parentheses in given expression are balanced or not. [input] | expression = "((A+B)-C)*D+((E-F)*G"

[output] | def create_list(a, b): result = [] for i in range(a, b+1): if i not in result: result.append(i) return result a = 0 b = 5 [instruction] | Generate a list of unique numbers between A and B where both A and B are input parameters. [input] | a = 0 b = 5

[output] | db.users.find({"name": "John"}) [instruction] | Write a query in MongoDB to find all documents in the 'users' collection that have a field 'name' with the value 'John'. [input] |

[output] | Functional Programming is a programming paradigm that emphasizes the use of functions, or predefined sequences of commands, to produce desired results. This paradigm tries to avoid state and mutable data, and instead use higher-order functions to pass functions as arguments. This makes it easier to [instruction] | Explain the functional programming paradigm. [input] |

[output] | SELECT name FROM customers ORDER BY name ASC; [instruction] | Create a SQL query to list all customer names from the table "customers" in ascending alphabetical order. [input] |

[output] | def factorial(num): """Function to return the factorial of a positive integer""" if(num <=1): return 1 else: return(num*factorial(num-1)) [instruction] | Create a function in Python to take a positive integer and return its factorial. [input] | num = 5

[output] | def create_frequency_table(words): """ Function to create a frequency table for a given list of words. Arguments: words {list}: List of words. Returns: dictionary: Frequency table of words. """ frequency_table = dict() for word in words: [instruction] | Create a Python function to return the frequency table of a list of words. [input] | words = ["apple", "mango", "cherry", "banana", "apple", "mango"]

[output] | You can determine the number of words in a string by splitting the string into single words using the split() method and using the len() method to find the length of the resulting list. [instruction] | How can you determine the number of words in a string? [input] |

[output] | import re email_list = [] for text in text_list: emails = re.findall(r'[\w\.-]+@[\w\.-]+', text) email_list.extend(emails) [instruction] | Write a regular expression to extract emails from a list of text. [input] | text_list = ["contact me at jack@example.com for more information", "reach out to jill@example.com for a discussion"]

[output] | def find_unique_values(L): """ Function to find all the unique values in a list. Arguments: L {list}: The list to search in. Returns: set: The set of unique values. """ unique_values = set() for item in L: if item not in unique_values: [instruction] | Create a Python function to find all unique values in a list. [input] | L = [1, 2, 4, 2, 1]

[output] | for char in reversed(string): print(char, end="") [instruction] | Edit the code to print out a string in reverse order. [input] | string = "Hello World!"

[output] | def get_common_elements(list1, list2): """ Function to get all the common elements in two lists. Arguments: list1 {list}: The first list. list2 {list}: The second list. Returns: list: A list containing all the common elements in both lists. """ [instruction] | Create a Python code to print out all the common elements in two lists. [input] | list1 = [1, 2, 3, 4, 5] list2 = [2, 3, 4, 6]

[output] | class Student { private: string name; int age; string address; public: void setName(string name); void setAge(int age); void setAddress(string address); string getName(); int getAge(); string getAddress [instruction] | Create a c++ class to store data for a student including their name, age, and address. [input] |

[output] | CREATE TABLE users ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, email VARCHAR(255) NOT NULL UNIQUE, name VARCHAR(255) NOT NULL, age INT NOT NULL, ); [instruction] | Design a database table to store user information such as an email address, name, age, etc [input] |

[output] | Function sumArray (arr[]) { sum = 0 for i = 0 to arr.length - 1 sum += arr[i] end for return sum } [instruction] | Generate an algorithm in any language that can find the sum of the numbers in a given array [input] |

[output] | $ (document).ready (function () { $("element").mouseover(function () { $(this).hide(); }); }); [instruction] | Implement a jQuery code for the following purpose [input] | Make an element hide when mouse moves over it

[output] | <button type="button" onclick="alert('Pop up window')">Click Me!</button> [instruction] | Create a javascript code to open a pop-up window when a user clicks the button [input] |

[output] | <html> <head> <title>Page counter</title> <script> var count = 0; function countClick(){ count++ document.getElementById("count").innerHTML = count; } </script> </head> <body> <h1>Page vi [instruction] | Design a HTML page to show a page counter [input] |

[output] | DELETE FROM TABLE_NAME; [instruction] | Design a MySQL query to delete all records in a specified table [input] |

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