← 목록

Synth · CodeAlpaca일부

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

[output] | <?php echo "Hello, World!"; ?> [instruction] | Write a PHP code snippet to display "Hello, World!" in console. [input] |

[output] | function addVals(x, y) { return x + y; } [instruction] | Write a different style of a given JavaScript code snippet. [input] | function sum(a, b) { return a + b; }

[output] | for i in range(11): print(i) [instruction] | Write a basic script in Python that counts from 0 to 10. [input] |

[output] | SELECT value FROM value WHERE COUNT(*) > 2 GROUP BY value; [instruction] | Write a SQL query to find the values that have occurred more than twice. [input] | Table name: values | id | value | |---|---| | 1 | 3 | | 2 | 3 | | 3 | 4 | | 4 | 5 | | 5 | 3 |

[output] | <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Title</title> </head> <body> <h1>Home</h1> <h1>About</h1> </body> </html> [instruction] | Write an HTML page with two headings "Home" and "About". [input] |

[output] | console.error("Username and password do not match.") [instruction] | How would you display the following message as an error in JavaScript? "Username and password do not match." [input] |

[output] | public static double maxValue(double[] array) { double maxValue = array[0]; for (int i = 1; i < array.length; i++) { if (array[i] > maxValue) maxValue = array[i]; } return maxValue; } [instruction] | Write code in Java to find the maximum value of the array. [input] | [1, 4, 6, 8, 9, 4, 2]

[output] | bool isPrime(int n) { if (n <= 1) return false; for (int i = 2; i < n; i++) if (n % i == 0) return false; return true; } [instruction] | How would you write a function in C++ to check if the number 16 is a prime number? [input] |

[output] | System.out.println("Welcome to the Java programming course!"); [instruction] | Write a short piece of code in Java to display the following message. [input] |

[output] | fruit_list = ["Pear", "Grape", "Apple", "Banana", "Mango"] fruit_list.remove("Apple") [instruction] | How would you delete the element "Apple" from the following list? [input] | ["Pear", "Grape", "Apple", "Banana", "Mango"]

[output] | let str = "Hello World!"; let reversedStr = str.split("").reverse().join(""); console.log(reversedStr); [instruction] | Write a JavaScript code to reverse the following string. [input] | "Hello World!"

[output] | UPDATE product SET stock = 10 WHERE stock < 10; [instruction] | Create a SQL query to update all rows of the table "product" if their stock is below 10. [input] |

[output] | string username = "johndoe"; string status = "inactive"; if (status == "inactive") { // Create new account for John Doe } else { // No new account needs to be created } [instruction] | How would you use an if-else statement in C# to check if a new account needs to be created for the following user? [input] | username: "johndoe" status: "inactive"

[output] | def calculate_triangle_area(side1, side2, side3): '''This function calculates the area of a triangle given three sides.''' s = (side1 + side2 + side3) / 2 return ((s*(s-side1)*(s-side2)*(s-side3))**0.5) area = calculate_triangle_area(6,8,10) print(f"The area of the triangle is {area} cm [instruction] | Write a short piece of code in Python to calculate the area of a triangle with the sides 6 cm, 8 cm, and 10 cm. [input] |

[output] | String str = "Hello World!"; boolean isNumeric = false; for (int i = 0; i < str.length(); i++) { if (Character.isDigit(str.charAt(i))) { isNumeric = true; break; } } if (isNumeric) System.out.println("The given string contains a numeric character."); el [instruction] | Write a piece of code in Java to check if the following string contains a numeric character. [input] | "Hello World!"

[output] | total = 0 for i in range(50, 101): if i % 2 == 0: total += i print(f"The sum of all even numbers between 50 and 100 is {total}") [instruction] | How would you use a for loop in Python to print the sum of all even numbers between 50 and 100? [input] |

[output] | public class main{ public static void main(String[] args){ int[] array = {1, 2, 3, 4, 5}; System.out.println("Size of the array is: " + array.length); } } [instruction] | In Java, develop a program which prints the size of a given array. [input] | int[] array = {1,2,3,4,5};

[output] | from scipy.optimize import curve_fit def func(x, a, b, c): return a*x**2 + b*x + c xdata = [0, 1, 2, 4, 11, 18] ydata = [2, 3, 4, 6, 12, 17] popt, pcov = curve_fit(func, xdata, ydata) [instruction] | In Python, construct a function to fit a curve to a given set of data points. [input] | xdata = [0, 1, 2, 4, 11, 18] ydata = [2, 3, 4, 6, 12, 17]

[output] | function countOccurence(array, element) { let count = 0; array.forEach(el => { if(el === element) count++ }); return count; } var array = [1, 2, 3, 4, 1]; let element = 1; console.log(countOccurence(array, element)); // 2 [instruction] | In JavaScript, construct a function to count the occurence of an element in an array. [input] | var array = [1, 2, 3, 4, 1]; int element = 1;

[output] | def infix_to_prefix(exp): # stack to store operators stack = [] # prefix expression pref_exp = "" # traverse through the expression for char in exp: # if the character is an operand # add it to prefix expression if char.isalpha(): pref_exp += char # if the character [instruction] | Develop a program to convert an infix expression to prefix notation. [input] | A*(B+C)-D/(E+F)

[output] | SELECT Name FROM Employees WHERE Salary > 50000 [instruction] | Write a SQL query to get employee names from the Employees table where salary is greater than 50000. [input] |

[output] | def scrape_frequent_words(url): try: from bs4 import BeautifulSoup from collections import Counter # Get html from the given url html_content = requests.get(url).text # Parse the html soup = BeautifulSoup(html_content) # Get a [instruction] | Create a function in Python that performs a web scrape and returns the most frequent words from the resulting text. [input] |

[output] | import React from 'react'; const StatusUpdate = ({ statusText }) => { return ( <div> <p>{statusText}</p> </div> ); }; export default StatusUpdate; [instruction] | Create a React component in JavaScript which displays the given string as a status update. [input] |

[output] | post "/posts" do post = Post.new(params[:post]) if post.save status 202 json post.to_json else status 400 json post.errors end end [instruction] | Suggest an API endpoint in Ruby on Rails for creating a new blog post. [input] |

[output] | put "/posts/:id" do post = Post.find(params[:id]) if post.update(params[:post]) status 200 json post.to_json else status 400 json post.errors end end [instruction] | Suggest an API endpoint for updating an existing blog post in Ruby on Rails. [input] |

[output] | class StringLength: def __len__(self, string): return len(string) [instruction] | Create a class in Python that implements the __len__ method to return the length of a given string. [input] |

[output] | String queryString = "SELECT Employees.Name FROM Employees WHERE Employees.Salary > ?"; PreparedStatement pstmt = conn.prepareStatement(queryString); pstmt.setDouble(1, 50000); ResultSet rs = pstmt.executeQuery(); while (rs.next()) { String name = rs.getString(1); // Process the name } [instruction] | Convert the following SQL query into a Java code using JDBC. [input] | SELECT Employees.Name FROM Employees WHERE Employees.Salary > 50000

[output] | SELECT name, salary FROM Employees WHERE department = 'IT'; [instruction] | Write a SQL query to get all employees' name and salary who are from department "IT" [input] |

[output] | <html> <head> <style> table tr:nth-child(2n) { background-color: red; } table tr:nth-child(2n+1) { background-color: blue; } </style> </head> <body> <div> <table> [instruction] | Develop an HTML page with a div and table, and use CSS to make alternating rows of the table red and blue. [input] |

[output] | SELECT * FROM People WHERE city = 'London' ORDER BY last_name ASC; [instruction] | Write a SQL query to get all people living in London, ordered by their last name [input] |

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