← 목록

Synth · CodeAlpaca일부

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

[output] | """ Write code to check if a given string contains only alpha-numeric characters. """ def is_alnum(string): return string.isalnum() if __name__ == '__main__': string = 'Hello World!' print(is_alnum(string)) [instruction] | Write code to check if a given string contains only alpha-numeric characters. [input] | Hello World!

[output] | """ Edit the following code to make it terminate in a finite number of steps. """ def foo(): for _ in range(10): print("Hello") [instruction] | Edit the following code to make it terminate in a finite number of steps [input] | def foo(): while True: print("Hello")

[output] | """ Given an array of English words, find any word which is an anagram of another word in the same array. """ def find_anagrams(words): anagrams = [] for i in range(len(words)): for j in range(i+1, len(words)): if (sorted(words[i]) == sorted(words[j])): [instruction] | Given an array of English words, find any word which is an anagram of another word in the same array. [input] | ["listen", "pot", "part", "opt", "trap", "silent", "top"]

[output] | """ Given an array containing words and a string, find the shortest word in the array that is a substring of the string. """ def find_shortest_substring(words, string): min_length = float("inf") min_word = None for word in words: j = string.find(word) if j>-1 and len(wo [instruction] | Given an array containing words and a string, find the shortest word in the array that is a substring of the string [input] | words = ["apple", "banana", "cat", "dog"], string = "aquickbrownfoxjumpsoverthelazydog"

[output] | """ Replace the character on odd index positions with '#'. """ def add_pound_signs(string): result_string = "" for i in range(len(string)): if i % 2 == 1: result_string += "#" else: result_string += string[i] return result_string if __name__ == ' [instruction] | Replance the character on odd index positions with '#'. [input] | "Hello World!"

[output] | def print_multiplication_table(x): for i in range(1, 11): ans = i*x print(f"{i} x {x} = {ans}") print_multiplication_table(x) [instruction] | Create a function that prints the multiplication table for a provided integer [input] | x = 8

[output] | words = string.split(' ') reversed_words = words[::-1] reversed_string = ' '.join(reversed_words) [instruction] | Using the given code snippet, reverse the words of the string. [input] | string = "this is a string"

[output] | The salient feature of the given code is that it both prints a result and returns a value. [instruction] | Identify the salient feature in the given piece of code. [input] | def func(x, y): z = x + y print(z) return x - y

[output] | intSetA = new HashSet<Integer>(); intSetA.addAll(Arrays.asList(1, 2, 3, 4)); intSetB = new HashSet<Integer>(); intSetB.addAll(Arrays.asList(2, 4, 6, 8)); intSetA.retainAll(intSetB); System.out.println("Intersection of SetA and SetB is " + intSetA); // Output: Intersection of SetA and SetB is [2, [instruction] | Use set operations to obtain the intersection of two given sets. [input] | SetA = {1, 2, 3, 4} SetB = {2, 4, 6, 8}

[output] | x <- 4:24 [instruction] | Write a R code to create a vector with a sequence of 15 numbers starting at 4 and ending at 24. [input] |

[output] | p { font-size: 20px; } [instruction] | Edit the CSS code to change the font size to 20 pixels. [input] | p { font-size: 14px; }

[output] | SELECT * FROM Employees WHERE departmentCode = 'IT'; [instruction] | Write a SQL query to select all employees from the department with the code 'IT'. [input] |

[output] | TypeScript is an open-source programming language developed and maintained by Microsoft. It is a typed superset of JavaScript that compiles to plain JavaScript, and is further designed for developing large applications. In addition, TypeScript supports object-oriented programming features such as cl [instruction] | Explain what TypeScript is. [input] |

[output] | for(var i = 0; i < 10; i++) { console.log("Hello World"); } [instruction] | Write a code snippet to print out "Hello World" ten times. [input] |

[output] | <!DOCTYPE html> <html> <head> <title>Welcome!</title> </head> <body> <h1>Welcome!</h1> <p>I am happy to be here.</p> </body> </html> [instruction] | Create an HTML page with an <h1> heading "Welcome!" and a <p> paragraph with the text "I am happy to be here." [input] |

[output] | The purpose of a pivot table in Excel is to summarize and analyze data. It can quickly summarize large amounts of data and create useful summaries with a few clicks. Pivot tables are useful for quickly analyzing data in different ways, such as sorting and filtering, and deriving meaningful insights. [instruction] | What is the purpose of a pivot table in Excel? [input] |

[output] | for (let i=0; i<array.length; i++) { if (i < array.length-1) { console.log(array[i] + ","); } else { console.log(array[i]); } } [instruction] | Write a code snippet to print out the elements of an array of integers, separated by a comma. [input] | array = [2, 4, 6, 8]

[output] | CSS stands for "Cascading Style Sheets", which is a style sheet language used for describing the presentation of a webpage written in HTML or XML. [instruction] | What does the acronym "CSS" stand for? [input] |

[output] | window.globalVariable = "value"; [instruction] | Write the code to set a global variable in JavaScript. [input] |

[output] | A 2D array (or two-dimensional array) is an array of arrays, meaning it is a collection of elements which are themselves arrays. Each element in the 2D array can be thought of as a row, and the elements inside that row can be thought of as columns. The elements all have the same data type. [instruction] | What is a 2D array? [input] |

[output] | function intToString(arr){ var strings = []; for(let i = 0; i < arr.length; i++) { strings.push(arr[i].toString()); } return strings; } [instruction] | Create a Javascript function to convert an array of integers into a new array of strings. [input] | [3, 6, 9]

[output] | <?php echo "<table border=\"1\">"; for($i = 1; $i <= 10; $i++ ) { echo "<tr>"; for($j = 1; $j <= 10; $j++ ) { echo "<td>".$i * $j."</td>"; } echo "</tr>"; } echo "</table>"; ?> [instruction] | Create a PHP script to generate a multiplication table until 10. [input] |

[output] | result <- sample(1:10, 10, replace = TRUE) print(result) [instruction] | Write an R script to generate a random number sequence between 1 and 10. [input] |

[output] | int[] array = new int[10]; [instruction] | Construct an array of size 10 to store integers in Java. [input] |

[output] | <p><bold>Hello World</bold></p> [instruction] | Change the following code to make the "Hello World" message appear in bold. [input] | <p>Hello World</p>

[output] | function calculateTip(bill) { return (bill < 50 ? bill * 0.2 : bill * 0.15); } [instruction] | Rewrite the following function to use a ternary operator instead. [input] | function calculateTip(bill) { if (bill < 50) { return bill * 0.2; } else { return bill * 0.15; } }

[output] | result = 2 ** 3 print(result) # Outputs 8 [instruction] | Compute 2 to the 3rd power using Python. [input] |

[output] | #!/bin/bash echo "Your current working directory is: $(pwd)" [instruction] | Write a bash script to echo the user's current working directory. [input] |

[output] | def sum_elements(matrix): result = 0 for i in range(len(matrix)): for j in range(len(matrix[i])): result = result + matrix[i][j] return result print(sum_elements(matrix)) [instruction] | Construct a code to find the sum of all elements in a given 2D matrix [input] | matrix = [[1, 2, 3],[4, 5, 6],[7, 8, 9]]

[output] | let num1 = 10; let num2 = 8; let sum = num1 + num2; console.log(sum); // Output will be 18. [instruction] | Make the following changes to a JavaScript program. [input] | let num1 = 10; let num2 = 8;

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