← 목록

Synth · CodeAlpaca일부

총 20,022개 · 페이지 1/668
🔀 랜덤 처음으로
불러오는 중…

[output] | def max_of_two(x, y): if x > y: return x else: return y [instruction] | Write a function that takes two parameters and will print out the maximum of the two. [input] |

[output] | curl -X GET http://example.com [instruction] | Create a cURL command that retrieves the contents of a webpage. [input] |

[output] | # Prints all numbers from 0 to 99 for i in range(100): print(i) [instruction] | Add a comment to explain the purpose of the following code. [input] | for i in range(100): print(i)

[output] | def sumNonDuplicates(arr): sum = 0 for num in arr: if arr.count(num) == 1: sum += num return sum [instruction] | Write a function that given a list of unique integers, returns the sum of the non-duplicated integer elements. [input] | [1, 2, 2, 3, 4, 5, 6]

[output] | public class Animal { private String species; private int age; public Animal(String species, int age) { this.species = species; this.age = age; } } [instruction] | Give an example of a class in Java. [input] |

[output] | def foo(): value = input() [instruction] | Fill in the blank with appropriate generic function to complete the code. [input] | def foo(): value = ____

[output] | """ Write a code to search a word in a given string and get the index position """ def search_word(word, string): return string.find(word) word = 'Hello' string = 'Hello World' print(search_word(word, string)) # print 0 [instruction] | Write a code to search a word in a given string and get the index position. [input] | word = 'Hello' string = 'Hello World'

[output] | <html> <head> <title>Calculator Webpage</title> </head> <body> <h1>Calculator</h1> <div class="container"> <div class="display"> <p>0</p> </div> <div class="keypad"> <div class="number-pad"> [instruction] | Create a web page using HTML and CSS which displays a user interface for a calculator. [input] |

[output] | <html> <head> <title>Table Example</title> </head> <body> <table> <tr> <th>Column 1</th> <th>Column 2</th> <th>Column 3</th> </tr> <tr> <td>Row 1 Data 1</td> <td>Row 1 Data 2</td> <td>Row 1 Data 3</td> </tr> [instruction] | Draft an HTML page with a table that contains three columns and two rows. [input] |

[output] | for i in range(6): print(i) [instruction] | Update the following code to loop through the numbers 0 to 5. [input] | for i in range(): print(i)

[output] | for i in range(3, 11): print(i) [instruction] | Create a loop to print a sequence of numbers from 3 to 10 [input] |

[output] | def remove_whitespace(text): return text.replace(" ", "") text_without_whitespace = remove_whitespace(text) print(text_without_whitespace) # prints "Thisisasentencewithsomewhitespace!" [instruction] | Create a Python program to remove all whitespace from the given string. [input] | text = " This is a sentence with some whitespace! "

[output] | g++ -o my_program my_program.cpp [instruction] | Compile a C++ program, called "my_program", with the following code. [input] | #include <iostream> int main() { std::cout << "Hello World!"; return 0; }

[output] | public static boolean isPrime(int n) { // Corner cases if (n <= 1) return false; if (n <= 3) return true; // This is checked so that we can skip // middle five numbers in below loop if (n % 2 == 0 || n % 3 == 0) return false; for ( [instruction] | Write an algorithm in Java to check if a number is a prime number. A prime number is an integer greater than 1 that is only divisible by 1 and itself. [input] |

[output] | The average of 1, 2 and 3 is 2.0. [instruction] | Calculate the average of the numbers 1, 2, and 3. [input] | <noinput

[output] | HashMap<String, String> map = new HashMap<>(); map.put("name", "John"); [instruction] | Write a Java code to create a HashMap and add elements into it. [input] | //Given Key and Value // key: "name" // value: "John"

[output] | $(window).scroll(function() { console.log('Scroll detected'); }); [instruction] | Create a jQuery function to detect when a page is scrolled. [input] |

[output] | def long_com_subarr(arr1, arr2): len1 = len(arr1) len2 = len(arr2) res = 0 count = 0 for i in range(len1): for j in range(len2): if arr1[i] == arr2[j]: count += 1 else: if result < count: r [instruction] | Create a program in python to find the longest common contiguous subarray between two integers. [input] | int arr1[7] = {1,2,4,4,4,4,7} int arr2[5] = {1,4,4,5,5}

[output] | def remove_primes(list): modified_list = [] for idx, num in enumerate(list): if is_prime(idx) == False: modified_list.append(num) return modified_list [instruction] | From a given list, remove all elements that have a prime index. [input] | list = [4, 7, 10, 11, 14]

[output] | int[, ,] array3D = new int[x, y, z]; [instruction] | Create a 3-dimensional array of ints in C#. [input] |

[output] | def find_longest_string(list): # Set initial max_length to the length of the first item in list max_length = len(list[0]) # Set initial max_string to the first string in the list max_string = list[0] # Loop through remaining strings in the list for i in range(1, len(list)): [instruction] | Design an algorithm to search for the longest string in a list. [input] | list = ["apples", "bananas", "kiwis"]

[output] | SELECT * FROM employee WHERE YEAR(CURDATE()) - YEAR(dob) BETWEEN 30 and 39; [instruction] | Write a SQL query to select the employees who are in their 30s. [input] |

[output] | <html> <head> <style> ul { list-style-type: none; padding: 0; margin: 0; } li { font-family: sans-serif; font-size: 20px; padding: 10px; border-bottom: 1px solid #ccc; } </style> </head> <body> <ul> [instruction] | Create a dynamic web page using HTML and CSS to display a list of books. [input] |

[output] | A min-heap is a data structure used for storing and retrieving data. It is a complete binary tree, where the root node is the minimum element in the heap. Each node of the heap follows the "min-heap" property, where the parent node is always less than or equal to its children. This property allows f [instruction] | Explain how a min-heap works. [input] |

[output] | #!/bin/bash DIR="example" mkDIR -p "$DIR/subdir1/subdir2" [instruction] | Write a Bash script for creating a directory and its subdirectories. [input] |

[output] | if x > 0: # execute one block of code else: # execute another block of code [instruction] | Construct an if-else statement to handle a conditional execution. [input] | if x is greater than 0

[output] | def classify_word(word): """ This function takes a word as a parameter and returns its classification - verb or noun. """ if word in ["run", "jump", "swim"]: return "verb" else: return "noun" print(classify_word("write")) # prints "verb" [instruction] | Algorithmically classify a given word as either a verb (action word) or a noun (object). [input] | word = "write"

[output] | Yes [instruction] | What should be the output for the given code? [input] | a = 7 b = 2 if a % b == 0: print("Yes") else: print("No")

[output] | SELECT SUM(price) FROM Purchases; [instruction] | Write an SQL query to calculate the sum of all prices of items purchased by customers. [input] |

[output] | import numpy as np [instruction] | Import the numpy library into the program [input] |