← 목록

Synth · CodeAlpaca일부

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

[output] | @app.route("/books/latest", methods=["GET"]) def get_latest_books(): cursor = conn.cursor() query = "SELECT * FROM books ORDER BY id DESC LIMIT 10;" cursor.execute(query) books = cursor.fetchall() return jsonify(books) [instruction] | Write a REST API endpoint handler to get the latest books from a database. [input] |

[output] | import ast def check_syntax(code): try: ast.parse(code) except SyntaxError: return False else: return True [instruction] | Using the given snippet of code, create a compiler to check if a given string is valid Python code. [input] |

[output] | public static String[] toLowerCase(String[] words) { String[] lowerWords = new String[words.length]; for (int i = 0; i < words.length; i++) lowerWords[i] = words[i].toLowerCase(); return lowerWords; } [instruction] | Using the provided snippet of code below, create a function in Java to convert a given array of strings to lowercase. [input] |

[output] | import pandas as pd import numpy as np df = pd.DataFrame(np.random.randint(0, 11, size=(3, 3)), columns=['Column1', 'Column2', 'Column3']) [instruction] | Generate a pandas DataFrame with three columns containing random integer numbers between 0 and 10. [input] |

[output] | let x = 12; let y = 5; if ( x > y ) { console.log(x); } else { console.log(y); } [instruction] | Construct an if-else statement in JavaScript that prints the largest number among two input numbers. [input] |

[output] | import mysql.connector mydb = mysql.connector.connect( host="localhost", user="yourusername", passwd="yourpassword", database="mydatabase" ) [instruction] | Create a script to connect to a MySQL database using Python. [input] |

[output] | Function ReverseOrder(A): n = A.length For i = 1 to n/2: temp = A[i] A[i] = A[n - i] A[n - i] = temp End End [instruction] | Write an algorithm in pseudocode to reverse the order of numbers in a given array. [input] |

[output] | DELETE FROM employees WHERE salary < 50000; [instruction] | Create a SQL query to delete all rows of a table named 'employees', where the employee's salary is below 50K. [input] |

[output] | import numpy as np matrix = np.random.uniform(0,1, (5,4)) [instruction] | Construct a matrix in Python containing 5 rows and 4 columns of random floating point numbers between 0 and 1. [input] |

[output] | def find_string(list, target): for index, value in enumerate(list): if value == target: return index list = ["red", "blue", "green", "yellow"] string = "green" print(find_string(list, string)) # Output 2 [instruction] | Given a list of strings and an input string, find the index of the input string in the list. [input] | list = ["red", "blue", "green", "yellow"] string = "green"

[output] | import string def remove_punctuation(string): for punct in string.punctuation: string = string.replace(punct, '') return string string = "Hello, how are you?" print(remove_punctuation(string)) # output 'Hello how are you' [instruction] | Modify the given Python code to remove any punctuations from the given string. [input] | string = "Hello, how are you?"

[output] | def remove_duplicate(my_list): return list(set(my_list)) my_list = [1, 2, 2, 3, 4, 5, 4] print(remove_duplicate(my_list)) # Output [1, 2, 3, 4, 5] [instruction] | Edit the given Python code to remove duplicate items from the given list. [input] | my_list = [1, 2, 2, 3, 4, 5, 4]

[output] | 11.75 [instruction] | Evaluate the following expression: 11 + 3 / 4. [input] |

[output] | 3 [instruction] | Compute the modulus of 3 and 4. [input] |

[output] | let myArr = [1, 2, 3, 4].filter((item, index, arr) => arr.indexOf(item) === index); [instruction] | Use an array method to remove duplicates from a given array in JavaScript. [input] | let myArr = [1, 2, 3, 1, 4, 3]

[output] | echo "Welcome!" [instruction] | Write a simple Bash script to display a welcome message. [input] |

[output] | public static boolean isStringLongerThan5(String str) { return str.length() > 5; } [instruction] | Write a function in Java to check if the length of a string is greater than 5. [input] | String str = "Hello World!"

[output] | SELECT name, salary FROM employee_data WHERE salary > 100000; [instruction] | Write an SQL query to find the name and salary of employees who earn more than $100,000. [input] |

[output] | CREATE TABLE users ( name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL ); [instruction] | Create a table in SQL to store the names and email addresses of users. [input] |

[output] | from selenium import webdriver # Create webdriver object driver = webdriver.Chrome() # Put target website URL url = 'https://www.example.com/' # Navigate to the website driver.get(url) # Scrape the data data = driver.find_elements_by_xpath('//*[@class="data-class"]') for element in data: pri [instruction] | Create a web browser automation script in Python to scrape the data from a website. [input] |

[output] | SELECT * FROM Employees WHERE last_name = 'Smith' [instruction] | Use a SQL query to extract all the rows from the table "Employees" that includes employees with the last name Smith. [input] |

[output] | SELECT * FROM orders WHERE tax_rate = 0.07; [instruction] | Write a query in MySQL for finding records with a specific tax rate. [input] | Tax Rate: 7%

[output] | Average score: 6. [instruction] | Calculate the average score of the following list of numbers. [input] | [2, 4, 6, 8, 10]

[output] | She will write a poem. [instruction] | Re-write the following sentence by changing the verb tense to future simple. [input] | She wrote a poem.

[output] | SELECT * FROM orders WHERE product_type = 'Electronics'; [instruction] | Write a query in SQL to find records with specific value. [input] | Key: product_type Value: Electronics

[output] | import random random_list = [random.randint(1, 10) for int_num in range(5)] print(random_list) [instruction] | Create a list of five randomly generated integers from 1 to 10 in Python. [input] |

[output] | sample_list = [1,2,3,4,5,6,7,8] def remove_even_numbers(lst): for num in lst: if num % 2 == 0: lst.remove(num) return lst print(remove_even_numbers(sample_list)) [instruction] | Define a function to remove all the even numbers from a list in Python. [input] | sample_list = [1,2,3,4,5,6,7,8]

[output] | function quadraticEquation(a, b, c) { let result; let delta = (b * b) - (4 * a * c); if (delta > 0) { result = { root1: (-b + Math.sqrt(delta)) / (2 * a), root2: (-b - Math.sqrt(delta)) / (2 * a) }; } else if (delta == 0) { result = { roo [instruction] | Create a function to solve a quadratic equation in JavaScript. [input] |

[output] | #include <bits/stdc++.h> using namespace std; // Function to check if two strings are equal bool areAnagram(string str1, string str2) { // Get lengths of both strings int n1 = str1.length(); int n2 = str2.length(); // If length of both strings is not same, then // th [instruction] | Create a function to check if a string is an anagram in C++. [input] |

[output] | SELECT employee_name FROM employees WHERE salary > 50000; [instruction] | Create a SQL query to find all employee names who earn more than $50,000 a year. [input] |

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