← 목록

Synth · CodeAlpaca일부

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

[output] | import React from 'react'; const ListItems = props => { const items = props.listItems.map(item => ( <li key={item}>{item}</li> )); return ( <ul> {items} </ul> ); }; export default ListItems; [instruction] | Write a React component to display a list of items in an unordered list. [input] | const listItems = ["Apples", "Bananas", "Cherries"

[output] | [Logic Circuit for Three Input AND Gate] [instruction] | Construct a logic circuit that implements a three input AND gate. [input] |

[output] | #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { vector<int> arr = {4, 2, 5, 1, 3}; sort(arr.begin(), arr.end()); for(int i : arr) cout << i << " "; return 0; } [instruction] | Sort a numerical array from smallest to largest in C++. [input] | [4, 2, 5, 1, 3]

[output] | import pygame # Initialize the game engine pygame.init() # Define the colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) # Set the window size size = (400, 500) screen = pygame.display.set_mode(size) # Iterate over the list of rectangles rects = [pygame.Rect(75, 150, 150, 50), [instruction] | Write a script in Python for drawing a rectangle on the screen. [input] |

[output] | for char in "Hello world": print(char) [instruction] | Construct a for loop to print out each character of a given string in a new line. [input] | String: Hello world

[output] | def count_unique_elements(lst): unique_elements = set(lst) return len(unique_elements) print (count_unique_elements([1,2,3,2,3,4,5])) # Output: 5 [instruction] | Write a code to get the number of unique elements in a given list. [input] |

[output] | # secret number secret_number = 42 # user guess guess = 0 # guessing loop while guess != secret_number: # ask user to enter a guess guess = int(input("Guess a number between 1 and 100: ")) # provide hints if guess < secret_number: print("Too low. Try something higher. [instruction] | Create a program to guess a secret number between 1 and 100. [input] |

[output] | def area(radius): return 3.14 * radius * radius print(area(5)) # Output: 78.5 [instruction] | Construct a code that finds the area of a given circle. [input] |

[output] | lst = [1, 8, 9, 10, 6] even_nums = [] for num in lst: if num % 2 == 0: even_nums.append(num) if even_nums: print(max(even_nums)) else: print("No even numbers in the list.") # Output: 10 [instruction] | Edit the given code to print out the largest even number in the given list. [input] | lst = [1, 8, 9, 10, 6]

[output] | # dictionary to convert numbers to words number_words = {0 : 'zero', 1: 'one', 2 : 'two', 3 : 'three', 4 : 'four', 5 : 'five', 6 : 'six', 7 : 'seven', 8 : 'eight', 9 : 'nine', 10 : 'ten'} # convert number to string def convert_to_words(n): if n [instruction] | Generate a code to convert a given number to its English word equivalent. [input] |

[output] | # initialise sum sum = 0 # loop over given range for i in range(1, 6): sum += i print(sum) # Output: 15 [instruction] | Provide an input to the following code so that it prints out the sum of all numbers between 1 and 5. [input] |

[output] | def fahrenheit_to_celsius(f): return (f - 32) * 5 / 9 [instruction] | Write a Python function to convert temperatures from Fahrenheit to Celsius. [input] |

[output] | student = { 'name': '', 'age': 0, 'grades': [], 'graduation_year': 0 } [instruction] | Create a Python dictionary to store information about a student. The student should have the following attributes: name, age, grades, and graduation year. [input] |

[output] | def add_item(items, item): items.append(item) return items [instruction] | Write a Python function to add an item to a given list. [input] |

[output] | def compute_total_after_taxes(items): tax = 0.07 total = 0 for item in items: price = item[1] tax_amount = price * tax total += price + tax_amount return round(total, 2) [instruction] | Write a Python function to compute the total amount of a given grocery bill after taxes. [input] | items = [('apple', 1.49), ('banana', 0.99), ('bread', 4.99)]

[output] | def create_dict(keys, values): return dict(zip(keys, values)) [instruction] | Write a Python function to create a dictionary from two given lists. The first list should be the keys and the second list should be the values. [input] |

[output] | def sum_squares(n): total = 0 for x in range(1,n+1): total += x * x return total [instruction] | Create a function in Python to calculate the sum of the square of all numbers from 1 to n. [input] |

[output] | int getFrequency(int arr[], int n, int subarr[], int m) { int count = 0; for (int i = 0; i <= (n - m); i++) { int j; for (j = 0; j < m; j++) { if (arr[i + j] != subarr[j]) break; } if (j == m) count++; } ret [instruction] | Design a C++ program to get the frequency of a subarray in an array. [input] | arr = [1,2,2,2,2,2,3,4,5], subarr = [2,2]

[output] | # include<stdio.h> int main() { int year; printf("Enter a year: "); scanf("%d",&year); if (year%400 == 0) printf("%d is a leap year", year); else if (year%100 == 0) printf("%d is not a leap year", year); else if (year%4 == 0) printf("%d is a leap [instruction] | Design a C program to check if a year is leap year or not. [input] |

[output] | object = {"name": "John Doe", "age": 18, "isActive": False} [instruction] | Construct an object with 3 properties of different data types. [input] |

[output] | def delete_empty_values(d): new_dict = {key: value for key, value in d.items() if value != 0 and value != False and value != None and value != ''} return new_dict my_dict = delete_empty_values(my_dict) print(my_dict) # Output -> {'b': False} [instruction] | Write a code to delete all empty values in a given dictionary. [input] | my_dict = {'a': '', 'b': False, 'c': 0, 'd': None}

[output] | public static int compare(String s1, String s2) { return s1.compareTo(s2); } [instruction] | Compare two strings using Java [input] |

[output] | <html> <head> <title>List of Books</title> </head> <body> <h1>List of Books</h1> <ul> <li>The Alchemist</li> <li>Life of Pi</li> <li>The Great Gatsby</li> <li>The Catcher in the Rye</li> <li>Harry Potter and the Sorcerer's Stone</li> </ul> </body [instruction] | Write a web page in HTML to view a list of books [input] |

[output] | model = tf.keras.Sequential([ tf.keras.layers.Embedding(input_dim=vocabulary_size, output_dim=embedding_dim), tf.keras.layers.GlobalAveragePooling1D(), tf.keras.layers.Dense(24, activation='relu'), tf.keras.layers.Dense(1, activation='sigmoid') ]) model.compile(loss='binary_crossentr [instruction] | Design a neural network architecture in TensorFlow to predict the sentiment of a movie review [input] |

[output] | The machine learning algorithm used to find patterns in data is called clustering. [instruction] | What is the name of the machine learning algorithm used to find patterns in data? [input] |

[output] | std::string s = "It's raining today"; [instruction] | Convert the following code written in Java to C++. [input] | String s = "It's raining today";

[output] | \bhello\b.*\bworld\b [instruction] | Write a Regex expression to match a string containing the words "hello" and "world". [input] |

[output] | You can delete a row in an SQL database using the DELETE statement. The syntax for this statement is DELETE FROM table_name WHERE condition; [instruction] | How can you delete a row in an SQL database? [input] |

[output] | SELECT name, age FROM people; [instruction] | Modify the following SQL query to also return the age of the people. [input] | SELECT name FROM people;

[output] | The three patterns identified in the list of numbers are: an increasing sequence (1, 4, 6, 10, 15), odd numbers (1, 3, 5, 10, 15), and composite numbers (4, 6, 10, 15). [instruction] | Identify three patterns in the following list of numbers: 1, 4, 6, 10, the 15. [input] |

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