← 목록

Synth · CodeAlpaca일부

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

[output] | The angle between two vectors can be found using the following formula: theta = arccos(v1.v2 / (||v1||*||v2||)), where v1 and v2 represent the two given vectors and ||v1|| and ||v2|| are the magnitudes of the vectors. [instruction] | Find the angle between two given vectors [input] |

[output] | Indexing in databases is important because it allows for faster access to data. Indexing works by creating an index data structure that stores a specific value or field in the database and a pointer to the data record containing that value. This strategy increases the speed of the query operations b [instruction] | Why is indexing important in databases? [input] |

[output] | def quickSort(arr): if len(arr) <= 1: return arr else: pivot = arr[len(arr) // 2] left = [x for x in arr if x < pivot] middle = [x for x in arr if x == pivot] right = [x for x in arr if x > pivot] return quickSort(left) + middle + quickSort(ri [instruction] | Sort a given array of integers using Quick Sort [input] |

[output] | Static binding is the process of linking a procedure call to the code to be executed during compile-time. This link is done by compiler at the compile-time and is fixed for the life of the program. On the other hand, dynamic binding is the process of linking a procedure call to the code to be execut [instruction] | What is the difference between static binding and dynamic binding [input] |

[output] | def bubbleSort(arr): n = len(arr) for i in range(n): for j in range(0, n-i-1): if arr[j] > arr[j+1] : arr[j], arr[j+1] = arr[j+1], arr[j] [instruction] | Alter the following given code so that it will implement the Bubble Sort Algorithm [input] | def mySort(arr): n = len(arr) for i in range(n-1): for j in range(0, n-i-1): if arr[j] > arr[j+1] : arr[j], arr[j+1] = arr[j+1], arr[j]

[output] | SELECT name FROM students ORDER BY name DESC; [instruction] | Write a SQL query that outputs the names of all the students in a given table sorted in descending order [input] |

[output] | int[] arr = {1,2,3,4,5}; [instruction] | Read in a string of comma-separated integers and create an array of the integers. [input] | "1,2,3,4,5"

[output] | python -m pip install virtualenv virtualenv envname source envname/bin/activate [instruction] | Create a virtual environment in Python using the "virtualenv" tool. [input] |

[output] | SELECT * FROM Employees WHERE age > 40; [instruction] | Create a SQL query to find all records of employees who are over 40 years old. [input] |

[output] | def sumFromZeroToMax(n): sum = 0 for x in range(n+1): sum += x return sum print(sumFromZeroToMax(10)) [instruction] | Write a function that takes in a max number and returns the sum of all numbers between 0 and the max number. [input] | 10

[output] | let nums = [1, 2, 3, 4]; function printArrElement(arr){ for(let i = 0; i < arr.length; i++){ console.log(arr[i]); } } printArrElement(nums); [instruction] | Fix the logic of the function to print out the element in the array. [input] | let nums = [1, 2, 3, 4];

[output] | import requests api_key = "<Enter API key here>" city = "London" url = "http://api.openweathermap.org/data/2.5/weather?q={}&appid={}".format(city, api_key) res = requests.get(url) data = res.json() print("Current temperature in {} is {}°F".format(city, data["main"]["temp"]-273.15 * 9/5 + 32)) [instruction] | Make an API call to get the current weather in a given city. [input] |

[output] | total_votes = 0 for candidate in range(len(candidates)): total_votes+=votes[candidate] print(total_votes) [instruction] | Write code to calculate the total number of votes for a candidate in an election. [input] | candidates = ["AJ Bascombe", "Maya Mathews", "Toby White"] votes = [2000, 4000, 3000]

[output] | print("My name is {}, and I'm {} years old.".format("Joe",31)) [instruction] | Write a statement to print a formatted string. [input] | Name: Joe Age: 31

[output] | def search(query, data): # base case if len(data) == 0: return False # recursive step else: if data[0] == query: return True else: return search(query, data[1:]) query = "computer" data = ["mobile","computer","laptop","tablet"] print(search(query, data)) [instruction] | Implement a simple search engine using recursion. [input] | query = "computer" data = ["mobile","computer","laptop","tablet"]

[output] | for i in list: if i % 2 != 0: list.remove(i) print(list) [instruction] | Edit the given list to only include even numbers. [input] | list = [2,3,4,5,6,7,8]

[output] | num = 8 # # # # # # # # # # # # # # # # # [instruction] | Edit this code to print out the square of a given number, using '#' as a marker. [input] | num = 8

[output] | def find_triplet(n): """ @brief: Finds all Pythagorean triplets which sum upto the given number n @param n: the sum which is the given number @return: a list of all Pythagorean triplets which might sum upto n, or an empty list if none are found """ triplets = [] for a in [instruction] | Write a code snippet to find all the Pythagorean triplets which sum up to the given number. [input] |

[output] | def find_primes(limit): """ @brief: Finds all prime numbers up to a given limit n @param limit: the upper limit to find prime numbers @return: a list of all prime numbers found """ primes = [] for n in range(2, limit + 1): is_prime = True for prime in prim [instruction] | Design a program to find all prime numbers up to a given limit n. [input] |

[output] | a = 5 b = 3 a, b = b, a [instruction] | Modify the following code to swap the values of two variables without using a third variable. [input] | a = 5 b = 3

[output] | def count_odds(arr): """ @brief: Counts the number of odd numbers in a given array @param arr: array whose odd numbers are to be counted @return: the number of odd numbers in the given array """ count = 0 for num in arr: if num % 2 == 1: count += 1 [instruction] | Write a code snippet to determine the number of odd numbers in a given array. [input] |

[output] | (1, 5) [instruction] | Given a list of integers and a target value, calculate two integers in the list that add up to the target value. [input] | target = 6 list = [1, 2, 3, 4, 5]

[output] | arr = [1, 2, 3, 4, 5] [instruction] | Create an array in Python that contains five different values. [input] |

[output] | SELECT name FROM Author WHERE topic = 'Artificial Intelligence'; [instruction] | Write a SELECT query to identify the names of authors who have published books with the topic ‘Artificial Intelligence’. [input] |

[output] | function addTen(num) { return num+10; } [instruction] | Create a function in JavaScript to take a given number and add 10 to it. [input] |

[output] | public class Student { //instance variables String name; int grade; //constructor public Student(String studentName, int studentGrade) { name = studentName; grade = studentGrade; } //methods public String getName(){ [instruction] | Write a Java class to define a student object that includes a name and a grade. [input] |

[output] | public static void printFibonacciIterative(int n) { int prev1=0, prev2=1, sum=0; for (int i = 0; i < n; i++) { System.out.print(sum + " "); prev2 = sum; sum = prev1 + prev2; prev1 = prev2; } } [instruction] | Write an Iterative program in Java to print the first n terms of the Fibonacci sequence. [input] |

[output] | import matplotlib.pyplot as plt data_set = [1, 2, 4, 8, 16, 32] plt.bar(range(len(data_set)), data_set) plt.show() [instruction] | Create a bar chart in Python, plotting the following integer data set. [input] | [1, 2, 4, 8, 16, 32]

[output] | number = 15 if (number % 2 == 0): print("even") else: print("odd") [instruction] | Create a python script to determine whether a number is odd or even. [input] | 15

[output] | SELECT first_name, last_name FROM persons; [instruction] | Write a SQL query to output the full names from a 'persons' table. [input] |

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