← 목록

Synth · CodeAlpaca일부

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

[output] | def is_prime?(num) is_prime = true for divisor in 2..(num-1) if (num % divisor == 0) is_prime = false break end end return is_prime end def primes_upto(m) primes = [] for n in 2..m primes << n if is_prime?(n) end return primes end [instruction] | Create a program in Ruby to print out all prime numbers up to a given positive integer m. [input] |

[output] | SELECT * FROM Users WHERE Age > 18; [instruction] | Select all records from the Users table whose age is greater than 18. [input] |

[output] | <html> <head> <title>My Page</title> </head> <body style="background-color: #FFFFFF;"> <h1>My Page</h1> </body> </html> [instruction] | Modify and update the given HTML code to include a background color. [input] | <html> <head> <title>My Page</title> </head> <body> <h1>My Page</h1> </body> </html>

[output] | print("Sorry, that's not correct. Please try again") [instruction] | Print out a message for an incorrect guess [input] |

[output] | [('Romeo', 'NOUN'), ('loves', 'VERB'), ('Juliet', 'NOUN'), ('.', 'PUNCT')] [instruction] | Analyze the following text and label each token [input] | Romeo loves Juliet.

[output] | Age = dic["age"] [instruction] | Extract a specific key-value pair from the given dictionary [input] | dic = {"Name": "John", "age": "27", "Address": "Street 79"}

[output] | maximum = lambda num1, num2: num1 if num1 > num2 else num2 [instruction] | Write a lambda expression to find the maximum value of two numbers. [input] |

[output] | class Fruit { private: string name; string color; public: Fruit(string name, string color) { this->name = name; this->color = color; } // other methods to access and manipulate attributes }; [instruction] | Write C++ code to create a class 'Fruit' that has two attributes - 'name' and 'color'. [input] |

[output] | <style> textarea{ width: 300px; height: 200px; } </style> [instruction] | Use CSS to create a text area with the width of 300px and the height of 200px [input] |

[output] | <form action="server.php" method="post"> <input type="text" name="name" placeholder="Your Name"> <input type="text" name="age" placeholder="Your Age"> <button type="submit">Submit</button> </form> [instruction] | Create an HTML form that submits data to a server. [input] |

[output] | <script> function changeBackgroundColor() { document.body.style.backgroundColor = 'green'; } </script> <button onclick="changeBackgroundColor()">Change background color!</button> [instruction] | Introduce a condition to change the background color of a given HTML page to green when the user clicks a button. [input] |

[output] | SELECT * FROM table_name WHERE number = 5; [instruction] | Write an SQL query to find all the rows in a table containing the number 5. [input] |

[output] | def sort_list(list_of_numbers): list_of_numbers.sort() return list_of_numbers print(sort_list([9, 15, 5, 11, 4])) # Output: [4, 5, 9, 11, 15] [instruction] | In Python, write code to sort a list of integers in ascending order. [input] | [9, 15, 5, 11, 4]

[output] | let elements = document.getElementsByClassName('myclass'); for(let i=0; i<elements.length; i++){ alert(elements[i].innerHTML); } [instruction] | Write a JavaScript code to find all the elements with class 'myclass' in a given HTML page and alert their inner HTML. [input] |

[output] | 111001000 [instruction] | Convert a given three-digit number to its binary equivalent [input] | 456

[output] | .box-shadow { box-shadow: 0 0 6px 0 yellow; } [instruction] | With the given input, make a css class which will give a box-shadow with 4px spread radius [input] | shadow size: 6px; shadow color: yellow

[output] | /\+\d{12}/ [instruction] | Write a regular expression to detect phone numbers with country code in a string [input] | +918327886067

[output] | 385 [instruction] | Calculate the sum of squares of the numbers till 10 [input] |

[output] | SELECT * FROM Employees ORDER BY salary DESC [instruction] | Write an SQL query to sort records in descending order based on salary [input] |

[output] | var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [instruction] | Create an array in JavaScript to store integers from 1 to 10 [input] |

[output] | <html> <head> <title>Button Section</title> </head> <body> <div> <button>First button</button> <button>Second button</button> </div> </body> </html> [instruction] | Build a HTML page with a section containing two buttons [input] |

[output] | def odd_num(arr): count = 0 for num in arr: if num % 2 != 0: count += 1 return count # Test Array arr = [2, 9, 0, 5, 3] # Function Call odd_num(arr) [instruction] | Find out the number of odd numbers in an array [input] | [2, 9, 0, 5, 3]

[output] | import React, { useState } from 'react'; const GEDCOMParser = () => { const [data, setData] = useState(); const parseGEDCOM = (gedcomData) => { let parsedData = {}; gedcomData.split("\n").forEach(line => { let fields = line.split(" "); parsedData[fie [instruction] | Generate a working React component to parse GEDCOM data. [input] |

[output] | def func(x, n): s = 0 for i in range (n): s += (x**i) return s def generateSumString(x, n): result = "The sum of series " for i in range(1, n+1): result += x + "^" + str(i) if(i != n): result += " + " else: result += " is" [instruction] | Update the given code to generate the correct output [input] | def func(x, n): s = 0 for i in range (n): s += (x**i) return s Output: The sum of series x^1 + x^2 + x^3 + ... + x^n is

[output] | #include <stdio.h> #include<string.h> // function to count the occurrence of letters int countOccurrences(char *str) { int count = 0; int i; int j; int len = strlen(str); // Iterate through each letter in the string for (i = 0; i < len; i++) { int numberCount = [instruction] | Generate a working C program to accept a sentence as an input and count the occurrences of each letter in the sentence [input] |

[output] | public class Book { public string Title { get; set; } public string Author { get; set; } public string Publisher { get; set; } public string ISBN { get; set; } public double Price { get; set; } } [instruction] | Create a new class named 'Book' with the following fields [input] | Title, Author, Publisher, ISBN, Price

[output] | def check_anagrams(str1,str2): str1_list = list(str1) str1_list.sort() str2_list = list(str2) str2_list.sort() return (str1_list == str2_list) # Driver code str1 = "rat" str2 = "tar" if check_anagrams(str1, str2): print("The strings are anagrams.") else: print( [instruction] | Write a python function that takes two strings as an argument and returns the True if they are anagrams of each other, else False. [input] | "rat" and "tar"

[output] | function reversePrintArray(arr) { if (arr.length === 0) { return; } reversePrintArray(arr.slice(1)); console.log(arr[0]); } [instruction] | Print the array elements in reverse order using a recursive function in JavaScript [input] | [1,2,3,4]

[output] | def gcd(a, b): while b > 0: a, b = b, a % b return a print(gcd(42, 56)) [instruction] | Implement a function to calculate the greatest common divisor [input] | 42, 56

[output] | def drawRectangle(size): for i in range(size): print("* " * size) drawRectangle(6) [instruction] | Write a code to construct the following rectangle pattern [input] | 6

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