← 목록

Synth · CodeAlpaca일부

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

[output] | let obj = { name: 'John', age: 20, printDetails() { console.log(`The name is ${this.name} and age is ${this.age}`); } } [instruction] | Given the object below, debug the problem to make a valid code in JavaScript. [input] | let obj = { name: 'John', age: 20, printDetails: () => { console.log(`The name is ${name} and age is ${age}`); } }

[output] | 10.0 [instruction] | Compute the average of the following three numbers: 5, 10, and 15. [input] |

[output] | for i in range(10): print(i) [instruction] | Create a for loop that prints the following output: [input] |

[output] | function findIndexOf(array, num) { return array.indexOf(num); } [instruction] | Using the given array, create a function that takes in two arguments, the array and a number, and returns the position of the number in the array. [input] | let arr = [1, 7, 9, 8, 5]

[output] | if (num % 3 == 0 && num % 5 == 0) { console.log("FizzBuzz"); } else if (num % 3 == 0) { console.log("Fizz"); } else if (num % 5 == 0) { console.log("Buzz"); } [instruction] | Create an if statement that prints "Fizz" if a number is divisible by 3 and "Buzz" if a number is divisible by 5. [input] |

[output] | "coding do can I" [instruction] | Reverse this sentence: "I can do coding." [input] |

[output] | #/bin/bash echo "Enter the first number: " read num1 echo "Enter the second number: " read num2 echo "Enter the third number: " read num3 echo "The sum of the three numbers is: " echo $(($num1 + $num2 + $num3)) [instruction] | Write a Bash script to read three numbers and print their sum to the screen. [input] |

[output] | function printAge(obj) { console.log(obj.age); } [instruction] | Using the given object, create a function to print out the value of the property "age" within the object. [input] | let obj = { name: 'John', age: 20, printDetails: () => { console.log(`The name is ${name} and age is ${age}`); } }

[output] | function findGCD(num1, num2) { let min = Math.min(num1, num2); while (num1 % min !== 0 || num2 % min !== 0) { min--; } return min; } let result = findGCD(45, 36); console.log(result); // output: 9 [instruction] | Use JavaScript to write a program that finds the greatest common divisor of two numbers. [input] | num1 = 45 num2 = 36

[output] | /** * Generates a random float value within the given range (inclusive). * @param min the minimum value of the range * @param max the maximum value of the range * @return a random float value within the range */ public static float randomFloat(float min, float max) { Random rand = new Rando [instruction] | Implement a method in Java to generate a random float within the given range. [input] | min = 0.3 max = 0.7

[output] | list_in = [40, 32, 12, 19] list_in.sort() print(list_in) #output: [12, 19, 32, 40] [instruction] | Edit the code below to sort the list of integers given in the input. [input] | list_in = [40, 32, 12, 19]

[output] | name = str age = int if_married = bool [instruction] | Substitute the correct data type for each variable in the code below. [input] | name = <data_type> age = <data_type> if_married = <data_type>

[output] | print(list1[3][1]) print(list1[4][0]) print(list1[3][1]) # output: 50 print(list1[4][0]) # output: 60 [instruction] | Create a Python program to take the input and print the output as shown in the example below. [input] | list1 = [10, 20, 30, [40, 50], [60, 70], 80]

[output] | SELECT name FROM developers WHERE seniority = 'Senior' [instruction] | Construct an SQL query to find the names of all senior developers. [input] | developers table: id INT, name VARCHAR(50), seniority VARCHAR(20)

[output] | # Merges two subarrays of arr[]. # First subarray is arr[l..m] # Second subarray is arr[m+1..r] def merge(arr, l, m, r): n1 = m - l + 1 n2 = r- m # create temp arrays L = [0] * (n1) R = [0] * (n2) # Copy data to temp arrays L[] and R[] for i in range(0 , n1 [instruction] | Let's try a different sort algorithm. Generate a Python code snippet to implement merge sort. [input] |

[output] | def input_validation(input): try: input = int(input) if input >= 2 and input <= 6: return True else: return False except ValueError: return False [instruction] | Create an input validation function in Python which checks that the input is an integer between 2-6. [input] |

[output] | def sortInt(nums): for i in range(len(nums)-1): for j in range(i+1,len(nums)): if nums[i] > nums[j]: #Swap nums[i],nums[j] = nums[j],nums[i] return nums [instruction] | Make a function in Python that sorts a list of integers in increasing order. [input] | [50, 2, 8, 7, 19, 29]

[output] | <div class="container"> <div class="header"> <div class="row1">Row1</div> <div class="row2">Row2</div> </div> <div class="main"> <div class="column1">Column1</div> <div class="column2">Column2</div> </div> </div> [instruction] | Develop an HTML/CSS layout with 2 columns and a 2-row header. [input] |

[output] | SELECT * FROM sales ORDER BY amount DESC LIMIT 10; [instruction] | Create a MySQL query to select the top 10 sales records from the table "sales". [input] |

[output] | db.collection.find({ "quantity": { $gt: 5 } }) [instruction] | Create a MongoDB query to find all records with a "quantity" field greater than 5. [input] |

[output] | <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Calculator</title> </head> <body> <h1>Calculator</h1> <form> <label> Number 1: <input type="text" name="nu [instruction] | Create an HTML page with a basic calculator form that takes two numbers as inputs and computes and displays the sum. [input] |

[output] | SELECT * FROM table_name WHERE name LIKE 'A%'; [instruction] | Create a MySQL query to select the records whose name fields begins with an "A". [input] |

[output] | <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Layout</title> <style> .row { display: flex; flex-wrap: wrap; } .column { flex: 25 [instruction] | Develop a CSS/HTML page with a 3-column layout and a sticky navigation bar. [input] |

[output] | def print_list_tuple(t): for item in t: print(item) [instruction] | Create a function that prints out the List of tuples. [input] | t = [(1, 5), (0, 1), (10, 20)]

[output] | DELETE FROM Customer WHERE Country = 'USA' AND Age = 18; [instruction] | Construct an SQL query to delete rows from a table that fulfill two conditions. [input] | Table Name: Customer Conditions: (1) Country = ‘USA’ (2) Age = 18

[output] | fahrenheit_temperature [instruction] | Suggest a name for the variable that represents a temperature value in Fahrenheit [input] |

[output] | url = "http://www.example.com:port/path?query=blah" [instruction] | Update the following code to create a valid URL [input] | url = "www.example.com:port/path?query=blah"

[output] | def xor_encrypt(string, key): encrypted_string = "" for i, letter in enumerate(string): encrypted_string += chr(ord(letter) ^ ord(key[i % len(key)])) return encrypted_string [instruction] | Create a function to encrypt a string using the XOR operator. [input] | key = 'ABCDEFG'

[output] | class Car: def __init__(self, hp, speed): self.hp = hp self.speed = speed [instruction] | Create a class definition for a Car object with attributes of HP and speed. [input] |

[output] | def change_case(string): return string.swapcase() [instruction] | Change the case of all characters in a string. [input] | string = "Hello World!"

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