← 목록

Synth · CodeAlpaca일부

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

[output] | testString = "Hello world!" print(testString[index]) # Output will be: w [instruction] | Construct a Python script to print a specific character from a string. [input] | str = "Hello world!" index = 5

[output] | for i in range(1,6): print('{:<10}{:<10}{:<10}{:<10}'.format(i, i**2, i**3, i**4)) [instruction] | Write the code to print a given table format in Python. [input] | Table with 4 columns and 5 rows

[output] | def row_sum(arr): row_sum = [] for row in arr: sum = 0 for ele in row: sum += ele row_sum.append(sum) return row_sum [instruction] | Input a two-dimensional array and calculate the sum of each row. [input] | arr = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

[output] | 7 [instruction] | Print out the number of items in the following list. [input] | my_list = [1, 2, 3, 4, 5, 6, 7]

[output] | def count_max(arr): max_val = 0 count = 0 for row in arr: max_val = max(max_val, max(row)) for row in arr: if max(row) == max_val: count += 1 return count [instruction] | Create a function that takes a 2D array of numerical values and returns the number of times the maximum value appears. [input] | my_array = [[1, 2, 4, 1], [2, 3, 3, 2], [3, 4, 3, 3]]

[output] | def array_sum(arr): sum = 0 for num in arr: sum += num return sum [instruction] | Create a function that returns the sum of all elements in a given array of numbers. [input] |

[output] | var userInput = prompt("Please enter your name:"); alert("Hello " + userInput + "!"); [instruction] | Create a prompt that takes user input and displays a message. [input] |

[output] | top_10 = arr[:10,] print(top_10) [instruction] | Use NumPy to extract the top 10 rows from a given matrix. [input] | import numpy as np arr = np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12]])

[output] | sortedList = sorted(myList) print(sortedList) [instruction] | Use Python to sort a given list of strings. [input] | myList = ["bananas", "oranges", "apples", "peaches"]

[output] | class UserModel(models.Model): name = models.CharField(max_length=100) address = models.CharField(max_length = 200) age = models.IntegerField() [instruction] | Create a Django model that includes a user's name, email address, and age. [input] |

[output] | class Customer: def __init__(self, name, address, phone): self.name = name self.address = address self.phone = phone [instruction] | Create a Python class to store a customer's name, address, and phone number. [input] |

[output] | .box { background-color: lightgreen; color: black; border: 1px solid white; } [instruction] | Use CSS to create a box containing some text with a light green background, black text, and a white border. [input] |

[output] | model = sklearn.linear_model.LinearRegression() model.fit(data[['crime_rate', 'school_quality]], data['house_price']) [instruction] | Build a regression model to predict house prices based on crime rate and school quality. [input] |

[output] | def insert_new_item(new_item, existing_list): """Inserts a new item into an existing list. Args: new_item (int): The item to be inserted. existing_list (list): The existing list. Returns: list: List with the new item inserted. """ existing_list.a [instruction] | Create a function in Python to insert a new item into an existing list. [input] | new_item = 5 existing_list = [1, 2, 3, 4]

[output] | The number of lines of code required to generate a Fibonacci sequence up to the n-th number is 3: one line to set the conditions, one line for the base case, and one line of the recursive loop. This does not include any lines for printing the result. [instruction] | How many lines of code are required to generate a Fibonacci sequence up to the n-th number? [input] |

[output] | SELECT MAX(student_gpa) FROM course_table WHERE course_id = 'xyz123'; [instruction] | Write a SQL query to find the highest student GPA within a specific course. [input] |

[output] | The last 10 digits of 2^1000 are 4814077888. [instruction] | Find the last 10 digits of the result of raising 2 to the power of 1000. [input] |

[output] | // This function takes a string and capitalizes every word in the string function capitalizeSentence(sentence) { // Split the sentence into individual words let words = sentence.split(' '); // Initialize the capitalized string let capitalized = ''; // Iterate through the words for (le [instruction] | Write a JavaScript code to capitalize every word in a sentence. [input] | sentence = 'hello world!'

[output] | def add_numbers(x, y): return int(x) + int(y) result = add_numbers(string1, string2) print(result) # Outputs 12 [instruction] | Create a function that takes two string arguments, adds the corresponding numbers together, and returns the result. [input] | string1 = "5" string2 = "7"

[output] | SELECT * FROM users ORDER BY last_login DESC LIMIT 1; [instruction] | Write an SQL query to find the latest users who have logged in. [input] |

[output] | ans = sum(range(1,10)) [instruction] | Rewrite the following code snippet with fewer lines of code. [input] | ans = 0 for i in range(1,10): ans += i

[output] | struct PersonalInfo { char name[50]; int age; char phone[15]; char address[120]; }; [instruction] | Design a struct in C that can be used to store personal information, such as name, age, etc. [input] |

[output] | if len(first_str) == len(second_str): print('The two strings are of equal length.') elif len(first_str) > len(second_str): print(first_str) else: print(second_str) [instruction] | Suggest a way to complete the following Python program which takes two strings as input and prints out the longer string. [input] | first_str = 'hello' second_str = 'world'

[output] | let button = document.querySelector("#button"); button.addEventListener("click", function(){ alert("Button was clicked!"); }); [instruction] | Edit the following JavaScript code snippet to add an event listener to the button such that when it is clicked, an alert message is shown. [input] | let button = document.querySelector("#button");

[output] | <select name="continents"> <option value="Africa">Africa</option> <option value="Antarctica">Antarctica</option> <option value="Asia">Asia</option> <option value="Australia">Australia</option> <option value="Europe">Europe</option> <option value="North America">North America</option> < [instruction] | Generate an HTML select element containing the names of all continents. [input] |

[output] | SELECT employeeName, startDate, salary FROM employees WHERE startDate > '2018-01-01'; [instruction] | Write a SQL query to select the employee name, start date, and salary of all employees who have joined after 2018. [input] |

[output] | for i in range(11): print(i) [instruction] | Modify the given code to create a for loop that prints a list of numbers from 0 to 10. [input] | int i = 0

[output] | function delElement(arr, el) { var index = arr.indexOf(el); if (index > -1) { arr.splice(index, 1); } return arr; } delElement(arr, 3) # Output [1, 2] [instruction] | Modify the given JavaScript code to delete an element from an array. [input] | arr = [1, 2, 3]

[output] | import nltk from nltk.corpus import wordnet sentence1 = "This has been an exciting journey" s1 = nltk.word_tokenize(sentence1) sentence2 = "It's been a thrilling ride" s2 = nltk.word_tokenize(sentence2) # First we convert the words into their respective synonyms syn1 = [] for word in s1: for [instruction] | Find the similarity between two given sentences using NLTK library. [input] | sentence1 = "This has been an exciting journey" sentence2 = "It's been a thrilling ride"

[output] | String s1 = "Update"; String s2 = s1.replace('u','v'); [instruction] | Fix the following Java code by replacing the letter "u" with "v". [input] | String s1 = "Update";

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