text stringlengths 141 2.89k ⌀ | instruction stringlengths 19 1.5k ⌀ | input stringlengths 0 800 ⌀ | output stringlengths 1 2.5k ⌀ |
|---|---|---|---|
[DE Wikipedia] Krogh Island
Krogh Island ist eine 8 km lange Insel westlich der Antarktischen Halbinsel. Sie gehört zu den Biscoe-Inseln und liegt unmittelbar westlich des südlichen Abschnitts der Lavoisier-Insel. Sie begrenzt den Lewis Sound nach Norden und die Wladigerow-Passage nach Westen. Kartiert wurde sie anhan... | null | null | null |
null | Develop a machine learning model in Python that takes as input a set of numbers and classifies them into two categories. | [1, 2, 3, 4, 5] | # import required libraries
import numpy as np
from sklearn import preprocessing
from sklearn.neighbors import KNeighborsClassifier
# define the training data and labels
data = np.array([1, 2, 3, 4, 5]).reshape(-1, 1)
labels = np.array([0, 0, 1, 1, 1])
# preprocess the data
scaled_data = preprocessing.scale(data)
# ... |
[DE Wikipedia] Lügner
Lügner steht für: Lügner, jemand, der eine Unwahrheit spricht, siehe Lüge Lügner (Rapper) (Sascha Rossier; * 1973), Schweizer Rapper und Produzent Lügner-Paradox, philosophisches Paradoxon Der Lügner steht für: Der Lügner (Corneille), Komödie von Pierre Corneille (1644) Der Lügner (Goldoni), Komö... | null | null | null |
null | Make a script that checks if a given integer value is divisible by 3 and 5 both. | value = 10 | def check_divisible(value): """Check if value is divisible by 3 and 5.""" # check if value is divisible by 3 and 5 if value % 3 == 0 and value % 5 == 0: return True else: return False |
null | Create a web application in Django that implements a blog system. | Not applicable | # Create the project
django-admin startproject blog
# Create the application
cd blog
python manage.py startapp posts
# Add the application to the project
# Edit the settings.py file
INSTALLED_APPS = [
'posts',
# ...
]
# Create the database
python manage.py makemigrations
python manage.py migrate
# Create the mode... |
null | Suggest an appropriate way to select the last element of a given list in Python. | list[-1] | |
null | Create a program to print the multiplication table for a given number in Python. | """
Create a program to print the multiplication table for a given number in Python
"""
def multiplication_table(n):
for i in range(1, 11):
print(n, 'x', i, '=', n*i)
if __name__=="__main__":
multiplication_table(5) | |
[DE Wikipedia] Cottbuser Radstadion
Das Cottbuser Radstadion befindet sich im Stadtteil Spremberger Vorstadt der brandenburgischen Stadt Cottbus. Das Stadion liegt im Sportzentrum Cottbus, das mit weiteren Sportanlagen und einem Sportinternat zum Olympiastützpunkt Brandenburg gehört. Die Bahn ist 333,33 Meter lang und... | null | null | null |
null | Create a Python script to find the maximum and minimum numbers from a list. | list1 = [2, 3, 7, 4, 5] | maxnum = max(list1)
minnum = min(list1)
print("Maximum number is:", maxnum)
print("Minimum number is:", minnum)
#prints Maximum number is: 7 Minimum number is: 2 |
[CS Wikipedia] Martina Zvěřinová
Martina Zvěřinová, roz. Dočkalová, (* 22. července 1983 Pardubice) je česká reprezentantka v orientačním běhu. Mezi její největší úspěch patří zlatá a stříbrná medaile z juniorského mistrovství světa 2003 a 2001. V současnosti běhá za český klub OK Lokomotiva Pardubice a též za finský ... | null | null | null |
null | Print the Fibonacci sequence up to a given number in Python. | 10 | # Declare a function
def Fibonacci(num):
a = 0
b = 1
# Iterate
for i in range(num):
print(a, end=" ")
c = a + b
a = b
b = c
print()
# Print the sequence
Fibonacci(10) |
null | Debug the following JavaScript code which calculates the average of an array of integers: | arr = [2, 3, 4, 5] sum = 0 for (i = 0; i < arr.length; i++) { sum += arr[i]} average = sum / arr.length | arr = [2, 3, 4, 5] sum = 0 for (i = 0; i < arr.length; i++) { sum += arr[i]; } average = sum / arr.length; console.log(average); |
[EN Wikipedia] Kaledibi, Hani
Kaledibi () is a neighbourhood in the municipality and district of Hani, Diyarbakır Province in Turkey. It is populated by Kurds and had a population of 709 in 2022. References Neighbourhoods in Hani District Kurdish settlements in Diyarbakır Province | null | null | null |
null | Write a Python code snippet to generate two random numbers and display the larger one. | import random
rand1 = random.randint(1, 100)
rand2 = random.randint(1, 100)
if rand1 > rand2:
print(rand1)
else:
Print(rand2) | |
null | Suggest an alternative for the following code snippet which is faster and less memory intensive. | arr = [2, 3, 5, 7] result = [] for i in range(len(arr)): for j in range(i + 1, len(arr)): result.append((arr[i], arr[j])) | arr = [2, 3, 5, 7] result = [(arr[i],arr[j]) for i in range(len(arr)-1) for j in range(i+1,len(arr))] |
null | Using the following list of prime numbers, calculate their sum. | [2, 3, 5, 7, 11, 13] | The sum of the numbers in the list is 51. |
null | Convert the following recursive function to an iterative one. | def factorial(n): if n == 0: return 1 else: return n * factorial(n - 1) | def factorial(n): result = 1 for i in range(1, n + 1): result = result * i return result |
[CS Wikipedia] Pavol Poljak
Pavol Poljak (16. prosince 1911, Malá Čausa – 13. února 1983, Bratislava) byl slovenský fotograf a publicista, představitel české a slovenské fotografie od meziválečného období do 80. let 20. století. Život Fotografii se věnoval profesionálně jako komerční reportér, fotograf ve Vojenském ze... | null | null | null |
null | Create a Python program that takes a user's input and converts it into pig latin. | Not applicable | def pig_latin(word):
vowels = "aeiouy"
if word[0].lower() in vowels:
return word + "ay"
else:
return word[1:] + word[0] + "ay"
print(pig_latin("hello")) # Output: "ellohay" |
null | Write a Python program to get all possible unique subsets of a given set of numbers. | S = [1, 2, 3] | def get_subsets(S):
subsets = [[]]
for i in S:
for j in range(len(subsets)):
subsets.append(subsets[j] + [i])
return subsets
S = [1, 2, 3]
print(get_subsets(S))
# Output: [[], [1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3]] |
null | Create a Python program that scrapes data from a web page and stores the data in a spreadsheet. | Not applicable | import requests
from lxml import html
import openpyxl
# Setup the web page URL
url = 'https://example.com/data.html'
# Scrape the web page
response = requests.get(url)
html_data = html.fromstring(response.text)
# Create an Excel workbook
wb = openpyxl.Workbook()
sheet = wb.active
# Read the data from the web page a... |
null | Given a list of numbers, write a python program that finds an index of an array element and its corresponding value. | my_list = [2,4,6,8,10] | def find_index_and_value(my_list):
for i, num in enumerate(my_list):
print("Element with index %d has value %d" % (i, num))
my_list = [2,4,6,8,10]
find_index_and_value(my_list) |
null | Construct an artificial neural network in Python for solving a classification problem. This network should contain three layers. | Description of the classification task | import numpy as np
import tensorflow as tf
# Input feature set
X = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])
# Output class labels
y = np.array([[0], [1], [1], [0]])
# Define model layers
model = tf.keras.Sequential([
tf.keras.layers.Dense(2, input_dim=2, activation='relu'),
tf.keras.layers.Dense(4, activation='re... |
null | Write an SQL query to get the sum of the values in a column. | tableName: myTable columnName: myColumn | SELECT SUM(myColumn) FROM myTable |
[EN Wikipedia] Vega de Liébana
Vega de Liébana is a municipality in the province and autonomous community of Cantabria, northern Spain. See also Pico Jano References External links Official website of the municipality Municipalities in Cantabria | null | null | null |
null | Design a program in Python that takes a string as an input and checks whether all the vowels are present in the string or not. | This is a test | def check_vowels(string):
vowels = ['a','e','i','o','u']
for vowel in vowels:
if vowel not in string:
return False
return True
print(check_vowels('This is a test')) |
null | Create a Python script to print the 3rd element in a given list. | [1,2,3,4,5,6] | list = [1,2,3,4,5,6] print(list[2]) # Output: 3 |
null | Write a code that takes in a list of names and creates a dictionary with the names as keys and their lengths as values. | names = ["Mary", "John", "Mike"] | def name_length_dict(names): name_length_dict = dict() for name in names: name_length_dict[name] = len(name) return name_length_dict name_length_dict(names) |
null | Convert this program from procedural to object-oriented. | def calculate_mortgage(principle, years, rate): # calculation return monthly_payment def calculate_interest_rate(value): # calculation return interest_rate | class MortgageCalculator: def __init__(self, principle, years, rate): self.principle = principle self.years = years self.rate = rate def calculate_mortgage(self): # calculation return monthly_payment def calculate_interest_rate(self, value): # calculation return interest_rate |
null | Create a Python program that displays a table of results based on user input. | Inputs for the table are scale (integer) and input values (list of integers) | scale = int(input('Input scale: '))
values = list(map(int, input('Input values: ').split()))
def print_table(scale, values):
for v in values:
print(f'{v:>{scale}}', end='\t')
print()
for v in values:
print(f'{v**2:>{scale}}', end='\t')
print()
for v in values:
print(f'{v**3:... |
null | Create a CSS program that formats the text in a paragraph so that it has the following characteristics: font size is 2em, font weight is bold, font color is orange. | p { font-size: 2em; font-weight: bold; color: orange; } | |
[HI Wikipedia] दीवारकला
दीवारकला या ग्रफ़ीटी (graffiti) दीवारों पर बनी लिखाईयों और चित्रों को कहते हैं। यह एक प्रकार की जनकला है और अक्सर ग़ैर-क़ानूनी होती है। दीवारकला के उदहारण प्राचीन मिस्र के ज़माने से ही मिलते आ रहें हैं। दीवारकला चिह्नों और साधारण लिखाईयों से लेकर विस्तृत तस्वीरों का रूप ले सकती है Iआज के आधुनिक... | null | null | null |
null | Generate an appropriate Python program to calculate the future value of an investment with the given principal, rate of interest and years. | Principal: 10000
Rate of interest: 10
Years: 5 | # Calculate the Future Value of an Investment
def future_value(principal, rate, years):
# Calculate the total amount
total_amount = principal * (1+(rate/100))**years
# return the future value
return round(total_amount,2)
# Testing
print(future_value(10000,10,5)) |
null | Implement a function to calculate the sum of digits of a given positive integer. | def sum_digits(n): total = 0 while n: total += n % 10 n //= 10 return total | |
null | Write a Python program to exchange the values of two different variables. | x = 10 y = 20 | x, y = y, x |
null | Implement Bubble Sort using Python. | [6, 2, 5, 1, 8] | def bubble_sort(arr):
for i in range(len(arr)):
for j in range(len(arr)-1-i):
if arr[j] > arr[j+1]:
temp = arr[j]
arr[j] = arr[j+1]
arr[j+1] = temp
arr = [6, 2, 5, 1, 8]
bubble_sort(arr)
print(arr) |
null | Develop a query in SQL to display all columns from a table named 'products' with a product price greater than 10. | SELECT * FROM products WHERE price > 10; | |
null | Create a Python program to detect if a given string contains an anagram of a given substring. | string: "listen"
substring: "silent" | def isAnagramSubstring(string, substring):
if len(substring) > len(string):
return False
chars = {}
for char in string[:len(substring)]:
if char in chars:
chars[char] += 1
else:
chars[char] = 1
for char in substring:
if char not in chars or char... |
null | Create an if statement that prints "Fizz" if a number is divisible by 3 and "Buzz" if a number is divisible by 5. | if (num % 3 == 0 && num % 5 == 0) { console.log("FizzBuzz"); } else if (num % 3 == 0) { console.log("Fizz"); } else if (num % 5 == 0) { console.log("Buzz"); } | |
[EN Wikipedia] Oreste Crisostomi
Oreste Crisostomi (born 21 August 1982), is an Italian filmmaker. He is particularly known as the writer and artistic director of the critically acclaimed documentary Fuori fuoco (Out of focus). Personal life He was born and raised in Terni. Since 2011, he has been carrying out constan... | null | null | null |
[CS Wikipedia] Vladimir Varankin
Vladimir Valentinovič Varankin (12. listopadu 1902 Nižnij Novgorod – 3. října 1938) byl ruský historik a esperantista. Je autorem filologického díla Teorio de esperanto; významný je jeho velký původní román Metropoliteno. Život a esperantská činnost Narodil se v roce 1902 v Nižním Novg... | null | null | null |
null | Write a code for concatenating two arrays. | Array1: [1,2,3] Array2: [4,5,6] | def concat_arrays(arr1, arr2): return arr1 + arr2 print(concat_arrays([1,2,3], [4,5,6])) Output: [1, 2, 3, 4, 5, 6] |
[CS Wikipedia] Bachmačská pamětní medaile
Bachmačská pamětní medaile je pamětní medaile zřízená 5. března 1948 jako připomínka třicátého výročí bitvy u Bachmače (březen 1918). Vznikl usnesením vlády, které bylo uveřejněno ve Věstníku ministerstva národní obrany č. 19 ze dne 13. března 1948. Medaile je bronzová podle n... | null | null | null |
[DE Wikipedia] Jaruco
Jaruco ist ein Municipio und eine Stadt in der kubanischen Provinz Mayabeque. Bis 2010 gehörte das Municipio zur aufgelösten Provinz La Habana. Sie wurde 1762 von Spaniern als Ciudad Condal de San Juan Bautista de Jaruco gegründet und hat ca. 20.400 Einwohner (Stand: 2003). Die Stadt liegt landei... | null | null | null |
[HI Wikipedia] युगाण्डा
युगांडा गणराज्य पूर्वी अफ्रीका में स्थित एक स्थलरुद्ध देश है। इसकी सीमा पूर्व में केन्या, उत्तर में सूडान, पश्चिम में कांगो लोकतान्त्रिक गणराज्य, दक्षिण पश्चिम में रवांडा और दक्षिण में तंजानिया से मिलती है। देश के दक्षिणी हिस्से में विक्टोरिया झील का एक बड़ा भाग शामिल है, जिससे केन्या और तंजानि... | null | null | null |
[EN Wikipedia] Tapu River
The Tapu River (Waipatukahu Stream prior to 1974) is a river of the Coromandel Peninsula in New Zealand's North Island. It flows west from the Coromandel Range, reaching the Firth of Thames at the settlement of Tapu, approximately halfway between Thames and Coromandel. Except for ammoniacal n... | null | null | null |
null | Design a function to convert Fahrenheit to Celsius in Python. | def fahrenheit_to_celsius(f): celsius = (f - 32) * 5/9 return celsius | |
null | Generate a Python program for converting temperatures from Celsius to Fahrenheit. | 15 degree Celsius | # Take input from user
c = float(input('Enter temperature in Celsius: '))
# Compute temperature in Fahrenheit
f = (c * 1.8) + 32
# Print the result
print('{} degree Celsius is equal to {} degree Fahrenheit.'.format(c, f)) |
null | Modify the C++ program below to print the average value of an array. | int array[4] = {2, 3, 5, 7}; | #include <iostream> int main() { int array[4] = {2, 3, 5, 7}; int sum = 0; for(int i = 0; i < 4; i++) { sum += array[i]; } double avg = (double)sum / 4; std::cout << "Average value of array : " << avg; return 0; } |
null | Write a query to select the first 3 characters of every row from a column called 'name' from a PostgreSQL table. | SELECT SUBSTRING(name, 1, 3) FROM table_name; | |
null | Perform PCA on a dataset. | from sklearn.decomposition import PCA def perform_pca(X): pca = PCA(n_components=2) pca.fit(X) X_pca = pca.transform(X) return X_pca | |
null | Design a text-based game in C++ in which the player can move around the game world. | #include <iostream> #include <string> std::string room_name; int player_position_x = 0; int player_position_y = 0; void move_player(int x, int y) { player_position_x += x; player_position_y += y; room_name = get_room_name(player_position_x, player_position_y); std::cout << "Moved to " << room_name << std::endl; } std::... | |
[DE Wikipedia] Chwalibożyce
Chwalibożyce ( Frauenhain) ist ein Dorf in Niederschlesien. Der Ort liegt in der Gmina Oława im Powiat Oławski in der polnischen Woiwodschaft Niederschlesien. Geographie Geographische Lage Das Angerdorf Chwalibożyce liegt neun Kilometer südlich des Gemeindesitzes und der Kreisstadt Oława (O... | null | null | null |
null | Write a PowerShell script to print out the current date. | Get-Date | Format-List | |
null | Using the heapsort algorithm, sort the following array of numbers in ascending order. | [97,54,67,8,2,22,5,47] | [2, 5, 8, 22, 47, 54, 67, 97] |
null | Create a Python function that takes two arguments: a number and an alphabet, and returns a list of strings composed of the alphabet each with the supplied length. | alphabet = 'ABCDE'
length = 3 | def generate_strings(alphabet, length):
lst = []
for a in alphabet:
for b in alphabet:
for c in alphabet:
s = a + b + c
lst.append(s)
return lst
result = generate_strings(alphabet, length)
print(result) |
[CS Wikipedia] Lobau
Lobau je údolní niva nacházející se na levém břehu Dunaje východně od rakouského hlavního města Vídně. Území o rozloze 23 km² je administrativně rozděleno mezi vídeňský obvod Donaustadt a město Groß-Enzersdorf. Lobau je tvořeno lužním lesem a sítí vodních kanálů. Nejrozšířenějším stromem je dub le... | null | null | null |
null | Build a function in Python to output a list of the first n Fibonacci numbers. | def Fibonacci(n):
# Taking 1st two Fibonacci numbers as 0 and 1
FibArray = [0, 1]
for i in range(2, n):
FibArray.append(FibArray[i-2] + FibArray[i-1])
return FibArray[:n]
print(Fibonacci(7)) # [0, 1, 1, 2, 3, 5, 8] | |
[CS Wikipedia] Václav Havel
Václav Havel (5. října 1936 Praha – 18. prosince 2011 Vlčice-Hrádeček) byl český dramatik, esejista, disident a kritik komunistického režimu, později politik a státník. Byl devátým a posledním prezidentem Československa (1989–1992) a prvním prezidentem České republiky (1993–2003). Václav Ha... | null | null | null |
null | How do you convert a string to an integer in Python? | In Python, strings can be converted to integers using the int() function. This function takes a string as its argument and returns an integer object. The int() function can also take optional parameters that allow for conversion from one base or radix, or from different types of numbers (e.g. octal, hexadecimal, binary... | |
null | Create a list in Python of all integers from -5 to 10. | list_nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
null | You need to find all the words in a given sentence sorted by their length. | I like to read books | def sortByLength(sentence): words = sentence.split(' ') sortedWords = sorted(words, key=len) return sortedWords |
[EN Wikipedia] Pahi River
The Pahi River is a river of the Northland Region of New Zealand's North Island. It flows generally west from its origins southwest of Maungaturoto, and the last few kilometres of its length form an upper silty arm of the Kaipara Harbour. It forms one of the arms of the Arapaoa River, in the ... | null | null | null |
[EN Wikipedia] Balestrini
Balestrini is an Italian surname. Notable people with the surname include: Alberto Balestrini (born 1931), Argentine fencer Alberto Balestrini (1947–2017), Argentine politician Carlo Balestrini (1868–1922), Italian painter Carlos Balestrini (1880–1972), Argentine sport shooter Giulio Balestri... | null | null | null |
null | Write a function that takes an array of numbers and returns an array whose elements are the product of all the elements except the element at the current index. | arr = [2, 3, 4, 5] | def get_products(arr): left = [1] right = [1] ans = [] # Traverse from left to right for i in range(1, len(arr)): left.append(arr[i-1] * left[i-1]) # Traverse from right to left for i in reversed(range(len(arr)-1)): right.insert(0, arr[i+1] * right[0]) # Compute the product of all elements except itself for i in range(... |
null | Unwrap the function parameter with default argument. | def func(arg1, arg2="default"): pass | def func(arg1, arg2): if arg2 is None: arg2 = "default" pass |
null | Given a list of numbers, find the minimum and maximum elements. | [3, 4, 8, 1, 5, 0, 9] | min_el = 0 max_el = 9 |
null | Modify the following code to print all words with more than 5 characters in a given string. | text = "This is an example string" | text = "This is an example string" words = text.split() for word in words: if len(word) > 5: print(word) |
null | Write an algorithm in JavaScript to print all the elements inside a given array. | var names = ["Harry", "Ron", "Hermione"] | for (var i = 0; i < names.length; i++) { console.log(names[i]); } |
null | Develop a program to remove an element from a list at the specified index. | my_list = [4, 5, 6, 7] index = 2 | def remove_at_index(my_list, index): del my_list[index] return my_list |
null | Convert the following SQL query into a python pandas dataframe. | SELECT * from books WHERE author LIKE '%Rowling%'; | import pandas as pd
# read the books table
df = pd.read_sql("SELECT * from books", connection)
# filter for rows with matching author
df_filtered = df[df['author'].str.contains("Rowling")]
# print the results
print(df_filtered) |
null | Write a Java program to read input from the console. | import java.util.Scanner; class UserInput { public static void main(String[] args) { Scanner read = new Scanner(System.in); System.out.print("Enter some string: "); String inputString = read.nextLine(); System.out.println("You have entered: " + inputString); } } | |
null | Generate a Python program that produces a spiral matrix with the specified number of rows and columns. | Row count: 9
Column count: 6 | def spiral_matrix(num_rows, num_columns):
matrix = [[0] * num_columns for row in range(num_rows)]
stride = [(1, 0), (0, 1), (-1, 0), (0, -1)]
direction = 0
x, y = 0, 0
val = 1
while 0 <= x < num_rows and 0 <= y < num_columns:
matrix[x][y] = val
x += stride[direction][0]
... |
null | Write a function to convert a 3 letter acronym to its full form. | Acronym: "GDP" | """ Convert a 3 letter acronym to its full form """ def acronym_to_full_form(acronym): acronyms = { 'GDP': 'Gross Domestic Product', 'CIA': 'Central Intelligence Agency', 'NASA': 'National Aeronautics and Space Administration' } return acronyms[acronym] if __name__ == '__main__': acronym = "GDP" print(acronym_to_full_f... |
null | Construct a regular expression to extract all words from a given string that start with a specific letter. | input_str = "The quick brown fox jumped over the lazy dog" | var regex = /\b[qQ]\w+\b/g; var result = input_str.match(regex); console.log(result); //['quick'] |
null | Complete the following HTML template with appropriate tags: | <html> <head> </head> <body> </body> </html> | <html> <head> <title> Title of page </title> </head> <body> <h1> Header title </h1> <p> This is a sample content of a web page. </p> </body> </html> |
[DE Wikipedia] Mahaney
Mahaney ist der Familienname der folgenden Personen: Kevin Mahaney (* 1962), US-amerikanischer Segler William Mahaney (* 1941), US-amerikanischer Geograph und Geologe | null | null | null |
[EN Wikipedia] Sourcebooks (publisher)
Sourcebooks LLC is an American independent book publisher located in Naperville, Illinois. The company publishes books, eBooks, and digital products. History The company was founded in 1987 by Dominique Raccah as a business and finance publisher. Raccah cashed in $17,000 from her... | null | null | null |
[HI Wikipedia] अल्बानिया
अल्बानिया गणराज्य (अल्बानियाई: Republika e Shqipërisë) उत्तरपूर्वी यूरोप में स्थित एक देश है। इसकी भू सीमाएं उत्तर में कोसोवो, उत्तर पश्चिम में मोन्टेनेग्रो, पूर्व में भूतपूर्व यूगोस्लाविया और दक्षिण में यूनान से मिलती हैं। तटीय सीमाएं दक्षिण पश्चिम में आड्रियाटिक सागर और आयोनियन सागर से मिलती... | null | null | null |
null | Display a chart on the page to show the data. | <div id="chartContainer"></div> <script> var chart = new CanvasJS.Chart("chartContainer", { //Options }); chart.render(); </script> | |
null | Write a Python program to perform a merge sort on given numbers. | def merge_sort(nums):
if len(nums) > 1:
mid_index = len(nums) // 2
left_half = nums[:mid_index]
right_half = nums[mid_index:]
merge_sort(left_half)
merge_sort(right_half)
i = j = k = 0
while i < len(left_half) and j < len(right_half):
if left_ha... | |
null | Write a function in Java to find the element that appears most frequently in the array. | [9, 5, 1, 0, 4, 5, 9, 2, 8] | public static int mostFrequentElement(int[] arr) { int count = 0; int maxCount = 0; int mostFrequent = arr[0]; for (int i = 0; i < arr.length; i++) { count = 0; for (int j = 0; j < arr.length; j++) { if(arr[i] == arr[j]) { count++; } if (count > maxCount) { maxCount = count; mostFrequent = arr[i]; } } } return mostFreq... |
[HI Wikipedia] हरिनारायण
हरिनारायण नाम के दो हिन्दी कवि हुए हैं - एक हरिनारायण मिश्र और दूसरे हरिनारायण। (१) हरिनारायण बेरी (जिला मथुरा) के निवासी थे। 'बारहमासी' और 'गोवर्धनलीला' खोज में इनकी दो रचनाएँ उपलब्ध हुई हैं। 'बारहमासी' में कांता प्रत्येक मास में होनेवाले दु:खों का वर्णन कर अपने पति को प्रवास जाने से रोकती है... | null | null | null |
null | Create a function that examines the character and determines if it's an uppercase letter or not. | def is_uppercase(character): if character.isalpha and character.isupper(): return True else: return False | |
null | Create a class in Java for a Person object with two fields, name and age. | public class Person { private String name; private int age; public Person(String name, int age) { this.name = name; this.age = age; } public String getName() { return name; } public int getAge() { return age; } } | |
null | Change the Python code to output the product of two numbers. | def multiply(a, b): return a + b | def multiply(a, b): return a * b |
[EN Wikipedia] Pararrhaptica trochilidana
Pararrhaptica trochilidana is a moth of the family Tortricidae. It was first described by Lord Walsingham in 1907. It is endemic to the Hawaiian island of Molokai. External links Archipini Endemic moths of Hawaii | null | null | null |
null | Edit the following Java code to create a method which will calculate the area of a rectangle, given its width and length. | public class Rectangle { private double width; private double length; | public class Rectangle { private double width; private double length; public double calculateArea() { return width * length; } } |
null | Generate an appropriate Python command to edit the following list such that all the negative numbers are replaced with 0. | [-1, 5, 9, -8, 2] | def filter_negative(nums):
return [max(0, n) for n in nums] |
[DE Wikipedia] Built to Last (Grateful-Dead-Album)
Built to Last ist das dreizehnte und letzte Studioalbum der Band Grateful Dead. Geschichte Das Album wurde zwischen dem 1. Februar und dem 20. Oktober 1989 aufgenommen und am 31. Oktober 1989 über das Label Arista Records veröffentlicht. Mit allen anderen Livealben un... | null | null | null |
[CS Wikipedia] Imambayildi
İmam bayıldı (v překladu Imám omdlel, Imám v bezvědomí) je turecké jídlo z lilku, oblíbené na celém Blízkém východě. Je pojmenováno podle historky o imámovi, který při vychutnávání pokrmu nadšením ztratil vědomí (to souvisí s obrazem imáma v lidové slovesnosti jako člověka, který druhé nabád... | null | null | null |
[CS Wikipedia] Mjory
Mjory (, – Miory, , ) je město ve Vitebské oblasti v Bělorusku, správní středisko Mjorského rajónu. K roku 2017 ve městě žilo zhruba osm tisíc obyvatel. Poloha a doprava Mjory leží přibližně 190 kilometrů severozápadně od Vitebsku, správního střediska oblasti, a zhruba 245 kilometrů severně od Min... | null | null | null |
null | Define a function in Python to check if a number is even. | def is_even(num):
if num % 2 == 0:
return True
else:
return False | |
null | Create a function to take in a given array, rotate it by one, so that the last element of the array is now the first element. | [1, 2, 3, 4, 5] | def rotate_list(arr): length = len(arr) temp = arr[length - 1] for i in range(length-1, 0, -1): arr[i] = arr[i-1] arr[0] = temp return arr my_list = [1, 2, 3, 4, 5] print(rotate_list(my_list)) #Output: [5, 1, 2, 3, 4] |
null | Formulate a Python code for calculating the Levenshtein distance for two strings. | def calculateLevenshteinDistance(str1, str2):
n = len(str1)
m = len(str2)
# Create a matrix to store results
dp = [[0 for x in range(m + 1)] for x in range(n + 1)]
# Initialize the first row and column with the difference of lengths
for i in range(n + 1):
for j in range(m + 1):
... | |
null | Create a python script to read a JSON object and print out its values. | {
"name": "Adam",
"age": 24,
"city": "New York"
} | import json
data = json.loads('{ "name": "Adam", "age": 24, "city": "New York" }')
print("Name: ", data['name'])
print("Age: ", data['age'])
print("City: ", data['city']) |
null | Create a Python script to pre-process a given corpus and vectorize it for usage as features in a machine learning problem. | import numpy as np
from sklearn.feature_extraction.text import CountVectorizer
def vectorize_corpus(corpus):
# Initialize the CountVectorizer
vectorizer = CountVectorizer()
# Fit the corpus
X = vectorizer.fit_transform(corpus)
# Convert the sparse matrix to numpy array
X = X.toarray()
# Ret... | |
null | Code a function in Python that takes a list of integers (denoted by `lst`) and returns a list of booleans where each element of the output list is `True` if the corresponding element in the input list is a prime number, and `False` otherwise. | lst = [7, 8, 12, 19, 22, 23] | def is_prime(n):
# check if n is divisible by any of the numbers
# between 2 and n-1
for i in range(2, n):
if n % i== 0:
return False
return True
def check_lst(lst):
# generate a list of booleans
# where each element corresponds to the corresponding
# element of lst
result_lst = []
for i in range(len(lst... |
null | Implement a non-recursive algorithm to compute the factorial of a given number | 7 | def factorial(n): res = 1 # Calculate value of # factorial in for loop for i in range(2,n+1): res = res * i return res n = 7 print("Factorial of",n,"is",factorial(n)) |
null | Find the maximum of three numbers using a Python function. | a = 10, b = 5, c = 20 | def maximumOfThreeNumbers(a, b, c):
if (a >= b) and (a >= c):
return a
elif (b >= a) and (b >= c):
return b
else:
return c
maximum = maximumOfThreeNumbers(10, 5, 20)
print("The maximum number is:", maximum) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.