← 목록

Synth · CodeAlpaca일부

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

[output] | def myfunc(): x = 1 y = 5 return x + y [instruction] | Design a program that automatically refactors a python code to improve readability and reduce complexity. [input] | def myfunc(): x = 1 y = 5 return x + y

[output] | def func1(): print("this is function 1") print("this is function 2") [instruction] | Beatify the following code by formatting it properly with adequate indentation and formatting. [input] | def func1(): print("this is function 1") print("this is function 2")

[output] | import java.util.Random; public class RollDie { public static void main(String[] args) { // creating instance of Random class Random rand = new Random(); // Generate random integers in range 0 to 6 int rand_int = rand.nextInt(6); // P [instruction] | Design a die roll program in Java. [input] |

[output] | var first = 10; var second = 15; // finding sum of two numbers var sum = first + second; // printing the result console.log("Sum of two numbers is " + sum); [instruction] | Write a JavaScript program for finding the sum of two numbers. [input] | numbers: 10, 15

[output] | <strong>Bold Text</strong> [instruction] | Write an HTML code snippet to make the text bold. [input] |

[output] | <html> <head> <title>Fruits List</title> </head> <body> <ul> <li>Apple</li> <li>Orange</li> <li>Pineapple</li> </ul> </body> </html> [instruction] | Create a HTML page that contains an unordered list with given items in a given order. [input] | list items: " Apple ", " Orange ", " Pineapple"

[output] | let a = 10; let b = 20; let c = 23; // greatest of three numbers let greatest = 0; if(a >= b && a >= c) { greatest = a; } else if(b >= a && b >= c) { greatest = b; } else { greatest = c; } console.log('The greatest number among the given numbers is ' + greatest); [instruction] | Write a JavaScript code snippet to find the greatest of three given numbers. [input] |

[output] | class Pattern { static void Main(string[] args) { for (int i = 1; i <= 5; i++) { for (int j = 1; j <= i; j++) { Console.Write("*"); } Console.WriteLine(); } for (int i = 4; i >= 0; i--) { [instruction] | Design a program in C# to print the following patterns. [input] |

[output] | def can_form_word(set_letters, word): flag = True for letter in word: if letter not in set_letters: flag = False break return flag [instruction] | Develop a function in python to check if a given word can be formed with the given set of letters. [input] | Set of letters: 'abeos' Word: 'seabed'

[output] | Abraham [instruction] | Extract the first name of the user from the below format. [input] | Full Name- Abraham Lincoln

[output] | def list_elements(dict): for item in dict: print(item, ":", dict[item]) list_elements(dictionary) # Output: # name : John # age : 20 # location : London [instruction] | Develop a code in python to list the elements present in a given dictionary. [input] | dictionary = { "name": "John", "age": 20, "location": "London" }

[output] | cbve [instruction] | Replace every occurrence of 'a' with 'b' in the given string. [input] | cave

[output] | def quick_sort(arr): if len(arr) < 2: return arr else: pivot = arr[0] i = 1 for j in range(1, len(arr)): if arr[j] < pivot: arr[i], arr[j] = arr[j], arr[i] i = i + 1 arr[0], arr[i-1] = arr[i-1], arr[0] [instruction] | Modify the previous code so that it is now optimized for time complexity? [input] | def quick_sort(arr): if len(arr) < 2: return arr else: pivot = arr[0] less = [i for i in arr[1:] if i <= pivot] greater = [i for i in arr[1:] if i > pivot] return quick_sort(less) + [pivot] + quick_sort(greater)

[output] | let array = [2, 4, 6, 8, 10]; for (let i=0; i<array.length; i++) { console.log(array[i]); } [instruction] | Create a JavaScript program to loop the following array [input] | array = [2, 4, 6, 8, 10];

[output] | let array = [2, 3, 4, 5, 6, 7, 8, 9]; for (let i=0; i<array.length; i++) { if (array[i] % 2 === 0) { console.log(array[i]); } } [instruction] | Print the even numbers in a given array? [input] | array = [2, 3, 4, 5, 6, 7, 8, 9];

[output] | square_numbers = [] for i in range(10): square_numbers.append(i * i) print(square_numbers) # [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] [instruction] | Create a list of square numbers between 0 and 9 [input] |

[output] | let array = [2, 4, 1, 6, 8, 9, 5]; let sorted_array = array.sort((a, b) => a-b); console.log(sorted_array); // [1, 2, 4, 5, 6, 8, 9] [instruction] | Create a JavaScript Program to sort an unsorted array [input] | array = [2, 4, 1, 6, 8, 9, 5];

[output] | sentence = "The Quick Brown Fox Jumps Over The Lazy Dog" sentence = sentence.lower().split() sentence = ' '.join(sentence) print(sentence) [instruction] | Write a script to normalize each word in a given sentence by converting it into lowercase. [input] | The Quick Brown Fox Jumps Over The Lazy Dog.

[output] | import tensorflow as tf model = tf.keras.Sequential([ tf.keras.layers.Dense(8, input_dim=2, activation="relu"), tf.keras.layers.Dense(1, activation="sigmoid") ]) model.compile(loss='binary_crossentropy', optimizer=tf.keras.optimizers.Adam(0.01), metrics=['accuracy' [instruction] | Write a Tensorflow model to classify a given X and Y as either positive or negative. [input] | X = [1, 1, 2, 4] Y = [3, 1, 0, 4]

[output] | import json # input JSON json_data = '{ "person": { "name":"John", "age":30, "location":"USA" } }' # parse json data = json.loads(json_data) # get the name name = data["person"]["name"] # print the name print(name) [instruction] | Read this JSON structure, parse it and print the value of "name". [input] | { "person": { "name":"John", "age": 30, "location": "USA" } }

[output] | import matplotlib.pyplot as plt # Data to plot algorithm1 = [90, 91, 95, 94, 99] algorithm2 = [83, 89, 95, 91, 99] # plotting a bar chart plt.bar([1, 2, 3, 4, 5], algorithm1, label = "Algorithm1", width = 0.25, color = 'b') plt.bar([1.25, 2.25, 3.25, 4.25, 5.25], algorithm2, label [instruction] | Write code to create a bar chart comparing the performance of two different algorithms. [input] | Algorithm 1: [90, 91, 95, 94, 99] Algorithm 2: [83, 89, 95, 91, 99]

[output] | <!DOCTYPE html> <html> <head> </head> <body> <form action="submit.php" method="post"> Email: <input type="text" name="email"> Message: <input type="text" name="message"> <input type="submit" value="Submit"> </form> </body> </html> [instruction] | Create a HTML form to allow users to enter an email address and a message. [input] |

[output] | .blue-background { background-color: blue; } [instruction] | Create a CSS class 'blue-background' which will set background color of any div to blue. [input] |

[output] | NSMutableArray *names = [NSMutableArray array]; [instruction] | Write an Objective-C statement to create an empty array to hold names. [input] |

[output] | To debug an unresponsive Flask web application, you should first check the server logs. If there are any errors, they should be debugged first. Other steps might include disabling caching, checking for memory leaks, checking for database locking, and checking for any long-running requests. You could [instruction] | How will you debug an unresponsive Flask web application? [input] |

[output] | One efficient algorithm to search for an item in an array is the binary search algorithm. The binary search algorithm works by dividing the array into two parts and then searching through the divided parts in logarithmic time. The algorithm starts by comparing the item to be searched with the middle [instruction] | Design an efficient algorithm to search for an item in an array. [input] |

[output] | Recursion is a powerful technique for solving problems because it allows for decomposing complex problems into simpler subproblems. By breaking down a problem into smaller components, it becomes easier to solve. This process can be repeated until a base case is reached, providing a way to reach a so [instruction] | Explain why recursion is a powerful technique for solving problems. [input] |

[output] | def get_first_n_chars(string, n): return string[:n] [instruction] | Create a function in Python which takes a string and an integer n as input and returns a string with the first n characters of the given string. [input] |

[output] | The most efficient algorithm to find the maximum element in an array is the Linear Search algorithm. This algorithm works by looping through the array and comparing each element to find the maximum element. This algorithm takes O(n) time and requires no additional space. [instruction] | Identify the most efficient algorithm to find the maximum element in an array. [input] |

[output] | def reverse_words(sentence): words = sentence.split() reversed_words = [word[::-1] for word in words] return ' '.join(reversed_words) print(reverse_words("This is a test")) # Output: sihT si a tset [instruction] | Write a Python program to reverse each word of a given sentence. [input] | This is a test

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