← 목록

Synth · CodeAlpaca일부

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

[output] | num1 = 4 num2 = 6 result = (num1 + num2) * num2 print(result) [instruction] | Write a Python program that adds two numbers and multiplies them. [input] | 4, 6

[output] | def get_sum(arr): sum = 0 for item in arr: sum += item return sum [instruction] | Edit the given function so that it returns the sum of all numbers in the input array. [input] | def get_sum(arr): return arr[0]

[output] | let inputArray = ['Hello', 'World', '!']; for (let i = 0; i < inputArray.length; i++) { console.log(inputArray[i]) } [instruction] | Write a JavaScript program that takes an array as input and prints its contents. [input] | ['Hello','World','!']

[output] | false [instruction] | Read the code and determine if it will cause a memory leak. [input] | int* numbers = new int[10]; delete[] numbers

[output] | <html> <head> <title>My Web Page</title> </head> <body> <h1>My Web Page</h1> <p>This is my web page. It has a header and a paragraph.</p> </body> </html> [instruction] | Create a web page with a header and a paragraph, both with some text. [input] |

[output] | <div style="display:flex;"> <div style="flex: 1;">Left</div> <div style="flex: 1;">Right</div> </div> [instruction] | Rebuild the provided code using CSS flexbox. [input] | <div> <div style="float:left;width:50%;">Left</div> <div style="float:right;width:50%;">Right</div> </div>

[output] | [1, 2, 3, 4, 7, 8] [instruction] | Imagine you have an array with the following elements: [3, 7, 2, 8, 1, 4]. Sort the array so that the elements are in ascending order. [input] |

[output] | public class RandomNumberGenerator { public static int generateNumber() { Random rand = new Random(); return rand.nextInt(10) + 1; } } [instruction] | Create a random number generator in Java that produces a random integer between 1 and 10. [input] |

[output] | import re string = re.sub(r'[^\w\s]','',string) print(string) # Output: This is a test string [instruction] | Write an expression in Python to remove all punctuation from a given string. [input] | string = "This, is a test string!"

[output] | const getMonday = week => { let now = new Date(); let day = now.getDay(); let diff = now.getDate() - day + (day === 0 ? -6 : 1); // adjust when day is sunday let monday = new Date(now.setDate(diff + (week - 1) * 7)); return monday.toISOString(); } let result = getMonday(week); consol [instruction] | Write a JavaScript function to get monday's date of a given week. [input] | week = 34

[output] | [1, 8, 27, 64, 125, 216, 343, 512, 729, 1000] [instruction] | Create a list containing the cubes of first 10 numbers. [input] |

[output] | sorted_users = sorted(users, key=lambda user: user['name']) [instruction] | Sort the users in alphabetical order by their name. [input] | users = [{'name': 'John', 'age': 25}, {'name': 'Alice', 'age': 28}, {'name': 'Bob', 'age': 39}]

[output] | import xml.etree.ElementTree as ET tree = ET.parse('data.xml') root = tree.getroot() node_list = [] for child in root: node_list.append(child.tag) [instruction] | Parse an XML document and store the node names in a list. [input] |

[output] | def prime_numbers(): prime_nums = [] for i in range(10, 50): is_prime = True for j in range(2, i): if i%j ==0: is_prime = False break if is_prime: prime_nums.append(i) return prime_nums [instruction] | Generate an array of numbers containing only prime numbers between 10 and 50. [input] |

[output] | def fibonacci(n): if n<0: print("Incorrect input") elif n==1: return 0 elif n==2: return 1 else: return fibonacci(n-1)+fibonacci(n-2) [instruction] | Write a function that uses recursion to return the Fibonacci of a given number. [input] |

[output] | def square_number(number): return number**2 print(square_number(number)) [instruction] | Write a function to square a given number and return its result. [input] | number = 5

[output] | def get_max_min_avg(number_list): max_num = max(number_list) min_num = min(number_list) average = sum(number_list) / len(number_list) return (max_num, min_num, average) max_num, min_num, average = get_max_min_avg(number_list) print("Maximum number is:", max_num) print("Minimu [instruction] | Write a code to calculate the maximum, minimum, and average of five numbers. [input] | number_list = [2, 4, 6, 8, 10]

[output] | I'm starting to enjoy programming more. [instruction] | Edit the following sentence to change its sentiment from negative to positive. [input] | I can't stand programming anymore.

[output] | Buy? No -----------> No / \ No Yes / \ Age/Income Car = Yes 0-25/0-25k ------------> Yes / \ No >25k --------> Yes / No ----------------> No [instruction] | Construct a decision tree for a given dataset [input] | Age | Income | Car | Buy? 0-25 | 0-25k | No | No 26-45| 0-25k | No | No > 45 | 0-25k | No | No 0-25 | >25k | No | Yes 26-45| >25k | No | Yes > 45 | >25k | No | Yes 0-25 | 0-25k | Yes | Yes 26-45| 0-25k | Yes | Yes > 45 | 0-25k | Yes | No

[output] | 5 * (7 + 9) - 12 = 5 * 16 - 12 = 80 - 12 = 68 [instruction] | Assign the correct operator precedence to the given expression. [input] | 5 * (7 + 9) - 12

[output] | 16 / \ 9 7 /\ /\ 5 4 3 2 / /\ / / G P T EP (E stands for empty) [instruction] | Construct a Huffman tree for the following set of characters. [input] | Character | Frequency G | 5 P | 9 T | 12

[output] | Creating a new thread in Java is quite simple. The new thread can be created by extending the Thread class and overriding the run() method. Example: public class MyThread extends Thread { @Override public void run() { // logic to be executed in the new thread } } // Create the new [instruction] | Create a new Java thread. [input] |

[output] | Using the string.ascii_lowercase constant, an array containing the alphabet in lowercase can be created. Example: import string alphabet_array = list(string.ascii_lowercase) print("Array containing the alphabet in lowercase:", alphabet_array) # Output: Array containing the alphabet in lowercas [instruction] | Create an array containing the alphabet in lowercase in Python. [input] |

[output] | Using a loop and mathematical operators, the sum of all the digits in a given number can be found in Java. Example: int number = 1234; int sum = 0; while(number > 0) { int digit = number % 10; sum += digit; number /= 10; } System.out.println("The sum of all the digits is "+ [instruction] | Find the sum of all the digits in a given number in Java. [input] | Number: 1234

[output] | Using the parseInt() built-in method, the given string can be converted to a number in JavaScript. Example: let str = "42"; let num = parseInt(str); console.log("Number:", num); // Output: Number: 42 [instruction] | Convert the given string to a number in JavaScript. [input] | String: "42"

[output] | def count_character_in_strings(strings, character): count = 0 for string in strings: if character in string.lower(): count += 1 return count [instruction] | Given a list of strings and a single character, write a Python function to return the count of strings containing that character. [input] | strings = ["Hello", "World", "Cat", "Dog", "Elephant"] character = "e"

[output] | SELECT * from employees WHERE salary > 1000 and state = 'Texas'; [instruction] | Write a SQL query to list all employees who earn more than $1000 per month and reside in Texas. [input] |

[output] | # models.py from django.db import models class Profile(models.Model): user = models.OneToOneField("auth.User", on_delete=models.CASCADE) first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100) birth_date = models.DateField() # views.py from djan [instruction] | Design a Django web application to store user profiles. [input] |

[output] | <?php $sum = 0; foreach($nums as $num) { $sum += $num; } echo $sum; ?> [instruction] | Write a PHP code snippet to sum up all numbers in an array. [input] | $nums = [1, 5, 10, 15, 20]

[output] | /(.*?),(.*?),(\d+)/ [instruction] | Design a regular expression to extract first name, last name, and age from the following comma-separated string. [input] | Marley,Bob,32

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