← 목록

Synth · CodeAlpaca일부

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

[output] | def get_title(url): url_parsed = urlparse(url) query_parsed = parse_qs(url_parsed.query) title = query_parsed['q'][0] return title print(get_title(url)) # Output: GPT 3 [instruction] | Write Python code to extract the title from a URL. [input] | url = "https://www.google.com/search?q=gpt-3&oq=GPT+3"

[output] | bool containsPunctuation(string s) { for (char c : s) { if (ispunct(c)) return true; } return false; } [instruction] | Create a function in C to check whether a given string contains any punctuations or not. [input] |

[output] | We can use a Set collection to remove duplicate characters from a string in Java. We can loop through the characters in the string, and add them to a Set, which does not allow duplicate elements. Then we can loop through the set and append each character to a new string. This new string will be free [instruction] | How can you remove duplicate characters from a string in Java? [input] |

[output] | public static int factorial(int n) { int factorial = 1; for (int i = 1; i <= n; i++) { factorial *= i; } return factorial; } [instruction] | Create a Java method that computes the factorial of an integer. [input] |

[output] | We can use the reversed() function to iterate a list in reverse order in Python. For example: my_list = [1, 2, 3, 4] for element in reversed(my_list): print(element) [instruction] | In Python, how can you iterate a list in reverse order? [input] |

[output] | We can create a dictionary in Python with 3 key-value pairs by declaring a dictionary variable with the desired contents. For example: my_dict = { "key1": "value1", "key2": "value2", "key3": "value3" } [instruction] | How can you create a dictionary in Python with 3 key-value pairs? [input] |

[output] | for element in reversed(my_list): print(element) [instruction] | Given a list, write a Python code snippet to print the elements of the list in reverse order. [input] | my_list = ["one", "two", "three", "four", "five"]

[output] | c = 8 [instruction] | Run the given code and determine the result. [input] | a = 3 b = 5 c = a + b

[output] | "!dlroW olleH" [instruction] | Using Python, reverse a given string "Hello World!". [input] |

[output] | .special { background-color: #eee; border: 2px solid #999; padding: 10px; display: block; } [instruction] | Make the following CSS code work properly on the web page. [input] | .special { background-color: #eee; border: 2px solid #999; }

[output] | model = Model() model.fit(x=[A, B, C, D], y=[0, 1, 0, 1]) [instruction] | Train a machine learning model without using any frameworks with the folowing input and output data. [input] | Input Data: A, B, C, D Output Data: 0, 1, 0, 1

[output] | <form> <label for="name">Name</label> <input type="text" name="name"> <label for="email">Email</label> <input type="email" name="email"> <label for="country">Country</label> <select name="country"> <option>---------</option> <!-- To be populated dynamically [instruction] | Create a functional HTML form using the following attributes. [input] | name, email, country

[output] | const MyButton = props => { return ( <button onClick={props.onClick} id={props.id}> Click Me </button> ) } [instruction] | Create a React component for a button that takes two props: an onClick event handler and an id. [input] |

[output] | public class Addition { public static int add(int x, int y) { return x + y; } public static void main(String[] args) { System.out.println(add(5,7)); } } [instruction] | Create a class in Java that will print the two integers added together. [input] |

[output] | #!/bin/bash if [ $1 -eq $2 ]; then echo "Arguments are equal" else echo "Arguments are not equal" fi [instruction] | Develop a bash script that will take 2 arguments as input and print "Arguments are equal" if both arguments are equal or "Arguments are not equal" otherwise. [input] |

[output] | public class Student { //private variables private String name; private int age; private int grade; //create getters and setters for the fields public String getName() { return name; } public void setName(String name) { this.name = name; } [instruction] | What changes can you suggest in order to optimize the following Java code? [input] | public class Student { //private variables private String name; private int age; private int grade;

[output] | def findArea(length, width): area = length * width return area # Call the function area = findArea(20, 15) print("The area of the room is: " + str(area) + "sq.ft") [instruction] | Create a function in Python that can compute the area of a rectangular room in square feet. [input] | length = 20 width = 15

[output] | #Create a class to store customer information class ContactData: def __init__(self, name, email, phone): self.name = name self.email = email self.phone = phone #Create a dictionary to store the customer contact details customer_details = {} # function to add customer de [instruction] | Design a data structure in Python to store customer contact details. [input] |

[output] | nums = [1, 2, 3] for n in nums: print(n) #Print the sum of the list print(sum(nums)) [instruction] | Suggest the missing line of code in the following Python program. [input] | nums = [1, 2, 3] for n in nums: print(n)

[output] | def merge(head1, head2): # If either is empty if not head1 or not head2: return head1 or head2 # if first linked list is smaller if head1.data < head2.data: head1.next = merge(head1.next, head2) return head1 else: # if second linked list is smaller or equ [instruction] | Merge the following two linked lists. [input] | Linked List 1: 1->3->5 Linked List 2: 2->4

[output] | SELECT s.name, m.marks FROM Student s, Marks m WHERE s.id = m.sub_id [instruction] | Write an SQL query that returns all the students with their marks from the following table. [input] | Student ( id, name, marks) Marks (sub_id, marks)

[output] | #!/bin/bash echo "Enter an integer" read num if (( num > 0 )); then echo "The number is positive" elif (( num < 0 )); then echo "The number is negative" else echo "The number is zero" fi [instruction] | Complete the following bash script with conditional statements. [input] | #!/bin/bash echo " Enter an integer " read num

[output] | <!DOCTYPE html> <html> <head> <title>Weather Tracker</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>Current Weather</h1> <div class="data-table"></div> <script> $(function() { $.get('https:/ [instruction] | Develop a web page that displays the current temperature in various cities. [input] |

[output] | CREATE TABLE `employee` ( `employee_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` varchar(255) NOT NULL, `dob` datetime NOT NULL, `salary` decimal(10,2) NOT NULL, `address` varchar(255) ); [instruction] | Design a MySQL Table to store company employees. [input] |

[output] | The expression 5 + 4 * 3 - 7 is a mathematical expression of arithmetic operations. [instruction] | Classify the type of the expression 5 + 4 * 3 - 7 [input] |

[output] | def get_permutations(input_list): result = [] if len(input_list) == 0: return [] if len(input_list) == 1: return [input_list] for i in range(len(input_list)): x = input_list[i] xs = input_list[:i] + input_list[i+1:] for p in get_permut [instruction] | Write a code that takes a list as input and returns a list of every permutation of that list [input] | [1, 2, 3]

[output] | def count_character(input_string, character): count = 0 for char in input_string: if char == character: count +=1 return count [instruction] | Write a code that takes a string and a character as an argument and counts the number of occurrences of that character in the string [input] | Avengers: "He brought the team together" Character: t

[output] | def add_two(input_list): new_list = [] for num in input_list: new_list.append(num + 2) return new_list [instruction] | Create a code that edits a list by adding two to each element [input] | [1, 2, 3]

[output] | def factorial(n): result = 1 for i in range(1,n+1): result *= i return result [instruction] | Write a code that takes a numeric value and returns the factorial of that number [input] | 3

[output] | def reverse_list(input_list): reversed_list = [] for i in range(len(input_list)-1,-1,-1): reversed_list.append(input_list[i]) return reversed_list [instruction] | Write a code that takes a list as an input and returns the elements in reverse order [input] | ['apple', 'banana', 'cherry']

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