← 목록

Synth · CodeAlpaca일부

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

[output] | body { background-color: blue; } [instruction] | Write a CSS rule to set the background color to blue for all elements inside the page's body. [input] |

[output] | def bubble_sort(list): for i in range(len(list)): for j in range(i+1, len(list)): if list[i] > list[j]: list[i], list[j] = list[j], list[i] return list my_list = [4, 6, 3, 9, 1] print(bubble_sort(my_list)) [instruction] | Implement a function in Python that sorts a list in ascending order using Bubble Sort algorithm. [input] | my_list = [4, 6, 3, 9, 1]

[output] | <a href="https://www.example.com/">Visit our site</a> [instruction] | Write an HTML code to add a link to a web page. [input] | Link text: Visit our site Link URL: https://www.example.com/

[output] | UPDATE Employees SET salary = salary * 1.1; [instruction] | Update a MySQL table to increase the salary of all employees by 10%. [input] | Employess table contains the following columns: - id: Integer - name: Text - salary: Number

[output] | def float_division(num, denom): return float(num)/denom print float_division(Numerator, Denominator) Output: 0.5 [instruction] | Create a function that takes in two numbers, a numerator and a denominator, and returns the result of the division expressed as a float. [input] | Numerator = 10, Denominator = 20

[output] | def foo(a,b): return a + b [instruction] | Clean up the following function so that there are no redundant parentheses: [input] | def foo ( ( a ) , (b) ): return a + b

[output] | The function takes an integer argument and checks if it is greater than 10. If the argument is greater than 10, the function increments the argument by 1. Finally, the function returns the modified argument. [instruction] | Analyze the following code and tell us what it does. [input] | def my_function(x): while x > 10: x += 1 return x

[output] | class Calculator: def __init__(self): # initializing the calculator pass def add(self, a, b): return a + b def subtract(self, a, b): return a - b def multiply(self, a, b): return a * b def divide(self, a, b): return a / b [instruction] | You need to design a calculator class with methods to perform basic calculations (add, subtract, multiply, divide, etc.). [input] |

[output] | arr.sort() Output: arr = [1, 2, 3, 5, 7] [instruction] | Given an array, arrange the elements in order. [input] | arr = [3, 7, 2, 1, 5]

[output] | # Function to print prime numbers def prime_numbers_below_100(): for num in range(2, 100): prime = True for i in range(2, num//2 + 1): if num % i == 0: prime = False break if prime: print(num, end=" ") prin [instruction] | Create a program to print out all prime numbers below 100. [input] |

[output] | class HistoryDataStruct: def __init__(self, k): self.history_size = k self.history = [] # list of (undo command, state of only that undo command) of size k self.current_state = None # Current state of the data structure def save_states(self, state): self.hist [instruction] | Design a data structure to store an undo history of size k. [input] |

[output] | def factorial(x): fact = 1 for i in range(1,x+1): fact = fact*i return fact print(factorial(5)) [instruction] | Construct a for-loop for calculating the factorial of a given number. [input] | Number: 5

[output] | SELECT p_name FROM table_person WHERE p_age >= 21 [instruction] | Construct a SQL query to select the names of all people aged 21 years or older. [input] | Table Schema: table_person(p_id int, p_name varchar, p_age int)

[output] | ^[a-zA-Z]+$ [instruction] | Construct a regular expression for validating that a string only contains the letters a-z and A-Z. [input] |

[output] | function getNumOfDigits(num) { return num.toString().length; } [instruction] | In JavaScript construct a function to obtain the number of digits in an integer [input] |

[output] | fib_sequence = [0, 1, 1, 2, 3] [instruction] | Create a Fibonacci sequence of 5 numbers using Python. [input] |

[output] | model = lm(sales ~ ., data = Advertising) [instruction] | Create a linear regression model in R from the given datasets. [input] | Datasets: Advertising.csv

[output] | def rightangle_triangles_pattern(n): pattern = "" for i in range(1,n+1): for j in range(1,i+1): pattern = pattern + " * " pattern = pattern + "\n" print(pattern) rightangle_triangles_pattern(5) [instruction] | Define a function in Python to print a pattern of right-angled triangles of different sizes [input] |

[output] | SELECT name FROM table_workers WHERE salary >= (SELECT PERCENTILE_DISC(0.25) WITHIN GROUP (ORDER BY salary) FROM table_workers) [instruction] | Write an SQL query to return the names of workers whose salary is within the top 25% among all workers. [input] | Table Schema: table_workers(id int, name varchar, salary int)

[output] | common_key_words = ["language", "easy", "learn", "comparing", "other", "simpler"] [instruction] | Extract the common key words from the given two strings using a Python script. [input] | String 1: This programming language is easy to learn String 2: Comparing to other languages, this language is simpler

[output] | <!DOCTYPE html> <html> <head> <title> About Us </title> <style> body { font-family: Arial; } .container { width: 90%; margin: auto; padding: 10px; } .about-us-header { font-size: 20px; } .about-us-content [instruction] | Design a UI layout in HTML and CSS for an About Us page. [input] |

[output] | for num in range(1, 51): if num > 1: for i in range(2, num): if (num % i) == 0: break else: print(num) [instruction] | Construct a for-loop for finding all prime numbers between 1 and 50 in Python. [input] |

[output] | switch (day) { case 1: console.log("Monday"); break; case 2: console.log("Tuesday"); break; case 3: console.log("Wednesday"); break; ..... case 7: console.log("Sunday"); break; default: cons [instruction] | Create a switch statement for printing out the day for a given number [input] |

[output] | def rearrangeWord(string): temp_string = string.split(" ") rearranged_string = [word[::-1] for word in temp_string] return " ".join(rearranged_string) print(rearrangeWord(string)) [instruction] | Create a function in Python to rearrange the characters of each word in a given string. [input] | string = "Welcome to the world of Python"

[output] | public static int CountChar(String string, char character) { int count = 0; for (int i=0; i<string.length(); i++) { if (string.charAt(i) == character) count++; } return count; } [instruction] | You need to develop a Java function to get the count of a given character in a given string. [input] | string = "Hello World" character = 'l'

[output] | @sorted_arr = sort {$b <=> $a} @arr; print "@sorted_arr\n"; [instruction] | Develop a script in Perl to sort an array. [input] | arr = (11, 12, 4, 15, 6)

[output] | INSERT INTO Employees (name, age, address) VALUES ('Jack', 25, 'NewYork'); [instruction] | Write an SQL query to insert a new record with values 'name': 'Jack', 'age': 25, 'address': 'New York' into a table named 'Employees'. [input] |

[output] | def my_function(num): res = num * 2 print(res) [instruction] | Correct the indentation in the code below. [input] | def my_function(num): res=num*2 print(res)

[output] | # Function to remove all consecutive duplicates in the string def remove_duplicates(string): # Empty string to store the result result = '' # Iterate over the string and keep track of the previous character seen prev = '' for char in string: # If the current characte [instruction] | Given a string, remove all consecutive duplicates in the string. [input] | string = "aabbccddeeff"

[output] | # Function to reverse the order of the given array def reverse_array(nums): # Variable to store the result result = [] # Iterate over the provided array starting from the last element for i in range(len(nums) -1, -1, -1): # Append each number to the result array [instruction] | Reverse the order of the given array without using inbuilt functions. [input] | nums = [12, 23, 34, 45]

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