← 목록

Synth · CodeAlpaca일부

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

[output] | def print_numbers(): '''This function prints numbers from 1 to 20, and also prints "skip" for the multiplies of 3 and 5.''' for num in range(1, 21): if num % 3 == 0 and num % 5 == 0: print("skip") else: print(num) print_numbers() # Output: 1 2 skip 4 [instruction] | Create a function to print the numbers from 1 to 20, and also print "skip" for multiplies of 3 and 5. [input] |

[output] | names = ["John", "Jacob", "Sophia", "Olivia", "Michael"] long_names = {name for name in names if len(name) > 6} print(long_names) # Output: {'Sophia', 'Olivia', 'Michael'} [instruction] | Using the given list of names, create a new set that contains only the names with length greater than 6. [input] | names = ["John", "Jacob", "Sophia", "Olivia", "Michael"]

[output] | # Decision Tree def classify_grades_decision_tree(grade): if grade in range(90, 101): # A range return 'A' elif grade in range(80,90): # B range return 'B' elif grade in range(70,80): # C range return 'C' elif grade in range(60,70): # D range return 'D [instruction] | Create a decision tree to classify if a given student's grade ranges from A to D. [input] |

[output] | <ul> <li>Apple</li> <li>Orange</li> <li>Banana</li> <li>Grapes</li> </ul> [instruction] | Suggest a completion for the following HTML code to demonstrate items in a unordered list. [input] | <ul> <li></li> </ul>

[output] | <div> <a href="#">Home</a> <a href="#">About</a> <a href="#" class="active">Contact</a> </div> [instruction] | Assign a class of 'active' to the last <a> element in the given HTML code. [input] | <div> <a href="#">Home</a> <a href="#">About</a> <a href="#">Contact</a> </div>

[output] | number = 5 print(number*number) # Output: 25 [instruction] | Suggest a completion to the following python code to print the square of a number. [input] | number = 5 print(number)

[output] | class ImmutableList: def __init__(self, list_values): self._dict = dict() for i, elem in enumerate(list_values): self._dict[i] = elem def __getitem__(self, item): return self._dict[item] def __len__(self): return len(self._dict) [instruction] | Create a class in Python that creates an immutable list. [input] |

[output] | SELECT C.name FROM Customers C INNER JOIN Orders O ON C.customer_id = O.customer_id WHERE O.order_date >= CURRENT_DATE - INTERVAL '1' MONTH GROUP BY C.name HAVING COUNT(*) > 2; [instruction] | Write an SQL query to find the name of customers who have ordered more than two items this month. [input] |

[output] | SELECT item_name, price FROM products ORDER BY price DESC LIMIT 10; [instruction] | Write an SQL query to find the top 10 highest-priced items in the products table. [input] |

[output] | list = [1,1,4,8,10,12,13] def insertion_sort(arr): for i in range(1, len(arr)): key = arr[i] j = i-1 while j >=0 and key < arr[j] : arr[j+1] = arr[j] j -= 1 arr[j+1] = key arr = [1,12,1,4,8,10,13] insertion_sort(arr) print (ar [instruction] | Sort the list below using insertion sort in Python: [input] | list = [1,12,1,4,8,10,13]

[output] | for (var i = 0; i < names.length; i++) { console.log(names[i]); } [instruction] | Write an algorithm in JavaScript to print all the elements inside a given array. [input] | var names = ["Harry", "Ron", "Hermione"]

[output] | def calculate_squares(arr): result = [] for num in arr: result.append(num ** 2) return result [instruction] | Describe an algorithm to convert an array of numbers into an array of its squares. [input] |

[output] | int a = 5; int b = 2; int c = a - b; [instruction] | Produce a snippet of C++ code to subtract two given numbers a and b. [input] |

[output] | ^[A-Z]+$ [instruction] | Write a regular expression to match the following pattern: words that consist only of capital letters. [input] |

[output] | # Algorithm to reverse a string def reverse_string(s): # Create a result string result = "" # Iterate through the string in reverse order for i in range(len(s)-1, -1, -1): result += s[i] return result [instruction] | Suggest the best algorithm to reverse a string. [input] |

[output] | def add_two_integers(x, y): return x + y [instruction] | Create a function to add two integers x and y. [input] |

[output] | ^[0-9]{8,16}$ [instruction] | Construct a regular expression that matches a string containing numbers from 0 to 9 within a range of 8 and 16 digits. [input] |

[output] | Software design patterns are important because they allow developers to create extensible and maintainable software applications. Design patterns provide a way of reusing the same code and structure across multiple applications, while allowing the application to remain logically organized. This can [instruction] | Explain why software design patterns are important in software development. [input] |

[output] | #!/bin/bash # num will be the number to be checked num=2 # counter to count the number of Prime numbers counter=0 echo "First 10 prime numbers are:" while [ $counter -lt 10 ] do # isPrime will take value 0 or 1, 1 if prime isPrime=1 # i will start from 2, because 2 is the smallest prime nu [instruction] | Create a shell script to find the first ten prime numbers [input] |

[output] | SELECT COUNT(*) AS Customer_Count, Country FROM Customers GROUP BY Country; [instruction] | Write a SQL query to generate a report which display the total number of customers in each country. [input] |

[output] | <form action="form-handler.php" method="post"> <label>Name:</label><br> <input type="text" name="name"><br> <label>Age:</label><br> <input type="text" name="age"><br> <input type="submit" value="Submit"> </form> [instruction] | Write an HTML code to design a form which contain two fields, Name and Age. The form should have a button with text "Submit". [input] |

[output] | <html> <head> <title>Hello World</title> </head> <body> <p style="color: red; font-family: Times New Roman;">Hello World!</p> </body> </html> [instruction] | Create a HTML document which show "Hello World!" text with red color in Times New Roman font. [input] |

[output] | public class ArmstrongNumbers { public static void main(String[] args) { int min = 100; int max = 500; for (int number = min; number <= max; number++) { int digits = 0; int result = 0; int originalNumber = number; wh [instruction] | Write a Java program to print all the Armstrong numbers between 100 to 500. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the total number of digits. [input] |

[output] | <!DOCTYPE html> <html> <head> <title>Current Date and Time</title> <style> p { font-size: 3em; font-family: Arial, sans-serif; } </style> </head> <body> <p id="time"></p> <script> const today = new Date(); const time = `${t [instruction] | Create a web page using HTML and CSS to display the current date and time. [input] |

[output] | function addIntWithoutTypeConversion(a, b) { let sum = 0; let carryin = 0; let k = 0; let temp_a = a; let temp_b = b; while (k < 32) { let ak = a >> k & 1; let bk = b >> k & 1; let carryout = (ak & bk) | (ak & carryin) | (bk & carryin); sum |= (ak ^ bk ^ carryin) << k; [instruction] | Write a code to add two integers without any type conversion. [input] |

[output] | SELECT population, COUNT(*) as count FROM countries WHERE population > 10e6 GROUP BY population; [instruction] | Write a SQL query to group the records from a table named 'countries' by their population greater than 10 million. [input] |

[output] | #include <iostream> using namespace std; void printPattern(int n) { int i, j, num; num = 1; // Prints the upper half for (i = 0; i <= n; i++) { // Start with printing number 1 num = 1; // Print 2*i+1 stars for (j = 0; j < 2 * i + [instruction] | Create a C++ program to print a pattern's series of numbers. [input] |

[output] | SELECT COUNT(*) FROM books WHERE title LIKE '%the%'; [instruction] | Write a MySQL query to count the number of book titles in the 'books' table having the word 'the' in their title. [input] |

[output] | public class Main { public static void main(String[] args) { Thread thread1 = new Thread(new Runnable(){ public void run(){ //task 1 } }); Thread thread2 = new Thread(new Runnable(){ public void run(){ [instruction] | Write a Java code to create a thread and process the tasks in separate threads. [input] |

[output] | SELECT SUM(salary) FROM employees; [instruction] | Write a SQL query that returns the sum of the values in a 'salary' column in a table named 'employees'. [input] |

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