← 목록

Synth · CodeAlpaca일부

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

[output] | import base64 def decodeBase64(encoded_string): return base64.b64decode(encoded_string).decode('utf-8') print(decodeBase64(encoded_string)) # Output: Hello World [instruction] | Suggest a way of decoding a string encoded using Base64. [input] | encoded_string = "SGVsbG8gV29ybGQ="

[output] | import com.rabbitmq.client.ConnectionFactory; import com.rabbitmq.client.Connection; import com.rabbitmq.client.Channel; import com.rabbitmq.client.DeliverCallback; public class Consumer { public static void main(String[] args) throws Exception { // establish a connection to the RabbitMQ bro [instruction] | Write a RabbitMQ consumer in Java to listen to a particular queue. [input] |

[output] | def square_numbers(lst): lst_sq = [] for i in range(len(lst)): lst_sq.append(lst[i] ** 2) return lst_sq [instruction] | Identify and correct the bug in the following program. [input] | def square_numbers(lst): lst_sq = [] lst_sq.append(lst[i] ** 2 for i in range(len(lst))) return lst_sq

[output] | def fibonacci(n): '''This function returns the n-th Fibonacci number.''' if n == 0 or n == 1: return n fib_n_1 = 0 fib_n_2 = 1 for i in range(2, n+1): fib_n = fib_n_1 + fib_n_2 fib_n_1, fib_n_2 = fib_n_2, fib_n return fib_n [instruction] | Create a program to generate the n-th Fibonacci number. [input] |

[output] | ['#9888', '#9876', '#987'] [instruction] | Extract the strings that match the following regex pattern from a text block [input] | text block = “hotel #9888, school #9876, airport #987” regex pattern = #[0-9]{4}

[output] | puts "What is your name?" name = gets.chomp puts "Hello, #{name}!" [instruction] | Create a Ruby program that asks for a user's name and greets them with their name [input] |

[output] | public class MyClass{ private int num; private double dbl; private char c; public int getNum(){ return num; } public void setNum(int num){ this.num = num; } public double getDbl(){ return dbl; } public void setDbl(double dbl){ [instruction] | Create a class in Java with three private fields and three public functions to access those fields. [input] |

[output] | <button type="button" onclick="window.location.href='https://example.com'">Go to website</button> [instruction] | What is the HTML code for a button tag that sends the user to a URL? [input] |

[output] | <h1 style="text-align: center;">Section 1</h1> <h2 style="text-align: center;">Section 2</h2> <h3 style="text-align: center;">Section 3</h3> [instruction] | Update the below HTML snippet to make all the section heading elements center aligned. [input] | <h1>Section 1</h1> <h2>Section 2</h2> <h3>Section 3</h3>

[output] | In order to test a web application using Selenium webdriver, you need to create a Selenium script that navigates the web application, verifies the expected output, and records test results. You would then run the script on different browsers or devices to verify the application's functionality acros [instruction] | How do you test a web application using Selenium webdriver? [input] |

[output] | for x in range(0, 10): print(x) [instruction] | Replace the placeholders in the following Python code snippet with appropriate values. [input] | for x in range(__, __): print(x)

[output] | result = (condition) ? 5 : 10; [instruction] | Rewrite the below C statement using a ternary operator. [input] | if (condition) { result = 5; } else { result = 10; }

[output] | The division of 10 and 5 is 2. [instruction] | Identify the division of numbers 10 and 5. [input] |

[output] | arr = [[1,2,3], [4,5,6], [7,8,9]] [instruction] | Create a multi-dimensional array in Python. [input] |

[output] | def maximum(head): max = head.data while head is not None: if max < head.data: max = head.data head = head.next return max [instruction] | Print the maximum element in a linked list. [input] | head - [1, 3, 4, 10, 8]

[output] | def multiply_list(lst): for i in range(len(lst)): lst[i] *= 10 return lst [instruction] | Create a loop in Python to multiply each element of a list with 10. [input] | lst = [1, 2, 3, 4, 5]

[output] | arr = [2, 8, 24] # [2 * 3, 4 * 3, 5 * 3] [instruction] | Given an array of integers and a target value, modify the array such that each element is the multiplication of the previous element and the target value. [input] | arr = [2, 4, 5], target = 3

[output] | average = 8.4 # (8 + 19 + 2 + 5 + 6)/5 [instruction] | Compute the average of the elements of the given list. [input] | nums = [8, 19, 2, 5, 6]

[output] | closest_num = 7 # 10 is the closest number to 6 in the array [instruction] | Find the closest number to given value using a binary search algorithm. [input] | arr = [2, 4, 7, 10, 11, 12], val = 6

[output] | John # The value associated with 'name' is 'John' [instruction] | Print the value corresponding to the given key in a dictionary. [input] | dic = {'name': 'John', 'age': 18}, key = 'name'

[output] | class RandomNumberList: def __init__(self): self.numbers = [] def generate_random(self, min, max): return random.randint(min, max) def create_list(self, n, min, max):    # Generate a list of n random numbers between min and max        self.numbers = [self.gen [instruction] | Create a class that contains two methods: one to generate a random number between a given range, and one to create a list of "n" random numbers. [input] | n = 10, min = 0, max = 100

[output] | sum = 165 # 10 + 11 + 12 + ... + 20 = 165 [instruction] | Calculate the sum of all the integers in the range of m to n (inclusive). [input] | m = 10, n = 20

[output] | a = [1,2,3,4,5] for number in a: print(number) // Instead of looping through the number of items in 'a', loop through the items of 'a' directly. [instruction] | Suggest an improvement to make the code more efficient. [input] | a = [1,2,3,4,5] loop_count = len(a) while loop_count > 0: print(loop_count) loop_count -= 1

[output] | function print_uppercase_letters(string) { for (let i = 0; i < string.length; i++) { let char = string[i]; if (char === char.toUpperCase()) { console.log(char); } } } [instruction] | Complete the following JavaScript function so that it reads the string parameter and prints all the uppercase letters. [input] | function print_uppercase_letters(string) { }

[output] | One approach is to loop through each character in the string and check if it matches the character to be searched for. If it does, the index of the character can be returned, or a boolean indicating whether the character is present in the string or not can be returned. Another approach is to use bui [instruction] | Suggest a method to search for a specified character in a string. [input] |

[output] | result = ["zero", "one", "two"][i] // Using a list and indexing can shorten the code. [instruction] | Suggest a way to make the following code more concise. [input] | if i == 0: result = "zero" elif i == 1: result = "one" elif i == 2: result = "two"

[output] | for n in range(10): print('*' * n) // The code can be rewritten to use one single line and one loop only. [instruction] | Suggest a way to change the following code so that it does not use a nested loop. [input] | for n in range(10): for i in range(n): print('*', end='') print()

[output] | A hash table can be used to store the contacts information as it provides a key-value mapping of the information. Keys can be either the name, email or phone number depending on the mapping pattern desired. A set or LinkedList can also be used for this purpose, as the information does not have any o [instruction] | Suggest a data structure that can be used to store contacts information (name, email, phone number). [input] |

[output] | /(.*)\.net$/ // Matches URLs that end with ".net". [instruction] | Write a regular expression that matches URLs that end with ".net". [input] |

[output] | def search_prime_numbers(n): for num in range(2, n + 1): if num > 2 and num % 2 == 0: // This line can be added to make the function more efficient by avoiding the check for even numbers greater than 2. continue for i in range(2, num): if num % i == 0: [instruction] | Suggest one line of code that should be added to the following function to make it more efficient. [input] | def search_prime_numbers(n): for num in range(2, n + 1): for i in range(2, num): if num % i == 0: break else: print(num)

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