conversations listlengths 2 2 |
|---|
[
{
"from": "human",
"value": "Create a function to calculate the sum of a sequence of integers. Input: [1, 2, 3, 4, 5]"
},
{
"from": "gpt",
"value": "# Python code\ndef sum_sequence(sequence):\n sum = 0\n for num in sequence:\n sum += num\n return sum"
}
] |
[
{
"from": "human",
"value": "Develop a function that will add two strings Input: str1 = \"Hello \"\nstr2 = \"world\""
},
{
"from": "gpt",
"value": "def add_strings(str1, str2):\n \"\"\"This function takes two strings and returns the sum of them.\"\"\"\n return str1 + str2\n\nstr1 = \"Hello... |
[
{
"from": "human",
"value": "Design a data structure in C++ to store information of a grocery store inventory. Input: "
},
{
"from": "gpt",
"value": "#include <map>\n#include <string>\n\nclass GroceryStoreInventory {\nprivate:\n std::map<std::string, int> items;\npublic:\n void addItems(st... |
[
{
"from": "human",
"value": "Implement a sorting algorithm to sort a given array. Input: [3, 1, 4, 5, 9, 0]"
},
{
"from": "gpt",
"value": "def bubble_sort(arr):\n n = len(arr)\n \n # Traverse through all array elements\n for i in range(n):\n \n # Last i elements are already in pl... |
[
{
"from": "human",
"value": "Design a Swift application for tracking expenses. The app should have a view for creating new expenses, and a view for displaying all expenses in a table view. Input: Not applicable"
},
{
"from": "gpt",
"value": "import UIKit\n\nclass ExpenseViewController: UIViewCon... |
[
{
"from": "human",
"value": "Create a REST API to convert a UNIX timestamp to human readable date. Input: Not Applicable"
},
{
"from": "gpt",
"value": "<?php\n$timestamp = $_GET['timestamp'];\n\nif(empty($timestamp)) {\n echo json_encode([\"error\" => \"Please provide a valid UNIX timestamp.\"])... |
[
{
"from": "human",
"value": "Generate a Python code for crawling a website for a specific type of data. Input: website: www.example.com \ndata to crawl: phone numbers"
},
{
"from": "gpt",
"value": "import requests\nimport re\n\ndef crawl_website_for_phone_numbers(website):\n response = reques... |
[
{
"from": "human",
"value": "Create a Python list comprehension to get the squared values of a list [1, 2, 3, 5, 8, 13]. Input: "
},
{
"from": "gpt",
"value": "[x*x for x in [1, 2, 3, 5, 8, 13]]"
}
] |
[
{
"from": "human",
"value": "Create a MySQL query to find the most expensive product from the table \"products\". Input: "
},
{
"from": "gpt",
"value": "SELECT * FROM products ORDER BY price DESC LIMIT 1;"
}
] |
[
{
"from": "human",
"value": "Create a data structure in Java for storing and managing books in a library. The data structure should include methods for adding a new book, checking if a particular book is available, and borrowing a book from the library. Input: Not applicable"
},
{
"from": "gpt",
... |
[
{
"from": "human",
"value": "Design a neural network model to classify emails into spam and non-spam. Input: "
},
{
"from": "gpt",
"value": "import tensorflow as tf\nfrom tensorflow.keras.layers import Dense, Input\n\n# Preparing data\nX_train, y_train, X_test, y_test = get_data() # Returns trai... |
[
{
"from": "human",
"value": "Generate a random string of 8 characters that contains at least one number. Input: Not applicable"
},
{
"from": "gpt",
"value": "function generateRandomString() {\n const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';\n let str = '';\n for ... |
[
{
"from": "human",
"value": "Create a Java application for sending SMS messages. This application should include a class for configuring the SMS provider. Input: Not applicable"
},
{
"from": "gpt",
"value": "import org.smslib.Library;\nimport org.smslib.http.SMSHttpProvider;\nimport org.smslib.s... |
[
{
"from": "human",
"value": "Create a Java program that generates a list of prime numbers from 2 to a given input. Input: 10"
},
{
"from": "gpt",
"value": "class PrimeNumber {\n public static void main(String a[]) {\n int n = 10;\n int i;\n int j;\n System.out.print(\"Prime numbers between 1 and... |
[
{
"from": "human",
"value": "Create a JavaScript object containing key-value pairs for each item in the following list: Input: Apple, Orange, Carrot"
},
{
"from": "gpt",
"value": "const object = {\n \"Apple\": \"\",\n \"Orange\": \"\",\n \"Carrot\": \"\"\n};"
}
] |
[
{
"from": "human",
"value": "Generate a python script to perform this action. Input: Given a string, remove all the consecutive duplicates from the string.\n\nInput: \"AAABBCCCD\""
},
{
"from": "gpt",
"value": "def remove_duplicates(string): \n result = \"\" \n prev = '' \n\n for char i... |
[
{
"from": "human",
"value": "Edit the following Java code to create a method that calculates the sum of an array of integers. Input: public class Sum {\n public static void main(String[] args) {\n int[] numbers = {1, 2, 3, 4, 5};\n System.out.println(\"The sum is: \" + getSum(numbers));\n ... |
[
{
"from": "human",
"value": "Design a Haskell solution for finding the area of a rectangle. Input: "
},
{
"from": "gpt",
"value": "rectArea :: Num a => a -> a -> a\nrectArea l w = l * w"
}
] |
[
{
"from": "human",
"value": "Create a React application to input two numbers and subtract them, displaying the result. Input: Not applicable"
},
{
"from": "gpt",
"value": "import React, { useState } from \"react\";\n\nconst App = () => {\n const [input1, setInput1] = useState(0);\n const [inpu... |
[
{
"from": "human",
"value": "Write a python script to generates random numbers between 0 and 9 that are divisible by 3. Input: "
},
{
"from": "gpt",
"value": "def generate_random_divisible_number():\n import random\n while True:\n # Generate a random number\n process = random... |
[
{
"from": "human",
"value": "Generate a 3x2 matrix filled with random numbers. Input: "
},
{
"from": "gpt",
"value": "import numpy as np\n\nmatrix = np.random.randint(1, 10, (3, 2))\nprint(matrix)"
}
] |
[
{
"from": "human",
"value": "Create a program which subtracts two numbers and prints the result. Input: 110, 15"
},
{
"from": "gpt",
"value": "def subtract(a,b):\n return a-b\n\nprint(subtract(110, 15)) # Output: 95"
}
] |
[
{
"from": "human",
"value": "Create a Django web application that displays a table of stocks with the following columns - name, current stock price, change and percentage change. Input: NYSE:AAPL, 428.31, -1.51, -0.35\nNYSE:MSFT, 217.31, 2.24, 1.04\nNYSE:AMZN, 3282.19, 5.78, 0.18\nNYSE:FB, 262.83, 4.68, 1.8... |
[
{
"from": "human",
"value": "Generate a class in C# that can be used to represent users in a database. Input: "
},
{
"from": "gpt",
"value": "public class User\n{\n\tpublic int Id { get; set; }\n\tpublic string Name { get; set; }\n\tpublic string EmailAddress { get; set; }\n\n\tpublic User(int i... |
[
{
"from": "human",
"value": "Create a Matlab program that computes the summation of an given list of numbers. Input: [3, 7, 23, 17]"
},
{
"from": "gpt",
"value": "A = [3, 7, 23, 17]; %Input list\nanswer = sum(A); % Calculation\nfprintf('Summation of the given list is %d', answer); % Output"
}
... |
[
{
"from": "human",
"value": "In the function below, write an algorithm to reverse a string. Input: def reverse_string(string):\n #TODO"
},
{
"from": "gpt",
"value": "def reverse_string(string):\n # Reverse the string\n if len(string) == 0: \n return string \n else: \n r... |
[
{
"from": "human",
"value": "Create a code snippet that will generate a random string with length n (n is an input to the program). Input: "
},
{
"from": "gpt",
"value": "import random\nimport string\n\ndef generateRandomString(n):\n letters = string.ascii_lowercase\n return ''.join(random... |
[
{
"from": "human",
"value": "Build a program to train a model to recognize handwritten digits using a convolutional neural network. Input: "
},
{
"from": "gpt",
"value": "import tensorflow as tf\nfrom tensorflow.keras.datasets import mnist\nfrom tensorflow.keras.models import Sequential\nfrom te... |
[
{
"from": "human",
"value": "Create a web page to visualize the tree structure provided as an input. Input: Tree structure:\n\n+---0\n +---1\n | +---3\n | +---4\n +---2\n +---5"
},
{
"from": "gpt",
"value": "<!DOCTYPE html>\n<html>\n <head>\n <title>Tree visualizati... |
[
{
"from": "human",
"value": "Rewrite the following code to remove two lines that are not necessary. Input: def find_max(nums, max_num=None):\n if len(nums) == 0:\n return None\n\n if max_num is None:\n max_num = nums[0]\n \n for num in nums:\n if num > max_num:\n ... |
[
{
"from": "human",
"value": "Design an object-oriented architecture for a game in C++. Input: Not applicable"
},
{
"from": "gpt",
"value": "#include <iostream>\n\n//Define the base class\nclass GameObject {\n public:\n // All game objects have a position\n double x, y, z;\n\n // ... |
[
{
"from": "human",
"value": "Create a function to remove all white spaces in a string. Input: string = “ Hello World ”"
},
{
"from": "gpt",
"value": "def remove_whitespace(string):\n return string.replace(\" \", \"\")"
}
] |
[
{
"from": "human",
"value": "Implement a recommendation engine in your mobile application which can offer customized suggestions based on user interaction. Input: Not applicable"
},
{
"from": "gpt",
"value": "// The main function to get recommendations\nfunction getRecommendations(userInput) {\n... |
[
{
"from": "human",
"value": "Write a C ++ program to optimize a given matrix with specific values. Input: "
},
{
"from": "gpt",
"value": "#include <iostream>\n#include <vector> \n\nusing namespace std;\n\nvoid optimizeMatrix (vector<vector<int>> &mat, int val) { \n // Iterate over the matrix\n ... |
[
{
"from": "human",
"value": "Create a bubble sort algorithm to sort an array of integers in ascending order. Input: [5,1,4,2,3]"
},
{
"from": "gpt",
"value": "def bubble_sort(arr):\n n = len(arr) \n\n # Loop through the array from the beginning to the end \n for i in range(n):\n ... |
[
{
"from": "human",
"value": "Develop a React component to render a list of user comments sorted by highest rating to lowest rating. Input: Not applicable"
},
{
"from": "gpt",
"value": "import React from 'react';\n\nconst CommentsList = ({ comments }) => {\n const sortedComments = comments.sort((... |
[
{
"from": "human",
"value": "To evaluate a user's birthdate, write a JavaScript function to calculate age given a date of birth. Input: date = 1982/3/21"
},
{
"from": "gpt",
"value": "function calculateAge(dateString) {\n let today = new Date();\n let birthDate = new Date(dateString);\n let age ... |
[
{
"from": "human",
"value": "Create a SQL query to select all records from a table ordered by date from oldest to newest. Input: Not applicable"
},
{
"from": "gpt",
"value": "SELECT * FROM table ORDER BY date ASC;"
}
] |
[
{
"from": "human",
"value": "Develop an Express application to manage Users. This application should have routes for creating a new User, getting a User, updating a User, and deleting a User. Input: Not applicable"
},
{
"from": "gpt",
"value": "// File: routes/users.js\n\nconst express = require... |
[
{
"from": "human",
"value": "Write a function in Java to split the array into two halves. Input: Array: {2, 4, 1, 6, 7, 8, 3, 5}"
},
{
"from": "gpt",
"value": "public static void splitArray(int arr[]) \n{ \n\tint mid = (arr.length + 1) / 2; \n\tint a[] = Arrays.copyOfRange(arr, 0, mid); \n\tint ... |
[
{
"from": "human",
"value": "Generate a valid JavaScript class constructor that takes in x and y coordinates. Input: Not applicable"
},
{
"from": "gpt",
"value": "class Point {\n constructor(x, y) {\n this.x = x;\n this.y = y;\n }\n}"
}
] |
[
{
"from": "human",
"value": "Write a Python code to get the third largest element in a given row. Input: [12, 13, 13, 45, 22, 99]"
},
{
"from": "gpt",
"value": "def third_largest(lst):\n if len(lst) < 3:\n return\n distinct = []\n for i in lst:\n if i not in distinct:\n ... |
[
{
"from": "human",
"value": "Given a list of tuples, write a program to find the tuple with the maximum sum. Input: tuples = [(1, 2), (5, 6), (7, 8), (4, 9)]"
},
{
"from": "gpt",
"value": "def max_sum_tuple(tuples):\n # Initialize the max_sum as 0\n max_sum = 0\n \n # Iterate through... |
[
{
"from": "human",
"value": "Create a Julia function to binarize an input array Input: "
},
{
"from": "gpt",
"value": "function binarize(arr)\n convertedArr = zeros(size(arr))\n for i in eachindex(arr)\n if arr[i] > 0\n convertedArr[i] = 1\n end\n end\n retur... |
[
{
"from": "human",
"value": "Generate a REST API with Python and Flask that allows users to create, read, update, and delete records from a database. Input: Not applicable"
},
{
"from": "gpt",
"value": "from flask import Flask, request\nfrom flask_sqlalchemy import SQLAlchemy\n\napp = Flask(name... |
[
{
"from": "human",
"value": "Generate an algorithm that checks for the validity of a sudoku puzzle solution Input: 3 4 6 8 2 9 7 5 1 \n7 8 9 6 5 1 4 3 2 \n5 2 1 4 7 3 6 9 8 \n6 3 7 9 4 8 5 2 1 \n2 9 4 5 1 6 3 8 7 \n8 1 5 3 6 7 9 4 2 \n9 6 8 1 3 5 2 7 4 \n1 7 3 2 8 4 9 6 5 \n4 5 2 7 9 6 1 0 8"
},
{
"... |
[
{
"from": "human",
"value": "Devise an algorithm in Java that takes a list of numbers as input and outputs the mean (average) of the numbers. Input: List of Numbers: [1, 3, 2, 5, 4]"
},
{
"from": "gpt",
"value": "public static double calculateMean(List<Integer> list) {\n\tdouble sum = 0;\n\tfor ... |
[
{
"from": "human",
"value": "Attempt to classify the following data points (1, 5) and (2, 8) using a linear classifier. Input: "
},
{
"from": "gpt",
"value": "We can use the following linear classifier:\ny = mx + c\n\nwith m = 3 and c = 0, our classifier would look like:\ny = 3x + 0\n\nFor the g... |
[
{
"from": "human",
"value": "Convert the following pseudocode into SQL query. Input: IF age is between 18 and 25 output \"Young Adult\"\nELSE IF age is between 26 and 30 output \"Adult\"\nELSE IF age is greater than 30 output \"Senior\""
},
{
"from": "gpt",
"value": "SELECT \n CASE\n WHEN ag... |
[
{
"from": "human",
"value": "Design a program to identify the elements present in a list which are binary values. Input: [1, 2, True, False, 0, 4]"
},
{
"from": "gpt",
"value": "def binary_elements(arr):\n result = []\n for val in arr:\n if val == True or val == False:\n ... |
[
{
"from": "human",
"value": "Create a Python function that takes in a string and a list of words and returns true if the string contains all the words in the list. Input: 'This is a test', ['test', 'this', 'is']"
},
{
"from": "gpt",
"value": "def contains_words(input_string, words):\n for word i... |
[
{
"from": "human",
"value": "Write a JavaScript program to move all zeros in an array to the end. Input: [0, 4, 0, 10, 0, 2, 14]"
},
{
"from": "gpt",
"value": "function moveZeros(arr){\n let notZero = [];\n let zeros = [];\n for(let item of arr){\n if(item === 0){\n zeros.push(item);\n } els... |
[
{
"from": "human",
"value": "Construct a regex pattern that can detect any strings that contain ampersand character as the first letter. Input: "
},
{
"from": "gpt",
"value": "regex_pattern = r\"^&.*\""
}
] |
[
{
"from": "human",
"value": "Create a Keras model with one input and one output that classifies text strings into two categories. Input: Two sets of text strings, one for each category"
},
{
"from": "gpt",
"value": "# Define the model\nmodel = Sequential()\nmodel.add(Input(shape=(None,))) #Input... |
[
{
"from": "human",
"value": "Write a function to compute the maximum thermometer reading given as a list of strings? Input: [\"100F\", \"45C\", \"30C\"]"
},
{
"from": "gpt",
"value": "def max_thermometer_reading(l):\n '''This function computes the maximum thermometer reading given as a list o... |
[
{
"from": "human",
"value": "Create a GraphQL query which returns the list of countries with their populations. Input: Not applicable"
},
{
"from": "gpt",
"value": "query {\n countries {\n name\n population\n }\n}"
}
] |
[
{
"from": "human",
"value": "Program a webhook to continuously monitor a specific resource for any changes and send an alert in the form of an email when a change is detected. Input: Not applicable"
},
{
"from": "gpt",
"value": "const axios = require('axios');\nconst cron = require('node-cron');... |
[
{
"from": "human",
"value": "Create a function which reverses a string in JavaScript. Input: "
},
{
"from": "gpt",
"value": "function reverseString(str) {\n let reversedStr = '';\n \n for(let i = str.length -1; i >= 0; i--) {\n reversedStr += str[i];\n }\n \n return reversedStr; \n... |
[
{
"from": "human",
"value": "Create a HTML page with an input form to capture the name of a user Input: "
},
{
"from": "gpt",
"value": "<html>\n <head>\n <title>Input Form</title>\n </head>\n <body>\n <form action=\"\" method=\"post\">\n <label for=\"name\">Name... |
[
{
"from": "human",
"value": "What should this Python program do? Input: def is_palindrome(s):\n '''Write your code here.'''"
},
{
"from": "gpt",
"value": "def is_palindrome(s):\n '''This function returns True if the string s is a palindrome and False if it isn't.''' \n return s == s[::-... |
[
{
"from": "human",
"value": "Use the Amazon Text-to-Speech API to generate speech from a given text. Input: "
},
{
"from": "gpt",
"value": "import boto3\n\nclient = boto3.client('polly')\n\ndef text_to_speech(text):\n response = client.synthesize_speech(\n OutputFormat='mp3',\n Text=tex... |
[
{
"from": "human",
"value": "Rewrite this Java program to extend it to do all permutations of a given array. Input: import java.util.Arrays;\n\npublic class Permutation {\n public static void main(String[] args) {\n int[] arr = {1, 2, 3};\n System.out.println(Arrays.toString(arr));\n }\n... |
[
{
"from": "human",
"value": "Use the Sklearn API to create a logistic regression model with maximum iterations of 80. Input: "
},
{
"from": "gpt",
"value": "from sklearn.linear_model import LogisticRegression\n\nmodel = LogisticRegression(max_iter=80)"
}
] |
[
{
"from": "human",
"value": "Output the maximum element in an array. Input: [1, 5, 10, 8, 15]"
},
{
"from": "gpt",
"value": "15"
}
] |
[
{
"from": "human",
"value": "Create a Vue.js component with a button that calls an action when clicked. Input: Not applicable"
},
{
"from": "gpt",
"value": "<template>\n <div>\n <button @click=\"handleClick\">Click me!</button>\n </div>\n</template>\n\n<script>\nexport default {\n name: 'MyComp... |
[
{
"from": "human",
"value": "Create a program that creates a class with variables and methods Input: A string variable called 'name' and a function called 'sayHello' which prints 'Hello {name}'."
},
{
"from": "gpt",
"value": "public class HelloClass {\n private String name;\n\n public Hell... |
[
{
"from": "human",
"value": "Design and create a data structure to efficiently store and retrieve student information. Input: "
},
{
"from": "gpt",
"value": "struct Student {\n int id;\n string name;\n string email;\n int age;\n int grade;\n string address;\n};\n\nunordered_map... |
[
{
"from": "human",
"value": "Design a function in Java to calculate the maximum of a given array. Input: [6, 1, 4, 9, -2]"
},
{
"from": "gpt",
"value": "public static int getMaxElement(int[] arr) { \n\tif (arr.length == 0) \n\t\treturn 0; \n \n\tint maxElement = arr[0]; \n \n\tfor (int i = 1; i... |
[
{
"from": "human",
"value": "Create a Python program to sort and print out the elements of an array of integers. Input: [17, 41, 5, 22, 54, 6, 29, 3, 13]"
},
{
"from": "gpt",
"value": "arr = [17, 41, 5, 22, 54, 6, 29, 3, 13]\n\narr.sort()\n\nprint(arr)\n\n# Output: [3, 5, 6, 13, 17, 22, 29, 41, ... |
[
{
"from": "human",
"value": "Create a program to simulate the movement of a particle in two dimensions. Input: "
},
{
"from": "gpt",
"value": "def simulate_particle(x0, y0, vx0, vy0, dt):\n \"\"\"Simulate the movement of a particle in two dimensions given initial x, y postions and the x, y ve... |
[
{
"from": "human",
"value": "Implement a deep learning model to classify intents in a utterance. Input: Utterance: I would like to book a flight"
},
{
"from": "gpt",
"value": "The model would take the utterance as input and be trained on a labeled dataset of intents and utterances. The outputs o... |
[
{
"from": "human",
"value": "Create an HTML page with a JavaScript function that calculates a user's Body Mass Index (BMI). Input: Not applicable"
},
{
"from": "gpt",
"value": "<!DOCTYPE html>\n<html>\n<head>\n <title>BMI Calculator</title>\n <script>\n function calculateBMI(){\n // ge... |
[
{
"from": "human",
"value": "Create a stored procedure in MySQL to insert new data into the table 'users'. Input: "
},
{
"from": "gpt",
"value": "CREATE PROCEDURE insert_user(IN first_name VARCHAR(255), IN last_name VARCHAR(255), IN email VARCHAR(255), IN user_level INT)\n BEGIN\n INSERT ... |
[
{
"from": "human",
"value": "Generate a Python program that adds two then doubles the result. Input: "
},
{
"from": "gpt",
"value": "def double_add(num1, num2): \n return (num1 + num2) * 2"
}
] |
[
{
"from": "human",
"value": "Edit the given C++ class so that the copy constructor is defined. Input: class MyClass {\npublic:\n\nprivate:\n};"
},
{
"from": "gpt",
"value": "class MyClass {\npublic:\n MyClass(const MyClass& other){};\n\nprivate:\n};"
}
] |
[
{
"from": "human",
"value": "Create a Java program that creates an SQL query to calculate the summation of values in a given column. Input: Table name: orders\nColumn name: payment_amount"
},
{
"from": "gpt",
"value": "String sql = \"SELECT SUM(payment_amount) FROM orders\"; \nStatement st = con... |
[
{
"from": "human",
"value": "Generate an optimized SQL query that select all rows in the table. Input: Table Name: Employees"
},
{
"from": "gpt",
"value": "SELECT * FROM Employees;"
}
] |
[
{
"from": "human",
"value": "Create a NumPy array called \"arr\" with 10 elements and compute the median. Input: "
},
{
"from": "gpt",
"value": "import numpy as np\n\narr = np.random.randint(0, 100, 10)\nmedian = np.median(arr)"
}
] |
[
{
"from": "human",
"value": "Generate a JavaScript script for parsing HTML tables. Input: [\n {\n \"id\": 1,\n \"name\": \"John Smith\",\n \"email\": \"john@example.com\"\n },\n {\n \"id\": 2,\n \"name\": \"Jane Doe\",\n \"email\": \"jane@example.com\"\n ... |
[
{
"from": "human",
"value": "Create a React component that displays given data points in a graphical format. Input: Data Points: [{x: 1, y: 10}, {x: 2, y: 20}, {x: 3, y: 30}]"
},
{
"from": "gpt",
"value": "import React, { Component } from 'react';\nimport { Line } from 'react-chartjs-2';\n\nclas... |
[
{
"from": "human",
"value": "Create a Vue.js application to display basic information about a user. Input: Not applicable"
},
{
"from": "gpt",
"value": "<template>\n <div>\n <h2>User Information</h2>\n <ul>\n <li>Name: {{user.name}}</li>\n <li>Email: {{user.email}}</li>\n <... |
[
{
"from": "human",
"value": "Create a Ethereum smart contract for a simple ToDo list application. This application should include methods to create, check off, and delete tasks with each task having a title and a status (open, checked off). Input: Not applicable"
},
{
"from": "gpt",
"value": "pr... |
[
{
"from": "human",
"value": "Create a simple node program that runs a timer. Input: "
},
{
"from": "gpt",
"value": "const Readline = require('readline');\n\nconst rl = Readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nrl.question('Enter time in seconds: ', (an... |
[
{
"from": "human",
"value": "Design a solution to track the employees working in a company Input: "
},
{
"from": "gpt",
"value": "\"\"\"\nDesign a solution to track the employees working in a company\n\"\"\"\nCreate a database table with fields to store employee information such as:\n-ID: unique... |
[
{
"from": "human",
"value": "Create an endpoint in an Express application that generates a PDF invoice for a given order. Input: Not applicable"
},
{
"from": "gpt",
"value": "const express = require('express');\nconst uuid = require('uuid');\nconst pdf = require('html-pdf');\n\nconst app = expre... |
[
{
"from": "human",
"value": "Write a python program to extract the non-vowel words in a sentence. Input: This machine learning project is challenging."
},
{
"from": "gpt",
"value": "def extract_words(sentence):\n non_vowel_words = []\n words = sentence.split()\n vowels = ['a','e','i','o... |
[
{
"from": "human",
"value": "Create a function to check for palindromes in a sentence. Input: Sentence: Was it a car or a cat I saw?"
},
{
"from": "gpt",
"value": "def is_palindrome(sentence):\n sentence = sentence.lower().replace(' ', '')\n if sentence == sentence[::-1]:\n return T... |
[
{
"from": "human",
"value": "Write a SQL query to find the highest price for each product type. Input: "
},
{
"from": "gpt",
"value": "SELECT\n type,\n MAX(price) AS 'highest_price'\nFROM products\nGROUP BY type;"
}
] |
[
{
"from": "human",
"value": "Create a program in C# that prints out multiplication tables of any given number up to 10. Input: Not applicable"
},
{
"from": "gpt",
"value": "class Program\n{\n static void Main(string[] args)\n {\n // Get the number from the user\n Console.Writ... |
[
{
"from": "human",
"value": "Create a function to print the elements of a linked list in a reverse order. Input: "
},
{
"from": "gpt",
"value": "function printReverseLinkedList(head) {\n if (head === null) return;\n\n printReverseLinkedList(head.next);\n\n console.log(head.data);\n}"
... |
[
{
"from": "human",
"value": "Create a program to convert from Roman numerals to decimal numbers. Input: "
},
{
"from": "gpt",
"value": "# Dictionary to store Roman to Decimal values \nroman_val = { 'I': 1, 'V': 5, 'X': 10, 'L': 50, \n 'C': 100, 'D': 500, 'M': 1000 } \n \n# Function ... |
[
{
"from": "human",
"value": "Write a Python program to calculate the average of a list of positive integers and output the result. Input: List of positive integers: [1, 5, 6, 7, 8]"
},
{
"from": "gpt",
"value": "list_of_positive_integers = [1, 5, 6, 7, 8]\ntotal = sum(list_of_positive_integers)\... |
[
{
"from": "human",
"value": "Generate a Tensorflow model for a sentiment analysis task. Input: Not applicable"
},
{
"from": "gpt",
"value": "# Imports\nimport tensorflow as tf\nfrom tensorflow import keras\nfrom tensorflow.keras import layers\n\n# Input data\ndata = tf.data.Dataset.from_tensor_s... |
[
{
"from": "human",
"value": "Create a JavaScript function to check if a string is a valid email address or not. Input: "
},
{
"from": "gpt",
"value": "function validateEmail(email) {\n var re = /^(([^<>()[\\]\\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[... |
[
{
"from": "human",
"value": "Create an AWS Lambda function that queries a database and returns the results of the query. Input: Database: PostgreSQL\nQuery: SELECT first_name, last_name FROM users;"
},
{
"from": "gpt",
"value": "import { connect } from \"pg\";\nimport { Handler } from \"aws-lamb... |
[
{
"from": "human",
"value": "Write a SQL statement to select the fields \"name\" and \"age\" from a table called `people`. Input: "
},
{
"from": "gpt",
"value": "SELECT name, age FROM people;"
}
] |
[
{
"from": "human",
"value": "Develop a Ruby program to generate five random numbers between 0 and 10 Input: Not applicable"
},
{
"from": "gpt",
"value": "def generate_random_numbers\n (0..10).to_a.sample(5)\nend\n \nputs generate_random_numbers"
}
] |
[
{
"from": "human",
"value": "Produce a class in Java to represent a student with fields like rollNumber, name and marks? Input: "
},
{
"from": "gpt",
"value": "class Student {\n private String name;\n private String rollNumber;\n private int marks;\n\n public Student(String name, Str... |
[
{
"from": "human",
"value": "Create a HTML document that displays a table with the employee data given below. Input: Employee Name | Salary\nJohn Doe | 50000 \nJane Doe | 45000 \nDr. Smith | 75000"
},
{
"from": "gpt",
"value": "<html>\n<body>\n <table>\n <tr>\n <th>Employee Name</th>\n ... |
[
{
"from": "human",
"value": "Develop a function in Python that prints out the Pascal's triangle for a given number of rows. Input: "
},
{
"from": "gpt",
"value": "def pascal_triangle(n): \n trow = [1] \n y = [0] \n for x in range(max(n, 0)): \n print(trow) \n trow=[l+r for... |
End of preview. Expand in Data Studio
No dataset card yet
- Downloads last month
- 3