[output] | def max_min(my_list): max_val = my_list[0] min_val = my_list[0] for val in my_list: if val > max_val: max_val = val if val < min_val: min_val = val return (max_val, min_val) [instruction] | Create a program to find the maximum and minimum from a given list [input] | my_list = [5, 7, 6, 3]
[output] | class Person: def __init__(self, name, age): self.name = name self.age = age [instruction] | Construct a class which instantiates objects with a given name and age [input] |
[output] | def fibonacci(n): # base case if n <= 1: return n # recursive case else: return(fibonacci(n-1) + fibonacci(n-2)) [instruction] | Write a recursive method to calculate the Fibonacci number of a given index [input] |
[output] | SELECT c.name FROM customers c JOIN orders o ON c.customer_id = o.customer_id JOIN order_items oi ON o.order_id = oi.order_id JOIN products p ON p.product_id = oi.product_id WHERE p.category = 'category_name'; [instruction] | Create a SQL query to get the names of all the customers who have purchased a product from a specific category. [input] |
[output] | <html> <head> <script> function renderCheckboxes() { var checkboxes = document.createElement("input"); checkboxes.type = "checkbox"; checkboxes.name = "checkbox"; checkboxes.value = "1"; [instruction] | Create an HTML page that renders two checkboxes and a button using JavaScript. [input] |
[output] | <customer> <name>John Doe</name> <address>123 Main Street, Anytown, USA 10101</address> </customer> [instruction] | Create an XML element to store the customer information, such as name and address. [input] |
[output] | <html> <head> <script> function printInput() { let input = document.getElementById("input").value; document.getElementById("result").innerHTML = input; } </script> </head> <body> <input type="text" id="input" [instruction] | Create an HTML page that contains an input field and a submit button; when the button is clicked, it should print the input text in the HTML page. [input] |
[output] | def ctof(celsius): fahrenheit = (celsius * 9/5) + 32 return fahrenheit ctof(37.5) // returns 99.5 [instruction] | Construct a function that converts a given temperature from Celsius to Fahrenheit. [input] | Celsius Temperature: 37.5
[output] | Pronoun: She Verb: was Adjective: embarrassed Verb: to open Determiner: the Noun: door [instruction] | Analyze the given sentence and label each word according to its part of speech. [input] | Sentence: She was embarrassed to open the door.
[output] | <?php // Function to collect user input and query the database function bookSeats(){ // Database connection and query $db_connection = new mysqli("localhost", "user", "password", "database"); $query = "SELECT * FROM movie_theater WHERE no_of_seats > 0 ORDER BY name ASC"; $result = $db_c [instruction] | Develop a PHP web application for a movie theater booking system. [input] |
[output] | <html> <body> <form action="" method="POST"> Enter your name: <input type="text" name="name"><br> <input type="submit" value="Submit"> </form> <?php if (isset($_POST['name'])) { echo "Hello, " . $_POST['name']; } ?> </body> </html> [instruction] | Construct a HTML page that takes a user input and display the response. [input] |
[output] | body { background-color: #FFFFFF; font-family: Arial, sans-serif; font-size: 14px; margin: 0px; padding: 0px; } h1{ font-size: 1.5em; font-weight: bold; } p { line-height: 25px; margin: 15px 0px; } [instruction] | Design a CSS style sheet to format a web page. [input] |
[output] | SELECT customer.name, SUM(sales.amount) AS total_sales FROM customer INNER JOIN sales ON customer.ID = sales.customer_id GROUP BY customer.name ORDER BY total_sales DESC; [instruction] | Construct a SQL query to find the list of customers with the highest total of sales. [input] |
[output] | import pandas as pd # Read in the data df = pd.DataFrame({'name': ['John', 'Mark', 'Isabelle'], 'age': [25, 45, 75]}) # Add a new column "age_group" def categorize_age(age): if age < 18: return "young" elif 18 <= age < 65: return "adult" else: [instruction] | Add a new column to a Pandas DataFrame called "age_group" that contains categorical values "young","adult","elderly". [input] | name age John 25 Mark 45 Isabelle 75
[output] | min_seats = 2 max_seats = 12 [instruction] | Calculate the maximum and minimum values in the column "seats". [input] | job | seats -----+-------- A | 3 B | 12 C | 2
[output] | import json data = """ { "fruits": [ { "type": "apple", "count": 10 }, { "type": "orange", "count": 5 }, { "type": "banana", "count": 15 } ] } """ data = json.loads(data) # Get the count for each type of fruit apple_count = 0 orange_count = 0 banana_count = 0 for f [instruction] | Given the JSON data below, find the count of each type of fruit. [input] | { "fruits": [ { "type": "apple", "count": 10 }, { "type": "orange", "count": 5 }, { "type": "banana", "count": 15 } ] }
[output] | sentence = "python is a programming language" # split the sentence into individual words words = sentence.split(" ") # capitalize each word in the sentence capitalized_words = [word.capitalize() for word in words] # join the words back together capitalized_sentence = " ".join(capitalized_words) [instruction] | Using string functions, capitalize each word in the given sentence. [input] | sentence = "python is a programming language"
[output] | # Generate a list containing the squares of the first ten odd numbers list_of_squares = [x**2 for x in range(1, 21, 2)] print(list_of_squares) # prints [1, 9, 25, 49, 81, 121, 169, 225, 289, 361] [instruction] | Generate a list containing the squares of the first ten odd numbers. [input] |
[output] | def get_prime_numbers(start, end): """ Function to return a list of all the prime numbers between start and end """ prime_numbers = [] for num in range(start, end + 1): if num > 1: is_prime = True for j in range(2, int(num/2) + 1): [instruction] | Create a function that takes two arguments, "start" and "end", and returns a list of all the prime numbers between the two. [input] |
[output] | import numpy as np # Create the matrix matrix = np.array([[0, 1, 2], [3, 4, 5], [6, 7, 8]]) # Get the lengths of each row row_lengths = [len(row) for row in matrix] # Delete the row with the minimum length and print the result del matrix[row_lengths.index(m [instruction] | Given the following matrix, delete the row or column that contains the least number of elements. [input] | [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
[output] | # Bubble sort function def bubble_sort(my_list): # Do n times for i in range(0, len(my_list) - 1): # Do n - i - 1 times for j in range(0, len(my_list) - 1 - i): if my_list[j] > my_list[j+1]: my_list[j], my_list[j+1] = my_list[j+1], my_list[j] r [instruction] | Sort the following list using a bubble sort algorithm. [input] | [36, 71, 16, 21, 73]
[output] | <html> <body style="background-color: blue;"> </body> </html> [instruction] | Edit the following HTML string so that it sets the background color of the page to "blue". [input] | <html> <body> </body> </html>
[output] | # Count the number of words in the sentence sentence = "Hello World" num_words = len(sentence.split()) print(num_words) # prints 2 [instruction] | Write a code in Python to count the number of words in the sentence "Hello World". [input] |
[output] | for i in range(10): print('hello') [instruction] | Create a loop that prints 'hello' 10 times when ran. [input] |
[output] | ['<img src="example.JPG" alt="Example Image"/>', '<img src="example2.JPG" alt="Example Image 2"/>'] [instruction] | Parse the HTML text to get all the <img> tags. [input] | <html> <body> <p>This is an example</p> <img src="example.JPG" alt="Example Image"/> <img src="example2.JPG" alt="Example Image 2"/> <p>This is the end</p> </body> </html>
[output] | def my_function(string): vowels = 'aeiouAEIOU' newString = '' for char in string: if char not in vowels: newString += char return newString [instruction] | Define a function called my_function that will take a string as an argument and returns the string with all the vowels removed. [input] |
[output] | 5 [instruction] | Find the sum of two integers x and y. [input] | x=2 y=3
[output] | 24 [instruction] | Calculate the least common denominator of 6 and 8. [input] |
[output] | a = 'a' while a <= 'z': print(a) a = chr(ord(a)+1) [instruction] | Create a while loop that prints all the letters of the alphabet. [input] |
[output] | 11 [instruction] | Given a set of numbers, find the largest number from the set. [input] | [2, 9, 10, 11, 5]