← 목록

Synth · CodeAlpaca일부

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

[output] | SELECT u.*, COUNT(o.id) as count FROM users u JOIN orders o ON o.user_id = u.id GROUP BY u.id ORDER BY count DESC LIMIT 10; [instruction] | Using MySQL, find the 10 customers who have made the most orders. [input] |

[output] | public static int computeTotalPrice(int[] item_price, int[] quantity) { int sum = 0; for (int i = 0; i < item_price.length; i++) { sum += item_price[i] * quantity[i]; } return sum; } System.out.println(computeTotalPrice(item_price, quantity)); [instruction] | Create a Java program to compute the total price of a customer's order based on item prices and quantities. [input] | item_price = [30, 20, 15], quantity = [2, 4, 1]

[output] | SELECT name FROM students WHERE score > 90; [instruction] | Write an SQL query to list the students' names who scored more than 90 in an exam. [input] |

[output] | db.products.update({name:"iPhone"},{$set: {price: 1000}}); [instruction] | Using MongoDB, update the product price for a specific product. [input] | product = {name: “iPhone”, price: 1000}

[output] | The sum of first column is 12 The sum of second column is 15 The sum of third column is 18 [instruction] | Your program needs to read a matrix of integers and then print out the sum of each column. [input] | matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

[output] | matrix = [[randint(0, 99) for x in range(columns)] for y in range(rows)] [instruction] | Write a Python program to fill a matrix with random numbers. [input] | rows = 4 columns = 3

[output] | result_list = list(set(input_list)) [instruction] | You're asked to generate a unique list from a given list of duplicate integers. [input] | input_list = [1, 1, 2, 3, 3, 3, 4, 4, 5, 5]

[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) print(Fibonacci(10)) [instruction] | You need to code a program that prints out the nth Fibonacci number. [input] | n=10

[output] | def swap_even_and_odd(my_list): for i in range(len(my_list)-1): if i % 2 == 0 and my_list[i] % 2 != 0: my_list[i], my_list[i+1] = my_list[i+1], my_list[i] return my_list print(swap_even_and_odd(my_list)) [instruction] | Program to swap all even and odd elements in a given array. [input] | my_list = [1, 2, 3, 4, 5, 6, 7, 8]

[output] | def countOddNumbers(input_array): count = 0 for num in input_array: if num % 2 != 0: count += 1 return count print(countOddNumbers(input_array)) [instruction] | Code a function that takes an array and counts the odd numbers in it. [input] | input_array = [1, 2, 3, 4, 5]

[output] | def replace_word(string, old_word, new_word): return string.replace(old_word, new_word) print(replace_word(string, "coding", "programming")) [instruction] | Your program needs to edit an existing string by replacing certain words with another word. [input] | string = "I am the biggest fan of coding"

[output] | def sort_by_length(words): return sorted(words, key=len) print(sort_by_length(words)) [instruction] | Generate a function that takes a given list of strings and orders them by their lengths. [input] | words = ["Python", "programming", "language"]

[output] | import random def random_word(words): return random.choice(words) print(random_word(words)) [instruction] | Develop a program that picks a random item from a given list of strings. [input] | words = ["Python", "programming", "language"]

[output] | <html> <head> <title>Hello World</title> </head> <body> <h1>Hello World!</h1> </body> </html> [instruction] | Write a HTML code for a webpage that displays the headline "Hello World!". [input] |

[output] | num1 = float(input("Enter first number: ")) num2 = float(input("Enter second number: ")) # Adding two numbers sum = num1 + num2 # Display the sum print('The sum of {0} and {1} is {2}'.format(num1, num2, sum)) [instruction] | Write a Python program to calculate the sum of two numbers entered by the user. [input] |

[output] | boolean variable = false; [instruction] | Create a boolean variable in Java, initialized to false. [input] |

[output] | CREATE TABLE users( name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, age INT NOT NULL ); [instruction] | Write a SQL query for creating a table named "users" with columns for "name", "email" and "age". [input] |

[output] | var event = { time: "12pm", attendees: ["John", "Jane", "Jack"], location: "New York" }; [instruction] | Create a JavaScript object that keeps track of event data such as time, attendees, and location. [input] |

[output] | SELECT * FROM students WHERE age > 15; [instruction] | Write a query in MySQL for selecting all records from a table named "students" which have "age" greater than 15. [input] |

[output] | class Rectangle: def __init__(self, length, width): self.length = length self.width = width def area(self): return self.length * self.width [instruction] | Write a class in Python for representing a rectangle. This class should store the length and width of the rectangle, and be able to compute its area. [input] |

[output] | SELECT AVG(salary) FROM employees WHERE age > 25; [instruction] | Write an SQL query for finding the average salary of employees in a table whose age is greater than 25. [input] |

[output] | body { margin: 0; } #container { margin: 0 auto; width: 800px; } [instruction] | Write a CSS code to display a web page with a centered container of width 800px. [input] |

[output] | 1255908800 [instruction] | Convert the date 1972-05-18 to a UNIX timestamp. [input] |

[output] | 15 [instruction] | Print all members of the list that are greater than 10. [input] | theList = [1, 15, 20, 9, 12, 13]

[output] | public class Vector2D { public double x, y; public Vector2D(double x, double y) { this.x = x; this.y = y; } public double magnitude() { return Math.sqrt(x * x + y * y); } public Vector2D add(Vector2D o) { return new Vector2D(x + o.x, y + o.y [instruction] | Create a class for a 2D vector in Java. [input] |

[output] | def stdev(data): avg = sum(data) / len(data) total = 0 for x in data: total += (x - avg) ** 2 return (total / (len(data) - 1)) ** 0.5 [instruction] | Write a function to calculate the standard deviation of data points in Python. [input] |

[output] | def smallestNumber(numbers): smallest = numbers[0] for number in numbers: if smallest > number: smallest = number return smallest [instruction] | Rewrite the following program to make it print out the smallest number in a given list. [input] | def smallestNumber(numbers): largest = numbers[0] for number in numbers: if largest < number: largest = number return largest

[output] | func printFirstTenPrime(){ count := 0 for i := 1; ; i++ { if (isPrime(i)) { fmt.Printf("%d ", i) count++; } if (count == 10) { break } } fmt.Println() } func isPrime(num int) bool { for i := 2; i <= num/2; i++ { [instruction] | Generate a program in Go for printing the first 10 prime numbers. [input] |

[output] | const binaryToDecimal = binaryString => parseInt(binaryString, 2); [instruction] | How would you convert a binary number to decimal in JavaScript? [input] |

[output] | myList = list(range(10,51)) [instruction] | Generate a list of numbers starting from 10 to 50. [input] |

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