← 목록

Synth · CodeAlpaca일부

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

[output] | The output of the above program is -5. [instruction] | What is the output of the following C code? int main() { int x = 10; x = x * -0.5; printf("%d", x); return 0; } [input] |

[output] | vec = [ 0., 0., 0., 0., 0. ] [instruction] | Create a new vector of size 5 filled with zeros. [input] |

[output] | def euclidean_dist(x, y): # write function here dist = 0 # iterate through each coordinate of the points for i in range(len(x)): # calculate the distance between corresponding coordinates dist += (x[i]-y[i])**2 return (dist**0.5) [instruction] | Implement the Euclidean distance formula using a def function in Python. [input] |

[output] | switch(input){ case 1: console.log("Yay!"); break; case 2: console.log("Nay!"); break; default: console.log("Invalid Input") break; } [instruction] | Create a switch statement that prints "Yay!" if input is 1 and "Nay!" if input is 2. [input] |

[output] | for(let i = 0; i <= 10; i++){ console.log(2**i); } [instruction] | Write a for loop for printing the first 10 powers of 2. [input] |

[output] | starString = "*"; for (let i = 1; i <= 10; i++){ console.log(starString); starString += "*"; } [instruction] | Create a tower of stars made up of 10 lines of increasing star lengths. [input] |

[output] | document.querySelectorAll(".container").forEach(function(container){ container.style.backgroundColor = "blue"; }); [instruction] | Change the background color of all element with the class "container" to blue. [input] |

[output] | // Total sum of each row for(let row of arr){ let total = 0 for(let col of row){ total += col } console.log(total) } [instruction] | Print out the sum of each row of a given 2 dimensional array. [input] | arr = [ [1, 1, 1], [2, 2, 2], [3, 3, 3] ]

[output] | if(number % 2 == 0){ console.log('`number` is even') } else { console.log('`number` is odd') } [instruction] | Using conditional statements, print out whether a given number is odd or even. [input] | number = 7

[output] | function removeDuplicates(arr){ let result = []; arr.forEach(function(element){ if(!result.includes(element)){ result.push(element); } }); return result; } [instruction] | Write a function for removing duplicate values from an array. [input] |

[output] | def calculate_price(products): total_price = 0 for price, quantity in products: total_price += price * quantity return total_price [instruction] | Refactor this function to be less complex and more readable. [input] | def calculate_price(products): total_price=0 for p in products: total_price+=p[0]*p[1] return total_price

[output] | /[a-zA-Z0-9_\-\.]+@example\.com$/ [instruction] | Write a regular expression to match emails with domain example.com [input] |

[output] | CREATE TABLE users ( id int NOT NULL AUTO_INCREMENT, username varchar(255) NOT NULL, password varchar(255) NOT NULL, email varchar(255) NOT NULL, PRIMARY KEY (id) ); [instruction] | Create a database table for a social media application. [input] |

[output] | import React from 'react'; const ItemList = ({items}) => { return ( <div className="item-list"> {items.map(item => ( <div className="item" key={item.name}> <div className="name">{item.name}</div> <div className="description">{item.description}</div> [instruction] | Create a React component for displaying a list of items with name, description, and price fields. [input] |

[output] | let str1="Hello"; let str2="World"; if(str1 > str2){ console.log(str1 + " is bigger than " + str2); } else{ console.log(str2 + " is bigger than " + str1); } [instruction] | Compare the following two strings and print out which one is bigger. [input] | str1="Hello" str2="World"

[output] | let arr = ["Hello", "World", "Foo", "Bar"]; let obj = {}; for(let i=0; i<arr.length; i++){ obj[arr[i]] = arr[i].length; } console.log(obj); // {Hello: 5, World: 5, Foo: 3, Bar: 3} [instruction] | Given an array of strings, generate an object with the strings as keys and the length of each string as values. [input] | let arr = ["Hello", "World", "Foo", "Bar"]

[output] | .card { border-radius: 10px; box-shadow: 0 0 5px rgba(0, 0, 0, 0.2); max-width: 500px; } [instruction] | Create a css class for a card component with rounded corners, a light shadow, and a maximum width of 500px. [input] |

[output] | class MyList def initialize @list = [] end def get(index) @list[index] end end [instruction] | Update the following code to add a method to retrieve elements from the list. [input] | class MyList def initialize @list = [] end end

[output] | let arr=[5,7,8,9]; let sum=0; for(let i=0; i<arr.length; i++){ sum+=arr[i]; } let average=sum/arr.length; console.log(average); // 7.5 [instruction] | Given an array of numbers, calculate the average. [input] | let arr=[5,7,8,9]

[output] | Function searchAndReplace(nums): for i in range(len(nums)): if nums[i] >= 0: nums[i] = math.sqrt(nums[i]) return nums [instruction] | Write an algorithm to search for numbers in an array and replace them with their square roots. [input] | [1,2,3,4,5]

[output] | <div class="list"> <ol> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> <li>Item 4</li> <li>Item 5</li> </ol> </div> [instruction] | Write a HTML code to display a ordered list of five items inside a div with the classname "list". [input] |

[output] | for number in list_of_numbers: [instruction] | Identify the correct loop structure to traverse through a list of numbers. [input] |

[output] | import random def create2DArray(row, col): arr = [[random.randint(1,100) for j in range(col)] for i in range(row)] return arr [instruction] | Create a 2D array with n columns and m rows and fill it with random numbers. [input] | Rows: 6, Columns: 8

[output] | class Stack(): def __init__(self): self.items = [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() stack = Stack() stack.push(5) stack.push(7) [instruction] | Create a stack and add two elements to it. [input] |

[output] | def detectInfiniteLoop(program): setOfInstructions = set() for line in program.split('\n'): if line in setOfInstructions: return True setOfInstructions.add(line) return False [instruction] | Design a program to detect an infinite loop in a given program. [input] |

[output] | An object oriented design approach for the problem statement would involve the following: creating a base class for the banking records which has properties to store user details and banking information, providing a way to create a savings account and checking account class that can be derived from [instruction] | Describe a good object oriented design approach for the following problem statement: [input] | Design an application that provides a way for users to store and access their banking records.

[output] | The necessary data to apply linear regression on the problem statement would include population density, housing costs and average income of the particular city. Additionally, the average property value should also be collected as the target variable to be predicted. The data could be collected from [instruction] | Acquire the necessary data to apply linear regression on the following problem statement [input] | Predict the average property value in a particular city given population density, housing costs and average income.

[output] | function updateNavMenu(preferences) { // code to update navigation menu for each user preference let html = ''; for (let preference in preferences) { if (preferences[preference]) { html += '<li>' + preference + '</li>'; } } document.getElementById("navMenu").innerHTML = html; [instruction] | Create a JavaScript program that updates the navigation menu based on user preferences [input] |

[output] | The output would involve creating a Django application with an API view that takes in the ID as the parameter and returns a dictionary containing the user's name and age. The Django application should also include the necessary models and associated functions, a URL configuration, and a core applica [instruction] | Create a Django application to serve an API endpoint [input] | The API endpoint should take an ID and return a user's name and age.

[output] | A possible algorithm to navigate through a maze could involve a Depth-First search approach. This approach involves finding a vertex within the maze, marking it as visited and then exploring all of its unvisited neighbors. After all of the neighbors are explored, the algorithm continues to explore t [instruction] | Design an algorithm to help a user navigate through a maze [input] |

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