dataset
stringclasses
12 values
id
stringlengths
5
50
messages
listlengths
1
138
code_alpaca
code_alpaca_300
[ { "role": "user", "content": "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\nFind the smallest element in a given array.\n\n### Input:\n[6, 8, 1, 4, 5]\n\n### Response:" }, ...
code_alpaca
code_alpaca_301
[ { "role": "user", "content": "How would you determine if a given number is a prime number?\n\nAnswer:" }, { "role": "assistant", "content": "A prime number is a number that is only divisible by 1 and itself. To check if a given number is a prime number, first use a loop to check all the numbers ...
code_alpaca
code_alpaca_302
[ { "role": "user", "content": "Compare two integers and print the larger one.\n\nNow complete the following instance -\nInput: a = 3, b = 5\nOutput:" }, { "role": "assistant", "content": "if a > b:\n print(a)\nelse:\n print(b)" } ]
code_alpaca
code_alpaca_303
[ { "role": "user", "content": "Edit the program to print the given date in the format \"dd/mm/yyyy\".\n\nAdditional Context:\nyear = 2020\nmonth = 5\nday = 3\n\nAnswer:" }, { "role": "assistant", "content": "# Print date in dd/mm/yyyy format\nprint(\"{:02d}/{:02d}/{:04d}\".format(day, month, year...
code_alpaca
code_alpaca_304
[ { "role": "user", "content": "Create a function to reverse a string.\n\ns = \"hello world\"\n\n" }, { "role": "assistant", "content": "\"\"\"\nReverse string\n\"\"\"\n\ndef reverse_string(s):\n \"\"\"Reverse a given string.\n \n Args:\n s (str): The string to reverse.\n \n...
code_alpaca
code_alpaca_305
[ { "role": "user", "content": "Normalize a given array such that it adds up to 1.\n\n[3, 0, 9, 5]\n\n" }, { "role": "assistant", "content": "[0.15, 0.0, 0.45, 0.3]" } ]
code_alpaca
code_alpaca_306
[ { "role": "user", "content": "Find the longest common substring between two strings.\ns1 = \"Tangible\"\ns2 = \"Non-Tangible\"\n" }, { "role": "assistant", "content": "\"\"\"\nFind the longest common substring between two strings\n\"\"\"\n\ndef longest_common_substring(s1, s2):\n \"\"\"Find t...
code_alpaca
code_alpaca_307
[ { "role": "user", "content": "Instruction:Find the top 5 most common words in a given string.\n\nInput: s = \"Hello world, this is a sample string for the task\"\n\n" }, { "role": "assistant", "content": "\"\"\"\nFind the top 5 most common words in a given string\n\"\"\"\n\nfrom collections impo...
code_alpaca
code_alpaca_308
[ { "role": "user", "content": "You need to complete the following task:\n\nClassify a given sentence based on the intention behind it.\n\nsentence = \"I want to buy a car\"\n\nAnswer:" }, { "role": "assistant", "content": "The given sentence is a request intention." } ]
code_alpaca
code_alpaca_309
[ { "role": "user", "content": "Instruction:Use the list comprehension syntax to make a new list whose elements are the square of the first list.\n\nInput: lst = [1, 2, 3, 4]\n\n" }, { "role": "assistant", "content": "[x**2 for x in lst]" } ]
code_alpaca
code_alpaca_310
[ { "role": "user", "content": "Tell me how would you respond to the following request.\nWrite a Python function to calculate the factorial of a number (a non-negative integer).\n" }, { "role": "assistant", "content": "def factorial(num):\n \"\"\"\n Calculates factorial of a given number.\n ...
code_alpaca
code_alpaca_311
[ { "role": "user", "content": "Write a function that takes a string and returns a boolean based on whether the string is a palindrome or not.\n" }, { "role": "assistant", "content": "def is_palindrome(str):\n \"\"\"\n Checks if the given input string is a palindrome or not.\n \"\"\"\n ...
code_alpaca
code_alpaca_312
[ { "role": "user", "content": "Write a code to check whether a given year is a leap year or not\n" }, { "role": "assistant", "content": "def is_leap_year(year):\n \"\"\"\n Checks if the given year is a leap year or not.\n \"\"\"\n if ((year % 4 == 0) and (year % 100 != 0)) or (year % ...
code_alpaca
code_alpaca_313
[ { "role": "user", "content": "Create a program which will take the user's name and output a custom message depending on the supplied name\n\nname = 'John'\n\n" }, { "role": "assistant", "content": "def greet_user(name):\n \"\"\"\n Greet the user with a custom message depending on the suppl...
code_alpaca
code_alpaca_314
[ { "role": "user", "content": "You need to complete the following task:\n\nWrite code to find the smallest number in an array of numbers.\n\narr = [5, 8, 2, 4, 7, 10]\n\nAnswer:" }, { "role": "assistant", "content": "def find_smallest_number(arr):\n \"\"\"\n Finds the smallest number in an ...
code_alpaca
code_alpaca_315
[ { "role": "user", "content": "Instruction:Write a function to calculate the arithmetic mean of an array of numbers\n\nInput: arr = [5, 8, 2, 4, 7, 10]\n\n" }, { "role": "assistant", "content": "def calculate_mean(arr):\n \"\"\"\n Calculate the arithmetic mean of an array of numbers.\n \...
code_alpaca
code_alpaca_316
[ { "role": "user", "content": "Write code to implement Bubble Sort.\n\nInput: arr = [5, 8, 2, 4, 7, 10]\n\nOutput:" }, { "role": "assistant", "content": "def bubble_sort(arr):\n \"\"\"\n Implementation of the Bubble Sort algorithm.\n \"\"\"\n for i in range(len(arr)-1):\n for j...
code_alpaca
code_alpaca_317
[ { "role": "user", "content": "Task: Write code to find the longest substring of unique characters in a given string.\nInput: string = 'abcabcbb'\nOutput:" }, { "role": "assistant", "content": "def find_longest_substring(string):\n \"\"\"\n Finds the longest substring of unique characters i...
code_alpaca
code_alpaca_318
[ { "role": "user", "content": "Find the index of a given item in an array\n\narr = [1, 4, 6, 8, 9]\nitem = 8\n\n" }, { "role": "assistant", "content": "def find_index(arr, item):\n \"\"\"\n Finds the index of a given item in an array\n \"\"\"\n for i, num in enumerate(arr):\n i...
code_alpaca
code_alpaca_319
[ { "role": "user", "content": "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\nWrite code to find the most frequent item in an array\n\n### Input:\narr = [1, 4, 6, 8, 9, 1, 4, 6]...
code_alpaca
code_alpaca_320
[ { "role": "user", "content": "Instruction:Write code to concatenate two given strings.\n\nInput: str1 = 'hello'\nstr2 = 'world'\n\n" }, { "role": "assistant", "content": "def concatenate(str1, str2):\n \"\"\"\n Concatenates two given strings.\n \"\"\"\n return str1 + str2" } ]
code_alpaca
code_alpaca_321
[ { "role": "user", "content": "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\nCreate a program to display all prime numbers between a given range.\n\n### Input:\na, b = 2, 8\n\n...
code_alpaca
code_alpaca_322
[ { "role": "user", "content": "Plase answer the following request: Explain the concept of Big O notation in one sentence.\nAnswer:" }, { "role": "assistant", "content": "Big O notation is a way to measure the efficiency of algorithms and to compare them based on how their running time or space co...
code_alpaca
code_alpaca_323
[ { "role": "user", "content": "Instruction:Write a code to remove the oldest elements from a list until the list contains at most 10 elements.\n\nInput: list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n\n" }, { "role": "assistant", "content": "def remove_old_elements(lst):\n for i in range(len(ls...
code_alpaca
code_alpaca_324
[ { "role": "user", "content": "Explain the concept of object-oriented programming.\n\n" }, { "role": "assistant", "content": "Object-oriented programming (OOP) is a programming paradigm based on the concept of \"objects\", which can contain data and code: data in the form of fields and code in th...
code_alpaca
code_alpaca_325
[ { "role": "user", "content": "You need to complete the following task:\n\nWrite a Python function to check if a value exists in a list.\n\n" }, { "role": "assistant", "content": "def is_in_list(lst, val):\n return val in lst" } ]
code_alpaca
code_alpaca_326
[ { "role": "user", "content": "How do you declare a variable in Python?" }, { "role": "assistant", "content": "\nIn Python, you can declare a variable by assigning a value to it. For example, x = 1 is a variable declaration which creates a variable named x with the value of 1." } ]
code_alpaca
code_alpaca_327
[ { "role": "user", "content": "Write a response that appropriately completes the request.\n\n### Instruction:\nWrite a code to multiple two numbers without using the multiplication operator.\n\n### Response:" }, { "role": "assistant", "content": "def multiply(x,y):\n if(y == 0):\n return 0\n ...
code_alpaca
code_alpaca_328
[ { "role": "user", "content": "Given a string, create a function that takes out all the duplicated characters in the string.\n\nNow complete the following instance -\nInput: string = 'Keeep Learning'\nOutput:" }, { "role": "assistant", "content": "def remove_duplicates(s):\n seen = []\n res = \...
code_alpaca
code_alpaca_329
[ { "role": "user", "content": "Tell me how would you respond to the following request.\nWrite a Javascript code to check if the given number is a prime number.\n" }, { "role": "assistant", "content": "function isPrimeNumber(num) {\n for(var i = 2; i < num; i++){\n if(num % i === 0) {\n r...
code_alpaca
code_alpaca_330
[ { "role": "user", "content": "Plase answer the following request: What is the purpose of treemaps in data visualization?\nAnswer:" }, { "role": "assistant", "content": "Treemaps are used to represent hierarchical data visually. They are used to visualize large datasets by dividing them into rect...
code_alpaca
code_alpaca_331
[ { "role": "user", "content": "Write a SQL query to select the top 3 highest salaries in a employees table.\n" }, { "role": "assistant", "content": "SELECT TOP 3 salary FROM employees ORDER BY salary DESC;" } ]
code_alpaca
code_alpaca_332
[ { "role": "user", "content": "Can you help with this?\n\nWhat is data transformation and how is it used?\n" }, { "role": "assistant", "content": "Data transformation is the process of converting data from one format to another format. It is mainly used for cleaning and normalizing data before it...
code_alpaca
code_alpaca_333
[ { "role": "user", "content": "Create a JavaScript function that takes an array of numbers and returns the median value from the array.\n\n" }, { "role": "assistant", "content": "function getMedian(arr) {\n arr.sort(function (a, b) {\n return a - b;\n });\n \n let mid = Math.floor(arr.leng...
code_alpaca
code_alpaca_334
[ { "role": "user", "content": "Tell me how would you respond to the following request.\nWrite a C++ code to find the longest common substring in two strings.\n" }, { "role": "assistant", "content": "#include <string>\n#include <algorithm>\n\nusing namespace std;\n\nstring longestCommonSubstring(c...
code_alpaca
code_alpaca_335
[ { "role": "user", "content": "Tell me how would you respond to the following request.\nWrite an algorithm to perform binary search on a sorted array.\n" }, { "role": "assistant", "content": "def binarySearch(array, item):\n low = 0\n high = len(array) - 1\n\n while low <= high:\n mid = (lo...
code_alpaca
code_alpaca_336
[ { "role": "user", "content": "Given a string, write a Python program to find the first non-repeating character in it.\ninput_str = \"aaaaabbbbccc\"\n\n" }, { "role": "assistant", "content": "def first_non_repeating_char(input_str): \n \n char_count = {}\n \n for ch in input_str: \n \n ...
code_alpaca
code_alpaca_337
[ { "role": "user", "content": "Write a JavaScript function to check if an array contains a specific element.\n\nNow complete the following instance -\nInput: var arr = [1,2,3,4];\nOutput:" }, { "role": "assistant", "content": "function contains(arr, element) {\n return arr.indexOf(element) > -1;...
code_alpaca
code_alpaca_338
[ { "role": "user", "content": "Construct a regular expression to extract all words from a given string that start with a specific letter.\nInput: input_str = \"The quick brown fox jumped over the lazy dog\"\nOutput:" }, { "role": "assistant", "content": "var regex = /\\b[qQ]\\w+\\b/g;\n \nvar res...
code_alpaca
code_alpaca_339
[ { "role": "user", "content": "Write a C++ function to find the maximum element in an array." }, { "role": "assistant", "content": "\n// C++ program to find maximum in arr[] of size n \n\nint arr[] = {10, 324, 45, 90, 9808}; \n\nint n = sizeof(arr)/sizeof(arr[0]); \n\nint max = arr[0];\n\n// Trav...
code_alpaca
code_alpaca_340
[ { "role": "user", "content": "Can you help with this?\n\nCreate a Node.js function to concatenate two strings.\n" }, { "role": "assistant", "content": "function concatenate(str1, str2) {\n return str1 + str2;\n}\n\nconsole.log(concatenate('Hello', 'World')); //HelloWorld" } ]
code_alpaca
code_alpaca_341
[ { "role": "user", "content": "Construct a regular expression to check if a string begins with a given substring.\n" }, { "role": "assistant", "content": "//String begins with substring\nvar regex = /^substring/;\n\nif (input_str.match(regex)) {\n console.log('The string begins with the substrin...
code_alpaca
code_alpaca_342
[ { "role": "user", "content": "Write a Ruby program to search for a specific item in an array of strings.\n\narray = [\"Apple\",\"Banana\",\"Mango\",\"Orange\"]\n\n" }, { "role": "assistant", "content": "def search_array(array, item) \n return array.include?(item)\nend\n \nputs search_array(arr...
code_alpaca
code_alpaca_343
[ { "role": "user", "content": "Write a PHP program to find the sum of all elements of an array.\n\n" }, { "role": "assistant", "content": "<?php\n \nfunction sum_array($arr) {\n $sum = 0;\n foreach ($arr as $val) {\n $sum += $val;\n }\n return $sum;\n}\n \n$arr = array(5, 10, 2...
code_alpaca
code_alpaca_344
[ { "role": "user", "content": "Create an HTML form with radio buttons for selecting gender." }, { "role": "assistant", "content": "\n<form>\n <label>Gender:</label><br>\n <input type=\"radio\" name=\"gender\" value=\"male\"> Male<br>\n <input type=\"radio\" name=\"gender\" value=\"female\"> Fe...
code_alpaca
code_alpaca_345
[ { "role": "user", "content": "Tell me how would you respond to the following request.\nWrite a Java program to find the largest element in a given array.\n" }, { "role": "assistant", "content": "public class Largest { \n \n static int getLargest(int[] inputArray){ \n int largest = inp...
code_alpaca
code_alpaca_346
[ { "role": "user", "content": "Write a response that appropriately completes the request.\n\n### Instruction:\nConstruct a SQL query to find all columns in a table called \"customers\" where the first name is equal to 'John'.\n\n### Response:" }, { "role": "assistant", "content": "SELECT * FROM c...
code_alpaca
code_alpaca_347
[ { "role": "user", "content": "What is the correct syntax for an infinite loop in C++?\n" }, { "role": "assistant", "content": "while (true) {\n // Code to run\n}" } ]
code_alpaca
code_alpaca_348
[ { "role": "user", "content": "Instruction: Create a method in Java to return the largest of three numbers.\n" }, { "role": "assistant", "content": "public static int max(int num1, int num2, int num3) {\nint max = num1;\nif (num2 > max) {\n max = num2;\n}\nif (num3 > max) {\n max = num3;\n}\nretu...
code_alpaca
code_alpaca_349
[ { "role": "user", "content": "Count the number of words in this sentence using Python.\nThis sentence has a total of eight words.\n" }, { "role": "assistant", "content": "8" } ]
code_alpaca
code_alpaca_350
[ { "role": "user", "content": "Write a response that appropriately completes the request.\n\n### Instruction:\nWrite a query in SQL to select all the rows from table Books.\n\n### Response:" }, { "role": "assistant", "content": "SELECT * FROM Books;" } ]
code_alpaca
code_alpaca_351
[ { "role": "user", "content": "Generate a 15-digit random number using Python.\n\nAnswer:" }, { "role": "assistant", "content": "import random\n\nrandom.randint(100000000000000, 999999999999999)" } ]
code_alpaca
code_alpaca_352
[ { "role": "user", "content": "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\nCompare the two strings character-by-character and return the number of differences using Java.\n\n...
code_alpaca
code_alpaca_353
[ { "role": "user", "content": "Classify the following transaction as valid or invalid using Python.\n\nTransaction ID: 101\nTransaction Amount: -200\n\n" }, { "role": "assistant", "content": "\"invalid\"" } ]
code_alpaca
code_alpaca_354
[ { "role": "user", "content": "Write a response that appropriately completes the request.\n\n### Instruction:\nWrite a query in MongoDB to find all the documents in the collection \"Books\".\n\n### Response:" }, { "role": "assistant", "content": "db.Books.find({})" } ]
code_alpaca
code_alpaca_355
[ { "role": "user", "content": "Implement a function in JavaScript to calculate the average of all elements in an array.\n\n[2, 3, 9]\n\n" }, { "role": "assistant", "content": "function avg(arr) {\n let sum = 0;\n for (const val of arr) {\n sum += val;\n }\n return sum/arr.lengt...
code_alpaca
code_alpaca_356
[ { "role": "user", "content": "Write a response that appropriately completes the request.\n\n### Instruction:\nGenerate a random string of 12 characters using Python.\n\n### Response:" }, { "role": "assistant", "content": "import string\nimport random\n\n''.join(random.choices(string.ascii_letter...
code_alpaca
code_alpaca_357
[ { "role": "user", "content": "What is the command to print \"Hello World\" twelve times in Python?\n" }, { "role": "assistant", "content": "for i in range(12):\n print(\"Hello World\")" } ]
code_alpaca
code_alpaca_358
[ { "role": "user", "content": "Given a string s, write a function to check if the string is a palindrome.\n\ns = \"A man, a plan, a canal: Panama!\"\n\n" }, { "role": "assistant", "content": "def is_palindrome(s):\n s = s.lower().replace(' ', '').replace(',', '').replace(':', '').replace('!', ...
code_alpaca
code_alpaca_359
[ { "role": "user", "content": "Generate a list of the first three even numbers Output:" }, { "role": "assistant", "content": "[2, 4, 6]" } ]
code_alpaca
code_alpaca_360
[ { "role": "user", "content": "Task: Edit the Java code to filter out the persons whose age is less than 18.\n\nList<Person> persons = new ArrayList<>();\n\nfor (Person person : persons) {\n System.out.println(person.getName());\n}\n\nAnswer:" }, { "role": "assistant", "content": "List<Person>...
code_alpaca
code_alpaca_361
[ { "role": "user", "content": "You need to find the largest subset of an array that sums up to a given value.\narr = [1, 2, 3, 4, 5], target = 8\n" }, { "role": "assistant", "content": "def find_largest_subset(arr, target):\n curr_sums, max_sum_list = [], []\n for num in arr:\n for c...
code_alpaca
code_alpaca_362
[ { "role": "user", "content": "Instruction: Can you explain what is imperative programming?\n" }, { "role": "assistant", "content": "Imperative programming is a programming paradigm that describes computation in terms of statements that change a program’s state. Imperative programming focuses on ...
code_alpaca
code_alpaca_363
[ { "role": "user", "content": "How do you count the number of specific characters in a given string?\n\nAnswer:" }, { "role": "assistant", "content": "You can use the count() method in Python to count the number of specific characters in a given string. For example:\n\ns = 'My name is John'\n\nnu...
code_alpaca
code_alpaca_364
[ { "role": "user", "content": "Generate an array with the first 10 even numbers" }, { "role": "assistant", "content": "\n[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]" } ]
code_alpaca
code_alpaca_365
[ { "role": "user", "content": "Write a codde fragment to print out the most frequent element in an array.\n\nAdditional Context:\narr = [1, 2, 2, 3, 4, 4, 5]\n\nAnswer:" }, { "role": "assistant", "content": "freq = {}\n\nfor el in arr:\n if el in freq:\n freq[el] += 1\n else:\n ...
code_alpaca
code_alpaca_366
[ { "role": "user", "content": "Write a JS program that takes a number n and prints out the first n even numbers.\nn = 10\n\n" }, { "role": "assistant", "content": "function getFirstNEvens(n) {\n let arr = [];\n for (let i = 0; i < n; i++) {\n arr.push(2 * i);\n }\n return arr;\...
code_alpaca
code_alpaca_367
[ { "role": "user", "content": "You need to complete the following task:\n\nHow do you merge two sorted arrays in O(n) time?\n\n" }, { "role": "assistant", "content": "Merging two sorted arrays in O(n) time can be done using a two-pointer technique. Starting from the beginning of both the arrays, ...
code_alpaca
code_alpaca_368
[ { "role": "user", "content": "Classify whether the following is an imperative or functional programming language.\n\nJava\n\n" }, { "role": "assistant", "content": "Imperative Programming" } ]
code_alpaca
code_alpaca_369
[ { "role": "user", "content": "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\nUpdate the existing HTML structure to add a new div class named \"container\".\n\n### Input:\n<body...
code_alpaca
code_alpaca_370
[ { "role": "user", "content": "Determine the type of the given variable.\nvar age = 20\n\nResponse:" }, { "role": "assistant", "content": "Number." } ]
code_alpaca
code_alpaca_371
[ { "role": "user", "content": "You need to complete the following task:\n\nDesign a JSON structure including a \"name\" field and a \"date\" field.\n\n" }, { "role": "assistant", "content": "{\"name\": \"\", \"date\": \"\"}" } ]
code_alpaca
code_alpaca_372
[ { "role": "user", "content": "Task: Construct a for loop to iterate through an array of numbers.\n\nvar nums = [1,2,3,4,5]\n\nAnswer:" }, { "role": "assistant", "content": "for(var i=0; i<nums.length; i++){\n console.log(nums[i]);\n}" } ]
code_alpaca
code_alpaca_373
[ { "role": "user", "content": "Task: Modify the following for loop to loop backwards.\n\nfor(var i=0; i<nums.length; i++){\n console.log(nums[i]);\n}\n\n" }, { "role": "assistant", "content": "for(var i=nums.length-1; i>=0; i--){\n console.log(nums[i]);\n}" } ]
code_alpaca
code_alpaca_374
[ { "role": "user", "content": "Describe the purpose of the given function.\nfunction avg(a,b){\n return (a+b)/2;\n}\n" }, { "role": "assistant", "content": "The purpose of this function is to calculate the average of two given numbers and return the result." } ]
code_alpaca
code_alpaca_375
[ { "role": "user", "content": "Create a CSS style to set the background color of a div class \"sample\".\n\n" }, { "role": "assistant", "content": ".sample{\n background-color: #fff;\n}" } ]
code_alpaca
code_alpaca_376
[ { "role": "user", "content": "Instruction: Compare and contrast two sorting algorithms: Bubble sort and Quick sort.\nOutput:" }, { "role": "assistant", "content": "Bubble sort is an algorithm that compares adjacent elements and swaps positions if they are out of order. It continues in this mann...
code_alpaca
code_alpaca_377
[ { "role": "user", "content": "Convert the given binary string to its corresponding decimal number.\n10111101\n" }, { "role": "assistant", "content": "189." } ]
code_alpaca
code_alpaca_378
[ { "role": "user", "content": "Explain the purpose of try-catch statement in JavaScript." }, { "role": "assistant", "content": "\nThe try-catch statement is used to handle errors in JavaScript code. It allows the code to continue running even if there is an error. The try clause contains the code...
code_alpaca
code_alpaca_379
[ { "role": "user", "content": "Plase answer the following request: Generate a unique 6 character alphanumeric string.\nAnswer:" }, { "role": "assistant", "content": "j4xdu6." } ]
code_alpaca
code_alpaca_380
[ { "role": "user", "content": "You need to complete the following task:\n\nConstruct an array of objects with the fields \"name\" and \"age\".\n\n" }, { "role": "assistant", "content": "[\n {\n \"name\": \"\",\n \"age\": \n },\n {\n \"name\": \"\",\n \"age\": \n },\n ...\n]" } ...
code_alpaca
code_alpaca_381
[ { "role": "user", "content": "Find the index of the given word in the sentence.\nWord: music\nSentence: I love listening to music.\n" }, { "role": "assistant", "content": "7." } ]
code_alpaca
code_alpaca_382
[ { "role": "user", "content": "Write a Python code snippet to print the pyramid structure with the given number of lines.\n4\n" }, { "role": "assistant", "content": "* \n ***\n *****\n *******" } ]
code_alpaca
code_alpaca_383
[ { "role": "user", "content": "Summarize the given paragraph in < 100 words.\n\nInput: Ada Lovelace is widely considered to be the world's first computer programmer. She was born to the poet Lord Byron and Lady Byron in 1815. She was fascinated by mathematics and charmed Charles Babbage, who is known as the ...
code_alpaca
code_alpaca_384
[ { "role": "user", "content": "Construct a switch statement to log different grades messages based on the grade variable.\n\nInput: var grade = \"A+\";\n\nOutput:" }, { "role": "assistant", "content": "switch(grade){\n case \"A+\":\n console.log(\"Excellent job!\");\n break;\n case ...
code_alpaca
code_alpaca_385
[ { "role": "user", "content": "Reverse a string using Python code.\ninput_str = \"Hello world!\"\n\n" }, { "role": "assistant", "content": "def reverse_string(input_str): \n new_string = \"\" \n for char in input_str: \n new_string = char + new_string\n \n return new_string \n \...
code_alpaca
code_alpaca_386
[ { "role": "user", "content": "Create a regex expression that captures a valid URL.\n\n" }, { "role": "assistant", "content": "^(https?:\\/\\/)([\\da-zA-Z\\.-]+)\\.([a-zA-Z\\.]{2,6})([\\/\\w \\.-]*)*\\/?$" } ]
code_alpaca
code_alpaca_387
[ { "role": "user", "content": "Write a C++ class to represent a date. Output:" }, { "role": "assistant", "content": "class Date \n{\nprivate:\n int day;\n int month;\n int year;\n\npublic:\n Date(int day, int month, int year); \n\n int getDay() const; \n int getMonth() const;\n ...
code_alpaca
code_alpaca_388
[ { "role": "user", "content": "Write a response that appropriately completes the request.\n\n### Instruction:\nWrite an SQL statement to select the name, city and country of all stores.\n\n### Response:" }, { "role": "assistant", "content": "SELECT name, city, country\nFROM stores;" } ]
code_alpaca
code_alpaca_389
[ { "role": "user", "content": "Instruction: Create a list of two-word phrases using each of the four words ('apple', 'bear', 'cat', 'dog').\nOutput:" }, { "role": "assistant", "content": "[('apple', 'bear'), ('apple', 'cat'), ('apple', 'dog'), ('bear', 'cat'), ('bear', 'dog'), ('cat', 'dog')]" ...
code_alpaca
code_alpaca_390
[ { "role": "user", "content": "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\nGiven a list of numbers, find the minimum and maximum elements.\n\n### Input:\n[3, 4, 8, 1, 5, 0, 9...
code_alpaca
code_alpaca_391
[ { "role": "user", "content": "Instruction: Assign the value 'Hello World' to the variable 'message'.\n" }, { "role": "assistant", "content": "message = \"Hello World\"" } ]
code_alpaca
code_alpaca_392
[ { "role": "user", "content": "Calculate the square root of the given number.\n25\n" }, { "role": "assistant", "content": "sqrt(25) = 5" } ]
code_alpaca
code_alpaca_393
[ { "role": "user", "content": "Write a JavaScript code to print the first 10 terms of the Fibonacci series.\n\nAnswer:" }, { "role": "assistant", "content": "let a = 0, b = 1, c, limit = 10;\n\nconsole.log(\"Fibonacci Series of \"+limit+\" numbers:\");\n\nfor(var i=0; i < limit; i++){\n if(i<=...
code_alpaca
code_alpaca_394
[ { "role": "user", "content": "Create a MySQL table 'employees' with columns name, age, department and salary.\n\n" }, { "role": "assistant", "content": "CREATE TABLE employees (\n name VARCHAR(255) NOT NULL,\n age INT NOT NULL,\n department VARCHAR(255) NOT NULL,\n salary DOUBLE NOT ...
code_alpaca
code_alpaca_395
[ { "role": "user", "content": "Find the largest number from the given list of numbers.\n[7, 9, 11, 5]\n\n" }, { "role": "assistant", "content": "largest_number = 11" } ]
code_alpaca
code_alpaca_396
[ { "role": "user", "content": "Write a Python program to print the following pattern. Output:" }, { "role": "assistant", "content": "for i in range(1,6):\n for j in range(1,i+1):\n print(\"*\", end=\" \")\n print()" } ]
code_alpaca
code_alpaca_397
[ { "role": "user", "content": "Task: Generate a random 5-character string using the letters a-z.\n\n" }, { "role": "assistant", "content": "import random\n\ncharacters = \"abcdefghijklmnopqrstuvwxyz\"\n\nrandom_string = \"\"\nfor i in range(5):\n random_string += random.choice(characters)\n\np...
code_alpaca
code_alpaca_398
[ { "role": "user", "content": "Task: Write a Python function to check if a given string is an anagram of another or not.\n\nword1 = \"cat\"\nword2 = \"tac\"\n\n" }, { "role": "assistant", "content": "def is_anagram(word1, word2):\n return sorted(word1) == sorted(word2)" } ]
code_alpaca
code_alpaca_399
[ { "role": "user", "content": "Write a Python function to create a two-dimensional array of specified dimensions.\nResponse:" }, { "role": "assistant", "content": "def create_2D_array(rows, columns):\n arr = [[] * columns] * rows\n return arr" } ]