text stringlengths 141 2.89k ⌀ | instruction stringlengths 19 1.5k ⌀ | input stringlengths 0 800 ⌀ | output stringlengths 1 2.5k ⌀ |
|---|---|---|---|
null | Create an HTML form that asks for the user's name and age. | <form> <label for="name">Name:</label> <input type="text" name="name" id="name"> <br> <label for="age">Age:</label> <input type="number" name="age" id="age"> </form> | |
null | Fill in the blanks of the following Python code to implement a Selection Sort algorithm. | def selection_sort(arr): for [i] in [range](len(arr),1,-1): max_element=arr[0] for [j] in [range]([i]): if arr[j] > max_element : max_element=arr[j] [temp] = arr[i] arr[i] = max_element arr[arr.index(max_element)] = [temp] | def selection_sort(arr): for i in range(len(arr),1,-1): max_element=arr[0] for j in range(i): if arr[j] > max_element : max_element=arr[j] temp = arr[i-1] arr[i-1] = max_element arr[arr.index(max_element)] = temp |
null | Write a python program to generate a Combinations of four numbers from a given list of N numbers | numbers = [1, 4, 5, 6, 7] | def comb_four(nums):
result = []
for i in range(len(nums)-3):
for j in range(i+1, len(nums)-2):
for k in range(j+1, len(nums)-1):
for l in range(k+1, len(nums)):
result.append([nums[i], nums[j], nums[k], nums[l]])
return result |
[CS Wikipedia] Arup
Arup Group Limited je britská nadnárodní inženýrská společnost, která vznikla v roce 1946 v Londýně, kde stále sídlí. Arup provádí plánování, řízení projektů a konzultování ve stavebním průmyslu a řešení různých aspektů vytvořeného prostředí jako udržitelnost a zmírňování změny klimatu. Arup má pře... | null | null | null |
null | Write a Python program to combine two lists of dictionaries into one list. | list1: [{'a','b', 'c'}, {'d' : 'e', 'f': 'g'}]
list2: [{'h' : 'i', 'j': 'k'}, {'l': 'm'}] | combined = [{'a': 'b', 'c'}, {'d': 'e', 'f': 'g'}, {'h': 'i', 'j' : 'k'}, {'l': 'm'}] |
null | Create an algorithm for finding the least common multiple of two numbers. | One algorithm to find the least common multiple of two numbers is as follows: Step 1: Find the greatest common divisor (GCD) of the two numbers. Step 2: Divide the product of the two numbers by the GCD to find the least common multiple (LCM). The GCD of two numbers can be found using the Euclidean algorithm, which work... | |
null | Design a python program to parse a CSV and detect the presence of duplicates | No Input | def find_duplicates(csv_file):
"""
A function to detect duplicates in a CSV.
Args:
csv_file (str): The path of the CSV file to be processed.
Returns:
Set of duplicates found.
"""
duplicates = set()
# Open and read the CSV file
with open(csv_file,'r') as csvfi... |
[HI Wikipedia] ऑस्ट्रेलिया
ऑस्ट्रेलिया (), सरकारी तौर पर ऑस्ट्रेलियाई राष्ट्रमंडल दक्षिणी गोलार्द्ध के महाद्वीप के अर्न्तगत एक देश है जो दुनिया का सबसे छोटा महाद्वीप भी है और दुनिया का सबसे बड़ा द्वीप भी, जिसमे तस्मानिया और कई अन्य द्वीप हिंद और प्रशांत महासागर में है। ऑस्ट्रेलिया एकमात्र ऐसी जगह है जिसे एक ही साथ महा... | null | null | null |
null | Integrate the following logic into a python program | Read a number and print "OK" if the number is greater than 10, and print "Not OK" otherwise. | num = int(input("Enter a number: "))
if num > 10:
print("OK")
else:
print("Not OK") |
null | Create a Python script to analyse sentiment from a list of sentences and print out the results. | ["I am happy.", "I am not happy.", "This is great!"] | import nltk
from nltk.sentiment.vader import SentimentIntensityAnalyzer
sentences = ["I am happy.", "I am not happy.", "This is great!"]
analyzer = SentimentIntensityAnalyzer()
for sentence in sentences:
scores = analyzer.polarity_scores(sentence)
print(f"{sentence} : {scores}")
# Output:
# I am happy. : ... |
null | Given a string, write a python program to print the next largest palindrome. | "1234" | def next_largest_palindrome(num):
# convert string to a number
num = int(num)
# increment number by 1
num += 1
while not is_palindrome(str(num)):
# increment number by 1
num += 1
return num
def is_palindrome(num):
return num == num[::-1]
print(next_largest_palindrome("1234... |
[EN Wikipedia] Mexico City Grand Prix (badminton)
The Mexico City Grand Prix or Mexico City Open is an open international badminton tournament held in Mexico City, Mexico. The tournament was a Grand Prix level, with the total prize money equaling US$50,000. Previous winners References External links Federación Mexican... | null | null | null |
[CS Wikipedia] Rochefort-en-Terre
Rochefort-en-Terre je francouzská obec v departementu Morbihan v regionu Bretaň. Ves je známá svým zachovalým středověkým rázem. Poloha Rochefort-en-Terre obklopují obce Pluherlin a Malansac. Přes území obce protéká řeka Gueuzon. Vývoj počtu obyvatel Počet obyvatel Historie Ve 12. sto... | null | null | null |
null | Design a program in Python that counts the number of words in a paragraph and returns the count. | def count_paragraph_words(par):
par = par.split()
return len(par) | |
[EN Wikipedia] Amsterdam
Amsterdam ( , , ; literally, "The Dam on the River Amstel") is the capital and most populated city of the Netherlands, with The Hague being the seat of government. It has a population of 921,402 within the city proper, 1,457,018 in the urban area and 2,480,394 in the metropolitan area. Located... | null | null | null |
null | Write a Python code snippet to create a shallow copy of the following dictionary: {‘a’: 1, ‘b’: 2}. | {'a': 1, 'b': 2} | import copy
original_dict = {'a': 1, 'b': 2}
shallow_copy_dict = copy.copy(original_dict) |
null | Generate the SQL command to insert a new item in an existing table. | Table Name: users Values: ('Adam', 34, 'Male') | INSERT INTO users (name, age, gender) VALUES ('Adam', 34, 'Male'); |
[DE Wikipedia] Wilhelm Lüdecke
Carl Friedrich Wilhelm Lüdecke (* 29. Juli 1868 in Bismark (Altmark); † 6. November 1938 in Bismark) war ein deutscher Komponist und Musikverleger. Leben Wilhelm Lüdecke stammte aus einfachen Verhältnissen, sein Vater, Friedrich Wilhelm Lüdecke war Handwerker und stellte Holzpantinen her... | null | null | null |
[DE Wikipedia] Snow White (2025)
Snow White ist eine angekündigte Realverfilmung des Zeichentrickfilms Schneewittchen und die sieben Zwerge der Walt-Disney-Studios von 1937, der auf dem Märchen Schneewittchen der Brüder Grimm basiert. Als Regisseur fungiert Marc Webb. Die Hauptrolle spielt Rachel Zegler, während Gal G... | null | null | null |
null | Output the median of the given list of numbers. | [1, 4, 7, 9, 12] | 7.5 |
null | Create a Python program to handle calendars and reminders. | Not applicable | import datetime
# Sample reminder
reminders = [
{
"date": "2021-02-14",
"title": "Valentine's Day",
"description": "Buy a heart-shaped document for your beloved!",
},
{
"date": "2021-04-01",
"title": "April Fool's Day",
"description": "Camouflage pranks on the family!",
},
]
# Function to add reminders
... |
null | Create a function which accepts a string and prints out each word with the count of its characters. | String: "Hello World" | def print_word_lengths(input_string): #Split the string into individual words words = input_string.split() #Iterate over each word for word in words: #Print the word and the length of the word print('{}: {}'.format(word, len(word))) print_word_lengths('Hello World') Output: Hello: 5 World: 5 |
null | Create an HTML form with two input fields for email and password. | <form> <label>Email: <input type="email" name="email"> </label> <label>Password: <input type="password" name="password"> </label> <input type="submit" value="Submit"> </form> | |
null | Normalize a string in Python. | def normalize(string):
return string.lower().strip() | |
null | Generate a random number between 0-100 in Python. | import random #Generate a random number between 0-100 randomNum = random.randint(0, 100) print ("Random number:", randomNum) | |
null | Create a script to generate a random password using uppercase, lowercase and numerics. | import string import random def generate_password(): password_characters = string.ascii_uppercase + string.ascii_lowercase + string.digits password_length = 16 return ''.join(random.choice(password_characters) for i in range(password_length)) generate_password() | |
[EN Wikipedia] List of Drag Race Holland episodes
Drag Race Holland is a Dutch reality competition streaming television series, based on the American RuPaul's Drag Race. The series is produced by Vincent TV and World of Wonder. The show premiered on Videoland in the Netherlands and on WOW Presents Plus internationally... | null | null | null |
null | Create a simple program to sort an array of integers from smallest to largest. | [7,3,1,9,2] | def sort_array(arr): arr.sort() return arr result = sort_array([7,3,1,9,2]) print(result) # Output: [1,2,3,7,9] |
null | In Python, write a script for generating one million random passwords. | import random
for x in range(1000000):
password = ''
for i in range(12):
password += random.choice('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@#!')
print(password) | |
[DE Wikipedia] Texas Motor Speedway
Der Texas Motor Speedway ist eine Rennstrecke in Fort Worth, Texas. Strecke Die Strecke ist als sogenanntes Quad Oval ausgelegt. Die Gesamtlänge der Strecke beträgt 1,5 Meilen (ca. 2400 m). Im Innenraum gibt es einen Straßenkurs mit vier verschiedenen Streckenlängen (von 0,5 Meilen ... | null | null | null |
null | Write a Python program to compute the summation of a list of numbers. | list = [1, 2, 3, 4, 5] | def compute_summation(list): result = 0 for i in list: result += i return result |
[HI Wikipedia] हेस्टिया
हेस्टिया (, यूनानी : हेस्तिआ ) प्राचीन यूनानी धर्म के प्रमुख देवियों में से एक थीं। वो परिवार, चूल्हे और घरेलू अग्नि की देवी थीं। प्राचीन रोमन धर्म में उनकी समतुल्य देवी थीं वेस्टा। यूनान के देवी-देवता यूनानी धर्म | null | null | null |
[HI Wikipedia] वाक्यविन्यास
किसी भाषा में जिन सिद्धान्तों एवं प्रक्रियाओं के द्वारा वाक्य बनते हैं, उनके अध्ययन को भाषा विज्ञान में वाक्यविन्यास, 'वाक्यविज्ञान' या सिन्टैक्स (syntax) कहते हैं। वाक्य के क्रमबद्ध अध्ययन का नाम 'वाक्यविज्ञान' कहते हैं। वाक्य विज्ञान, पदों के पारस्परिक संबंध का अध्ययन है। वाक्य भाषा का सब... | null | null | null |
null | Create a class that prints out the following message: "Welcome to the world of programming!" | class WelcomeMessage: def __init__(self): print("Welcome to the world of programming!") | |
null | Write a Python program to generate a 4-digit random number. | import random
def generate_4_digit_random_number():
return random.randint(1000, 9999)
if __name__ == '__main__':
print(generate_4_digit_random_number()) | |
null | Create an application in Python for encryption and decryption of strings. The application should take a string as input, and use a cipher text algorithm of choice to encrypt the string. | Not applicable | from Crypto.Cipher import AES
key = b'Sixteen byte key'
def encrypt(plaintext):
cipher = AES.new(key, AES.MODE_ECB)
return cipher.encrypt(plaintext)
def decrypt(ciphertext):
cipher = AES.new(key, AES.MODE_ECB)
return cipher.decrypt(ciphertext) |
null | Build a SQL query to calculate the biggest salary in the table “Employees”. | SELECT MAX(salary) FROM Employees; | |
null | Implement a Wiki page title search using Python. | Search string: "Machine Learning" | """ Implement a Wiki page title search using Python """ import wikipedia def search_wiki_title(search_string): try: wikipedia.set_lang("en") result = wikipedia.search(search_string)[0] except (wikipedia.exceptions.PageError, wikipedia.exceptions.DisambiguationError): result = None return result if __name__ == '__main__... |
[CS Wikipedia] Rudolf Hromada
Rudolf Hromada (9. listopadu 1890 Praha– 26. října 1964 ?) byl autorem esperantských slovníků a překládal do esperanta české autory, především básníky. Život Profesí vedoucí úředník. Překládal ze všech českých básníků (Erbena, Sv. Čecha, Machara, Heyduka, Sládka, Vrchlického, Wolkera, Dyk... | null | null | null |
null | Explain what is a neural network. | A neural network is an artificial intelligence system made up of connected units which process information. Each unit is analogous to a neuron in the human brain, and in a neural network, information travels from the input nodes, through the hidden layers, to the output nodes. The neurons in each layer are connected to... | |
[DE Wikipedia] Ana Rosa Quintana
Ana Rosa Quintana Hortal (* 12. Januar 1956 in Madrid) ist eine spanische Journalistin und Fernsehmoderatorin. Sie studierte Kommunikationswissenschaften an der Universität Complutense Madrid. Sie arbeitete im Radio (Radio Nacional de España, Radio Continental, Radio 80, Antena 3 Radio... | null | null | null |
[DE Wikipedia] Pablo Forlán
Pablo Forlán, vollständiger Name Pablo Justo Forlán Lamarque (* 14. Juli 1945 in Soriano) ist ein ehemaliger uruguayischer Fußballspieler. Forlán heiratete Pilar Corrazo, die Tochter des einzigen zwei Mal mit Uruguay bei Südamerikameisterschaften erfolgreichen Trainers Nino Corazzo. Aus die... | null | null | null |
null | In Java, what is a good way to make a deep copy of an object? | A deep copy of an object can be obtained by using the Object.clone() method or by serializing and deserializing the object. | |
null | Given a binary tree, write a code to search a given value in the tree. | def search_tree(tree, value): # If the tree is empty if not tree: return False if value == tree.val: return True # If the given value is less than the tree's value # search left subtree elif value < tree.val: return search_tree(tree.left, value) # If the given value is more than tree's value # search right subtree else... | |
null | Generate a random password of 16 characters that includes a mix of alphanumeric characters and punctuation. | import string import random def random_password(str_len): alphanumeric = string.ascii_letters + string.digits + string.punctuation return ''.join(random.choice(alphanumeric) for i in range(str_len)) random_password(16) | |
null | Create a Python program that displays the country, population and area of the given data. | data = [{'country':'India', 'population':1378350000, 'area':3287590},
{'country':'China', 'population':1403500000, 'area':9596961}] | data = [{'country':'India', 'population':1378350000, 'area':3287590},
{'country':'China', 'population':1403500000, 'area':9596961}]
for item in data:
print("Country:",item['country'], ",Population:", item['population'] ,
",Area:", item['area']) |
null | Generate an HTTP request to delete a customer account. | customer_id = 3 | DELETE /customers/3 HTTP/1.1 Host: example.com Content-Type: application/json Authorization: Bearer <Access Token> |
[CS Wikipedia] Jacques Fesch
Jacques Fesch (6. dubna 1930, Saint-Germain-en-Laye – 1. října 1957, La Santé) byl v roce 1957 kvůli loupežnému přepadení, při kterém zastřelil policistu, odsouzen na smrt a následně popraven. Při svém tříletém pobytu ve vězení se obrátil na katolickou víru. 36 let po jeho popravě započal ... | null | null | null |
[HI Wikipedia] चण्डीगढ़
चण्डीगढ़, (पंजाबी: ਚੰਡੀਗੜ੍ਹ), भारत का एक संघ राज्यक्षेत्र है, जो दो भारतीय राज्यों, पंजाब और हरियाणा की राजधानी भी है। इसके नाम का अर्थ है चण्डी का किला। यह हिन्दू देवी दुर्गा के एक रूप चण्डिका या चण्डी के एक मन्दिर के कारण पड़ा है। यह मन्दिर आज भी शहर से कुछ दूर हरियाणा के पंचकुला जिले में स्थ... | null | null | null |
[EN Wikipedia] Real Club de Polo de Barcelona
Real Club de Polo de Barcelona () is a country club in Barcelona, Spain. Established in 1897, it had 9000 members at the time of the 1992 Summer Olympics. Normally used for polo, field hockey, tennis, squash, and swimming by its members, the club was the venue for the Olym... | null | null | null |
[HI Wikipedia] सुभद्रा कुमारी चौहान
सुभद्रा कुमारी चौहान (१६ अगस्त १९०४-१५ फरवरी १९४८) हिन्दी की सुप्रसिद्ध कवयित्री और लेखिका थीं। झाँसी की रानी (कविता) उनकी प्रसिद्ध कविता है। वे राष्ट्रीय चेतना की एक सजग कवयित्री रही हैं। स्वाधीनता संग्राम में अनेक बार जेल यातनाएँ सहने के पश्चात अपनी अनुभूतियों को कहानी में भी व्यक... | null | null | null |
[HI Wikipedia] अज़रबाइजान
आज़रबाइजान(अन्य वर्तनी:अज़रबैजान या अज़रबाइजान) (), कॉकेशस के पूर्वी भाग में एक गणराज्य है, पूर्वी यूरोप और एशिया के मध्य में बसा हुआ। भौगोलिक रूप से यह एशिया का ही भाग है। इसके सीमांत देश हैं: अर्मेनिया, जॉर्जिया, रूस, ईरान, तुर्की और इसका तटीय भाग कैस्पियन सागर से लगता हुआ है। यह १९९१ तक भू... | null | null | null |
null | Create a Python script that prints all the combinations of a string. | String: "ABC" | def combinations(s):
# Get the length of the string
n = len(s)
# A loop to pick starting point of substring
for i in range(n):
# Pick ending point of substring
for j in range(i,n):
# Print the substring
for k in range(i,j+1)... |
null | Create a method to convert a given number to Roman numeral format. | num = 2020 | def int_to_roman(num): roman_numerals = { 1: 'I', 4: 'IV', 5: 'V', 9: 'IX', 10: 'X', 40: 'XL', 50: 'L', 90: 'XC', 100: 'C', 400: 'CD', 500: 'D', 900: 'CM', 1000: 'M' } result = '' for n in sorted(roman_numerals.keys(), reverse=True): count = num // n result += roman_numerals[n] * count num %= n return result if __name_... |
null | Edit the following Python code such that it will print an array containing the seven days of the week. | days = ["Monday", "Thuesday", "Wednesday", "Thrusday", "Friday"]
for day in days:
print(day) | days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
for day in days:
print(day) |
null | Develop a function in Python to calculate the n factorial. | def factorial(n):
if n == 0:
return 1
else:
return n*factorial(n-1) | |
[EN Wikipedia] Anthophyta
The anthophytes are a paraphyletic grouping of plant taxa bearing flower-like reproductive structures. The group, once thought to be a clade, contained the angiosperms - the extant flowering plants, such as roses and grasses - as well as the Gnetales and the extinct Bennettitales. Detailed mo... | null | null | null |
null | Write a python loop to print all the even numbers between 2 and 15 (inclusive). | for i in range(2, 16): if i % 2 == 0: print(i) | |
null | Create a MongoDB document containing the following data | Name: John Age: 32 Occupation: Engineer | { name: "John", age: 32, occupation: "Engineer" } |
null | Create a React component to render a pie chart | import React from 'react'; import {Pie} from 'react-chartjs-2'; const data = { labels: [ 'Red', 'Green', 'Yellow' ], datasets: [{ data: [300, 50, 100], backgroundColor: [ '#FF6384', '#36A2EB', '#FFCE56' ], hoverBackgroundColor: [ '#FF6384', '#36A2EB', '#FFCE56' ] }] }; export const PieChartComponent = () => { return ( ... | |
null | Build a type checking function to determine what kind of data is being processed, given a generic string in Python. | str = '123' | def check_type(str):
try:
int(str)
return 'Integer'
except ValueError:
pass
try:
float(str)
return 'Float'
except ValueError:
pass
return 'String'
print(check_type('123')) # prints 'Integer' |
[DE Wikipedia] Tomoe Gozen
Tomoe Gozen (japanisch , deutsch etwa: „Dame Tomoe“; * um 1157; † um 1247), veraltet Tomowe, war eine der wenigen weiblichen Krieger (Onna-musha) der japanischen Geschichte. Leben und Wirken Bis zur Schlacht von Awazu Tomoe Gozen kam laut dem Heike Monogatari aus der Provinz Shinano. Später ... | null | null | null |
null | Write a Java program for removing all white spaces from a given string. | public class RemoveSpace { public static String removeSpace(String str) { return str.replaceAll("\\s",""); } public static void main (String[] args) { String str = "Hello World!"; str = removeSpace(str); System.out.println(str); } } | |
null | Construct a CSS code that adds a background color of red to the ’div' element. | div { background-color: red; } | |
[DE Wikipedia] Rindsmaul
Rindsmaul ist der Familienname folgender Personen: Rindsmaul steht für: Rindsmaul (Adelsgeschlecht), ursprünglich fränkisches, dann steirisches Adelsgeschlecht | null | null | null |
null | Below is the code of a shopping list application. Modify it to add a function to calculate the total cost of all items in the list. | shopping_list = { 'item1': 2.5, 'item2': 3.5, 'item3': 4.25 } | shopping_list = { 'item1': 2.5, 'item2': 3.5, 'item3': 4.25 } def calculate_cost(list): cost = 0 for item in list: cost += list[item] return cost total_cost = calculate_cost(shopping_list) print(total_cost) # prints 10.25 |
null | Given a JSON string, write a function in JavaScript to extract the value for the key "name". | jsonString = {"name":"John", "age":30, "city":"New York"} | function getValueByKey(jsonString, key) { let jsonObj = JSON.parse(jsonString); return jsonObj[key]; } nameValue = getValueByKey(jsonString, "name"); console.log(nameValue) //prints "John" |
null | Write a Java program to compare two strings lexicographically. | Two strings: string1="GeeksforGeeks" and string2="GeeksQuiz" | public class CompareStringLexicographically { public static void main(String[] args) { String str1 = "GeeksforGeeks"; String str2 = "GeeksQuiz"; // Comparing both strings lexicographically int result = str1.compareTo(str2); // checking for the comparison output if (result > 0) System.out.println("str1 is greater than s... |
null | Formulate a spark query to delete records having a given value in a field | field: age; value: 18; table: people | DELETE FROM people WHERE age = 18; |
null | Rewrite the following code snippet to use the generator in Python. | def squares_up_to_n(n):
results = []
for i in range(n):
results.append(i**2)
return results | def squares_up_to_n(n):
for i in range(n):
yield i**2 |
null | Calculate the sum of the squares of the given number array. | [2, 3, 4] | 29 (2^2 + 3^2 + 4^2 = 4 + 9 + 16 = 29) |
null | Create an algorithm in Python for removing duplicates from an array of integers. | [1, 2, 4, 5, 6, 2, 7, 4] | def remove_duplicates(arr):
s = set()
result = []
for i in arr:
if i not in s:
s.add(i)
result.append(i)
return result
arr = [1, 2, 4, 5, 6, 2, 7, 4]
print(remove_duplicates(arr))
# Output: [1, 2, 4, 5, 6, 7] |
null | Write a code to wrap a text in a box, with the given length and padding parameters. | text = "Hello World!", length = 20, padding = 5 | def wrap_in_box(text, length, padding): border = "" for i in range(length): border += "-" space = "" for i in range(padding): space += " " text = space + text + space if len(text) > length: text = text[:length-1] text = text.center(length) print(border) print(text) print(border) |
null | Build an algorithm in Python for finding the sum of all the odd numbers in a given array. | [1, 2, 3, 4, 5, 6] | def sumOddNumbers(arr):
sum = 0
for num in arr:
if num % 2 != 0:
sum += num
return sum
arr = [1, 2, 3, 4, 5, 6]
print(sumOddNumbers(arr)) |
null | Create a program which takes a string and replaces all instances of the letter "e" with "X". | "Hello world" | def replace_e_with_x(s): """Function to replace all instances of the letter "e" with "X""" return s.replace('e', 'X') print(replace_e_with_x("Hello world")) # Output: "HXllo world" |
null | Create a REST API using the Flask framework in Python to create, read, update and delete records from a database. | Not applicable | from flask import Flask, request
from flask_restful import Resource, Api
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
# Connect to the database
app.config['SQLALCHEMY_DATABASE_URI'] = 'YOUR DB URI'
db = SQLAlchemy(app)
# Create a model class for table row
class TableRow(db.Model):
id = db.Column(d... |
null | Write a JavaScript function that sorts an array of strings alphabetically. | myArray = ["cat","apple","dog"] | function sortArray(arr) { let sortedArray = arr.sort(); return sortedArray; } |
null | Write a function in Python to evaluate an algebraic expression | exp= "((x+y)^2)*(x+1)"
x=2
y=3 | def evaluate_expr(expr,x,y):
x = float(x)
y = float(y)
def eval_expr(expr):
return eval(expr)
evaluation = eval_expr(expr.replace("x", str(x)).replace("y", str(y)))
return evaluation
exp = "((x+y)^2)*(x+1)"
x = 2
y = 3
print(evaluate_expr(exp,x,y)) |
null | Suggest an improvement for the following piece of code | def addTwoNumbers(a, b): return a + b | def addTwoNumbers(a, b): try: if type(a) == str or type(b) == str: raise TypeError('Inputs must be of type int or float') return a + b except TypeError as e: print(e) |
null | Can you create a Python program to find prime numbers within a given range? | def is_prime(n):
if n <= 1:
return False
for i in range(2, n):
if n % i == 0:
return False
return True
def find_prime_numbers(a, b):
result = []
for num in range(a, b + 1):
if is_prime(num):
result.append(num)
return result
start = 2
end = 20
p... | |
[EN Wikipedia] Cryptanaerobacter
Cryptanaerobacter is a genus in the phylum Bacillota (Bacteria). Etymology The name Cryptanaerobacter derives from: Greek cryptos (κρυπτός), hidden; an (ἄν), not; aer, aeros (ἀήρ, ἀέρος), air; Neo-Latin, a rod bacter, nominally meaning "a rod", but in effect meaning a bacterium, rod; g... | null | null | null |
null | Write a for loop in Java to print all the numbers in a given list. | int[] list = {21, 34, 54, 77, 92}; | for (int i = 0; i < list.length; i++) { System.out.println(list[i]); } |
null | Create a Python function that takes two lists as parameters, and returns the first list with each element doubled. | list1: [1, 2, 3]
list2: [4, 5, 6] | def double_list(list1,list2):
for i in range(len(list1)):
list1[i] *= 2
return list1
list1 = [1, 2, 3]
list2 = [4, 5, 6]
print(double_list(list1,list2)) |
null | Write a SQL query to select all the vehicles from a table that are owned by John. | Table name: vehicles Columns: owner_name, vehicle | SELECT vehicle FROM vehicles WHERE owner_name = 'John' |
null | Write a Python program to determine the number of elements in a given array before the return value is -1. | Array = [2, 3, -1, 5, 4, 7] | def countElements(Array):
count = 0
for i in Array:
if i != -1:
count = count + 1
else:
break
return count |
null | Create a Python script that takes two integers as input and prints out their greatest common divisor. | 30, 54 | def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
if __name__ == "__main__":
a = int(input("Enter first integer: "))
b = int(input("Enter second integer: "))
result = gcd(a, b)
print("The GCD of {} and {} is: {}".format(a, b, result)) |
[EN Wikipedia] Pseudoschrankia brevipalpis
Pseudoschrankia brevipalpis is a species of moth in the genus Pseudoschrankia, endemic to Oahu in the Hawaiian Islands. It is a pollinator of Schiedea kaalae. References Endemic moths of Hawaii Hypeninae Moths described in 2015 | null | null | null |
null | Generate a correct SQL query to retreive a subset of rows in a table | Table Name: students Condition: Retrieve rows where the student grade is greater than 80 | SELECT * FROM students WHERE grade > 80; |
null | Create a program in Python to calculate the factorial of any given non-negative number n. | def factorial(n):
factorial = 1
while n > 0:
factorial *= n
n -= 1
return factorial | |
null | Follow the comments in the code to complete the program which prints a conversion table from Fahrenheit to Celsius. | # This program prints a conversion table from Fahrenheit to Celsius # Print a heading for the table # TODO # Print the column headings # TODO # Calculate and print the table body # TODO | # This program prints a conversion table from Fahrenheit to Celsius # Print a heading for the table print("Fahrenheit to Celsius Conversion Table") # Print the column headings print("Fahrenheit \t Celsius") # Calculate and print the table body for fahr in range(-50 , 121): celsius = (fahr - 32) * 5 / 9 print("%3d \t\t ... |
null | Generate a python program to read the contents from a given URL | import requests
def read_url(url):
r = requests.get(url)
if r.status_code == 200:
return r.text
else:
return None | |
null | Generate a program in Python to calculate the area of a circle given its radius. | 5.5 | import math
def calculate_area_of_circle(radius):
area = math.pi * radius ** 2
return area
result = calculate_area_of_circle(5.5)
print('The area of the circle is: ', result) |
null | Generate an array with the numbers from -10 to 10 in incremental order. | let arr = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | |
null | Use regex to match a substring, 'the' within a sentence. | The quick brown fox | regex = /the/ This regex will match the substring "the" in the sentence "The quick brown fox." |
[HI Wikipedia] कंपनी राज
कंपनी राज का अर्थ है ब्रिटिश ईस्ट इण्डिया कम्पनी द्वारा भारत पर शासन। यह 1773 में शुरू किया है, जब कंपनी ने कोलकाता में एक राजधानी की स्थापना की है, अपनी पहली गवर्नर जनरल वॉरेन हेस्टिंग्स नियुक्त किया और संधि का एक परिणाम के रूप में 1764 बक्सर का युद्ध के बाद सीधे प्रशासन, में शामिल हो गया है ... | null | null | null |
[CS Wikipedia] Pilot Pen Tennis 2009 – muži
Tenisový turnaj na okruhu ATP Pilot Pen Tennis 2009 se konal ve dnech 23.–29. srpna v americkém New Havenu venku na kurtech s tvrdým povrchem. Odměny činily 750,000 USD. Dvouhra Nasazení hráčů V závorce je kolo, ve kterém hráč vypadl. Všichni nasazení hráči měli v 1. kole vo... | null | null | null |
null | Create a Python object-oriented program to represent a hospital patient. The patient object should contain attributes for name, age, birthdate, and current medical conditions. | Not applicable | class Patient:
def __init__(self, name, age, birthdate, conditions):
self.name = name
self.age = age
self.birthdate = birthdate
self.conditions = conditions
def get_name(self):
return self.name
def get_age(self):
return self.age
def get_birthdate(self):
return self.birthdate
def get_conditions(self):
r... |
[CS Wikipedia] Kostel Nanebevzetí Panny Marie (Nové Město na Moravě)
Kostel Nanebevzetí Panny Marie je filiální a hřbitovní kostel v římskokatolické farnosti Nové Město na Moravě, nachází se v centru města Nové Město na Moravě na Malé ulici. Kostel je jednolodní stavba z 16. století s půlkruhovým závěrem a protáhlou l... | null | null | null |
[DE Wikipedia] Peter Hauptmann (Theologe)
Peter Hauptmann (* 25. März 1928 in Chemnitz; † 23. Juni 2016 in Überlingen) war ein deutscher lutherischer Theologe, Professor für Kirchengeschichte Osteuropas und Theologiegeschichte der Lutherischen Konfessionskirchen an der Westfälischen Wilhelms-Universität Münster, sowie... | null | null | null |
[CS Wikipedia] Kaplická brázda
Kaplická brázda je geomorfologický podcelek v západní části Novohradského podhůří. Jedná se o v severojižním směru protáhlou prolomovou sníženinu širokou 5–12 km, která je pokračováním severně položené Českobudějovické pánve. Je ohraničena výraznými zlomovými svahy – zejména na západě, k... | null | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.