← 목록

Synth · CodeAlpaca일부

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

[output] | public class Employee { public string Name; public int Age; public string Department; public int Salary; public Employee(string name, int age, string department, int salary) { Name = name; Age = age; Department = department; Salary = salar [instruction] | Design a class in C# to store employee details. [input] |

[output] | model = AIplatform.SentimentAnalysis() model.fit(X, y) prediction = model.predict(sentence) [instruction] | Using an AI platform, create a sentiment analysis model to predict a sentiment of a given sentence. [input] |

[output] | #!/bin/bash DIR="example" mkDIR -p "$DIR/subdir1/subdir2" [instruction] | Write a Bash script for creating a directory and its subdirectories. [input] |

[output] | User: Hi, I'm looking for a pizza Bot: Hi there! What kind of pizza are you looking for? User: I'd like a pepperoni pizza with extra cheese Bot: Sure, one pepperoni pizza with extra cheese coming right up! Anything else I can do for you? [instruction] | Create an example chatbot dialogue using the given context. [input] | Context: You're a pizza maker

[output] | # Imports import nltk # CKY Parsing def cky_parse(sentence): """Given a sentence, apply CKY parsing to optimize the parsing of it""" words = nltk.word_tokenize(sentence) # Create tree structure table = [[None for i in range(len(words))] for j in range(len(words))] for j in range(len [instruction] | Write a code to optimize the parsing of a given sentence using CKY parsing. [input] | Sentence: "The cat chased the dog around the corner of the house."

[output] | let x = canvas.width/2; let y = canvas.height/2; let radius = 20; let dx = 3; let dy = -3; function draw() { ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.beginPath(); ctx.arc(x, y, radius, 0, Math.PI*2); ctx.fillStyle = "#0095DD"; ctx.fill(); ctx.closePath(); if (x+radius > [instruction] | Create an animnation of a bouncing ball in the canvas using JavaScript. [input] |

[output] | import mysql.connector # Establish a connection with the database mydb = mysql.connector.connect( host="localhost", user="username", password="password", database="databaseName" ) # Create a new record mycursor = mydb.cursor() sql = "INSERT INTO tableName (col1, col2, col3) VALUES (%s, %s [instruction] | Implement a feature to add a record to a MySQL database table. [input] |

[output] | import matplotlib.pyplot as plt from wordcloud import WordCloud # Generate a word cloud image text = "Machine Learning is an area of computer science that gives computers the ability to learn without explicit programming." wordcloud = WordCloud().generate(text) # Show the generated image plt.imsho [instruction] | Create an example Word Cloud from the given text. [input] | Text: Machine Learning is an area of computer science that gives computers the ability to learn without explicit programming.

[output] | # Imports import nltk from nltk.tokenize import word_tokenize from nltk.tag import pos_tag # Tokenize the natural language query response = input("What would you like to search for? ") words = word_tokenize(response) tagged_words = pos_tag(words) # Process the query and search for relevant resu [instruction] | Create a search engine to process natural language queries. [input] |

[output] | def sort_array(numbers): # Bubble sort algorithm for i in range(len(numbers)): for j in range(0, len(numbers)-i-1): if numbers[j] > numbers[j+1]: numbers[j], numbers[j+1] = numbers[j+1], numbers[j] return numbers [instruction] | Write a code for sorting the given array of numbers in ascending order. [input] |

[output] | import nltk from nltk.tokenize import word_tokenize # Create a list of "spammy" words spammy_words = ['free', 'discount', 'offer', 'win', 'prize', 'billion', 'million', 'cash'] # Define a function for detecting spam def detect_spam(email): # Tokenize the email words = word_tokenize(email) [instruction] | Create a program to detect spam emails. [input] |

[output] | # Imports import requests from bs4 import BeautifulSoup # Define the URL url = "https://www.example.com/" # Get the HTML response = requests.get(url) html = response.content # Parse the HTML soup = BeautifulSoup(html,"html.parser") # Extract the title and description title = soup.find("title") [instruction] | Create a web scraper to extract the title and description of a given URL using BeautifulSoup. [input] | URL: https://www.example.com/

[output] | # Define the population size POPULATION_SIZE = 100 # Define the parameters for the genetic algorithm MUTATION_RATE = 0.2 CROSSOVER_RATE = 0.7 MAX_ITERATIONS = 10 # Create the initial population population = create_population(POPULATION_SIZE) # Run the genetic algorithm for iteration in range [instruction] | Design and implement a genetic algorithm for finding the optimal solution for a given problem. [input] |

[output] | # Imports from chatterbot import ChatBot from chatterbot.trainers import ChatterBotCorpusTrainer # Create the AI Chatbot bot = ChatBot("CovidBot") # Train the bot on the corpus trainer = ChatterBotCorpusTrainer(bot) trainer.train("chatterbot.corpus.english.covid19") # Start the chatbot whil [instruction] | Create an AI chatbot that can answer questions about the given topic "Covid-19". [input] | Topic: Covid-19

[output] | def find_max(arr): max = arr[0] for i in range(1, len(arr)): max = max if max > arr[i] else arr[i] return max [instruction] | Suggest a method to optimize the following code. [input] | def find_max(arr): max = arr[0] for i in range(1, len(arr)): if arr[i] > max: max = arr[i] return max

[output] | a = 10 b = 25 if a < b: print("b is greater than a") else: print("a is greater than b") [instruction] | Suggest a better way of writing the following code. [input] | a = 10 b = 25 if a > b: print("a is greater than b") else: print("b is greater than a")

[output] | def add_item(item, list): list.append(item) undo_list.append(item) ​ def undo_item(item, list): if len(list) > 0: last_item = list.pop() redo_list.append(last_item) def redo_item(item, list): if len(redo_list) > 0: last_item = redo_list.pop() list [instruction] | How would you extend the following code to add the features "undo" and "redo"? [input] | def add_item(item, list): list.append(item)

[output] | #!/bin/bash IP_ADDRESS="$1" if [[ $IP_ADDRESS =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then echo "Valid IP Address" else echo "Invalid IP Address" fi [instruction] | Create a bash script to detect if a given IP address is valid or not. [input] | 192.168.1.100

[output] | The given function takes a string as an argument, creates an empty string to store unique characters from the given string. It then iterates through the given string and checks if the character is already present in the new string. If the character is not present, it adds the character to the new st [instruction] | Explain the working of a function that takes a string as an argument, removes all the duplicate characters from it and returns the modified string [input] |

[output] | JSON (JavaScript Object Notation) data is structured in a hierarchical way. It consists of data stored in key-value pairs. The JSON object typically contains a set of key-value pairs, or nested objects. Data is organized and encoded in a way that makes it easier for programs to read and interpret th [instruction] | Describe the structure of JSON data [input] |

[output] | Imperative programming paradigm. [instruction] | Categorize a piece of code as an imperative or functional programming paradigm [input] | sum = 0; for (i = 0; i < n; i++) { sum += arr[i]; }

[output] | public class ConcatenateStrings { public static String concat(String s1, String s2) { StringBuilder sb = new StringBuilder(); sb.append(s1); sb.append(s2); return sb.toString(); } public static void main(String[] args) { String str1 = "Hello"; String str2 [instruction] | Develop a program to join two strings [input] | String1 = "Hello"; String2 = "World";

[output] | def TowerOfHanoi(n, from_rod, to_rod, aux_rod): if n == 1: print("Move disk 1 from rod",from_rod,"to rod",to_rod) return TowerOfHanoi(n-1, from_rod, aux_rod, to_rod) print("Move disk",n,"from rod",from_rod,"to rod",to_rod) TowerOfHanoi(n-1, aux_rod, to_rod, from_ro [instruction] | Generate a python program to solve the Tower of Hanoi problem with n discs [input] |

[output] | def remove_duplicates(arr): unique_arr = [] for item in arr: if item not in unique_arr: unique_arr.append(item) return unique_arr # Driver code arr = ['apple', 'apple', 'orange', 'kiwi', 'apple', 'banana', 'banana'] print (remove_duplicates(arr)) [instruction] | Given an array containing a string with duplicates, output an array with only unique strings. [input] | ['apple', 'apple', 'orange', 'kiwi', 'apple', 'banana', 'banana']

[output] | def split(string, delimiter): return string.split(delimiter) # Driver code string = "This-is-a-test" delimiter = "-" print (split(string, delimiter)) [instruction] | Develop a program to split a string by a specific delimiter [input] | String = "This-is-a-test" Delimiter = "-"

[output] | import pandas as pd data = [{"first_name":"John", "last_name":"Doe"}, {"first_name":"Jane", "last_name":"Smith"}, {"first_name":"Tom", "last_name":"Johnson"}, {"first_name":"Sandy", "last_name":"Robinson"}, {"first_name":"Roger", "last_name":"McDonald"}, {"fi [instruction] | Create a dataframe in pandas [input] | List of 7 employees, each with first name and last name.

[output] | def calculator(num1, num2): return num1 + num2 [instruction] | Design a basic calculator that returns the output of two number inputs [input] | Number inputs: 9, 12

[output] | import re def sanitize(string): string = re.sub(r'[^\w\s]','',string) return string string = sanitize(raw_input("Enter your text here: ")) [instruction] | Modify the given code to sanitize the user input. [input] | string = raw_input("Enter your text here: ")

[output] | for i in range(11): print(i) [instruction] | Write code to print out the numbers from 0 to 10 using a for loop [input] |

[output] | count = 0 for num in arr: if num == 2: count += 1 print(count) [instruction] | Find the number of times the element 2 appears in the following array [input] | arr = [2, 3, 5, 7, 2, 6, 2]

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