← 목록

Synth · CodeAlpaca일부

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

[output] | def count_words_longer_than_number(text, number): words = text.split() count = 0 for word in words: if len(word) > number: count += 1 return count count_words_longer_than_number(Sentence, Number) [instruction] | Write a function in Python that takes a sentence and a number as inputs, and returns the number of words in that sentence that are longer than the given number. [input] | Sentence = "Hello, this is a sentence"; Number = 3;

[output] | #include <iostream> double power(double base, int exponent) { double result = 1; for(int i = 0; i < exponent; i++) { result *= base; } return result; } int main() { double base; int exponent; base = 5.0; exponent = 2; std::cout << power(base, e [instruction] | Write a C++ program for calculating the power of a number. [input] | Base = 5; Exponent = 2;

[output] | def list_sort(list): for i in range(0, len(list)): min_index = i for j in range(i+1, len(list)): if list[min_index] > list[j]: min_index = j list[i], list[min_index] = list[min_index], list[i] return list list_sort(mylist [instruction] | Create a program in Python that takes a list of numbers as input and sorts it in ascending order. [input] | mylist = [3, 2, 5, 4, 1]

[output] | even_list = [] for num in mylist: if num % 2 == 0: even_list.append(num) print(even_list) [instruction] | Read the given list and filter out the odd numbers. [input] | mylist = [1,2,3,4,5]

[output] | var celsius = 20; var fahrenheit = (celsius * (9/5)) + 32; console.log(fahrenheit); [instruction] | Write a script in JavaScript for converting temperature from Celsius to Fahrenheit. [input] | Celsius = 20

[output] | length_list = [] for string in mylist: length_list.append(len(string)) print(length_list) [instruction] | Create a program in Python that will take a list of strings and output a list containing the lengths of each string. [input] | mylist = ["Hello", "World", "WDI", "Class"]

[output] | filteredlist = [] for num in mylist: if '3' not in str(num): filteredlist.append(num) print(filteredlist) [instruction] | Read the given list and filter out the elements containing the number '3'. [input] | mylist = [13, 23, 32, 31, 14]

[output] | const person = { name: 'John Doe', age: 20, address: 'New York, USA' } [instruction] | Create a JavaScript object to store the data of a person. [input] | name: John Doe, age: 20, address: New York, USA

[output] | SELECT name, salary FROM employees; [instruction] | Write a SQL query to select employee names together with their salary. [input] |

[output] | function validPhoneNumber(phoneNumber) { let phoneRegex = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/; let validPhone = phoneRegex.test(phoneNumber); return validPhone; } validPhoneNumber("412-678-9012") # true [instruction] | Write a JavaScript program to validate whether a given phone number is valid. [input] | phone number: 412-678-9012

[output] | <!DOCTYPE html> <html> <head> <title>JavaScript Greeting Message</title> </head> <body> <h1>Welcome!</h1> <script type="text/javascript"> document.write("Welcome!"); </script> </body> </html> [instruction] | Create an HTML page to display the output of a JavaScript greeting message. [input] | message: Welcome!

[output] | from pymongo import MongoClient #creating the MongoClient client = MongoClient("mongodb://localhost:27017/") #connecting to the database db = client["database_name"] [instruction] | Enter the necessary code to initiate a MongoDB connection [input] |

[output] | class Example: def __init__(self, variable): self.variable = variable def method(self): return self.variable + 1 [instruction] | Create a class definition in python with one variable and one method [input] |

[output] | try: x = int(input("Please enter a number: ")) except ValueError: print("Input must be an integer!") [instruction] | Insert a try and except block in the following code [input] | x = int(input("Please enter a number: "))

[output] | def create_array(n): # create an empty list mylist=[] # add elements to the list by looping n times for i in range(0, n + 1): mylist.append(i) # return the list return mylist [instruction] | Define a python function that returns an array of the numbers from 0 to n [input] |

[output] | public class Person { private int age; private String name; private String hobby; //constructors public Person(int age, String name, String hobby) { this.age = age; this.name = name; this.hobby = hobby; } //getters public int getAge() { return age; } [instruction] | Write a class definition in Java to create a Person object with the properties age, name, and hobby. [input] |

[output] | SELECT Name, Phone FROM People WHERE Age > 30 [instruction] | Write a MySQL query to select the names and phone numbers of people whose age is greater than 30 [input] |

[output] | x = 1 print(x) [instruction] | Change the comment to a print statement in the code. [input] | x = 1 # print the value of x

[output] | def count_target(lst, target): count = 0 for i in lst: if i == target: count += 1 return count print(count_target(list, target)) [instruction] | Write a function in Python that takes two parameters, a list of integers and a target integer. The function should return the number of times the target integer appears in the list. [input] | list = [12, 4, 1, 18, 7, 15, 6, 11, 4] target = 4

[output] | def array_string(arr) arr.sort.join(', ') end puts array_string(['cat', 'dog', 'bird', 'bat']) [instruction] | Write a Ruby method that takes an array of strings as a parameter, and returns a string with the elements of the array sorted and separated by commas. [input] | ['cat', 'dog', 'bird', 'bat']

[output] | public class PriorityQueue { private int size; private int[] data; public PriorityQueue(int capacity) { this.size = 0; this.data = new int[capacity]; } public void add(int item) { if (this.size == this.data.length) { throw new IllegalStateException("The queue is full!" [instruction] | Write a Java class to implement a priority queue data structure. [input] |

[output] | def reverse_string(str): return str[::-1] print(reverse_string('hello')) [instruction] | Write a Python script that takes a string as input and outputs a string with the same characters in reverse order. [input] | hello

[output] | a { color: blue; } [instruction] | Write a CSS selector to select all the links in a web page. [input] |

[output] | <?php function reverse_array($arr) { $reversed_arr = array_reverse($arr); return $reversed_arr; } $input_arr = [1, 2, 3, 4, 5]; $output_arr = reverse_array($input_arr); print_r($output_arr); [instruction] | Write a PHP program to receive an array as an input and return an array with the same elements in reverse order. [input] | [1, 2, 3, 4, 5]

[output] | #include <iostream> using namespace std; struct Node{ int data; Node *next; }; Node *head = NULL; void createList(int n) { Node *newNode, *temp; int data, i; head = new Node; if(head == NULL) { cout<<"Memory allocation failed\n"; } else { [instruction] | Write a C++ program to create a linked list of length 5. [input] |

[output] | #import <Foundation/Foundation.h> @interface Person : NSObject @property NSString *name; @property NSUInteger age; @property CGFloat height; - (instancetype)initWithName:(NSString *)name age:(NSUInteger)age height:(CGFloat)height; @end #import "Person.h" @implementation Person - (instancetype [instruction] | Write an Objective-C class to represent a person containing attributes like name, age, and height. [input] |

[output] | [ { "name": "John Doe", "score": 100 }, { "name": "Jane Doe", "score": 70 }, { "name": "Bob Smith", "score": 50 } ] [instruction] | Write a JSON document to store the name and score of players in a game. [input] |

[output] | Deadlock is a state in which two or more processes wait for each other to finish, but none of the processes can finish because each is waiting for the other. To prevent deadlock, one can employ the use of a deadlock avoidance algorithm which typically checks for whether a particular set of condition [instruction] | What is deadlock and how to prevent it? [input] |

[output] | x = 3, y = 2, z = 3 [instruction] | Update the values of the variables x, y and z using the given expression. [input] | x=1, y=2, z=3, expression: x+2*y-z

[output] | The maximum possible value that can be stored in a single byte is 255. [instruction] | What is the maximum possible value that can be stored in a single byte? [input] |

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