text stringlengths 141 2.89k ⌀ | instruction stringlengths 19 1.5k ⌀ | input stringlengths 0 800 ⌀ | output stringlengths 1 2.5k ⌀ |
|---|---|---|---|
null | Create a while loop that prints the numbers 1-10 | i = 1 while i <= 10: print(i) i += 1 | |
null | Propose a solution to fetch an online catalog of products and display them in a tabular format using Python. | Catalog consisting of 1000 products | import requests
import pandas as pd
# Set the request URL
url = "http://example.com/products"
# Send the request and retrieve the data
data = requests.get(url).json()
# Convert the data into a pandas DataFrame
df = pd.DataFrame(data)
# Print the resulting table
print(df) |
null | Write a code that uses a for-loop to print out the elements of the following array: | my_list = [1,2,3,4] | for element in my_list: print(element) |
[EN Wikipedia] The Sketch
The Sketch was a British illustrated weekly journal. It ran for 2,989 issues between 1 February 1893 and 17 June 1959. It was published by the Illustrated London News Company and was primarily a society magazine with regular features on royalty, aristocracy and high society, as well as theatr... | null | null | null |
null | Create a web scraper in Python to scrape the content from a website | Website URL: https://www.example.com | import requests
from bs4 import BeautifulSoup
def scraper(url):
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
for article in soup.find_all('article'):
print(article.text)
if __name__ == "__main__":
scraper("https://www.example.com") |
[HI Wikipedia] पुणे
पुणे भारत के महाराष्ट्र राज्य का एक महत्त्वपूर्ण शहर है। पुणे भारत का छठवां सबसे बड़ा शहर व महाराष्ट्र का दूसरा सबसे बड़ा शहर है।. यह शहर महाराष्ट्र के पश्चिम भाग, मुला व मुठा इन दो नदियों के किनारे बसा है और पुणे जिला का प्रशासकीय मुख्यालय है। सार्वजनिक सुखसुविधा व विकास के हिसाब से पुणे महाराष्ट्... | null | null | null |
null | Write a HTML tag that creates a hyperlink to a given URL. | https://www.example.com | <a href="https://www.example.com">[Link text]</a> |
null | Create a Python function to calculate the sum of the list elements. | [1, 3, 4, 7, 9] | def list_sum(list_in):
return sum(list_in)
# or
def list_sum(list_in):
total_sum = 0
for num in list_in:
total_sum += num
return total_sum |
null | Construct a SQL query to list the unique countries from table countries. | SELECT DISTINCT country FROM countries; | |
null | Write a code which generates the Fibonacci sequence. | """ Write a code which generates the Fibonacci sequence """ def generate_fibonacci_sequence(n): a = 0 b = 1 if n == 1: print(a) else: print(a) print(b) for i in range(2,n): c = a + b a = b b = c print(c) if __name__ == '__main__': n = 9 generate_fibonacci_sequence(n) | |
null | Write a PHP program to build a dynamic HTML table with the details of 10 students. | $students = [ [ 'name' => 'John Doe', 'age' => 22, 'marks' => 91 ], [ 'name' => 'Jane Doe', 'age' => 21, 'marks' => 87 ], // ... ]; $html = "<table> <tr> <th>Name</th> <th>Age</th> <th>Marks</th> </tr>"; foreach ($students as $student) { $html .= "<tr> <td>{$student['name']}</td> <td>{$student['age']}</td> <td>{$studen... | |
null | Explain how to implement a heap sort algorithm in Java. | // To implement a heap sort algorithm in Java: // 1. Build a min heap from the input data. // 2. At the top of the heap, obtain the minimum element. // 3. Exchange the minimum element with the last element of the heap. // 4. Reduce the size of the heap by one and heapify the root of the heap. // 5. Repeat steps 2-4 unt... | |
[DE Wikipedia] Ernst-Volker Staub
Ernst-Volker Wilhelm Staub (* 30. Oktober 1954 in Hamburg; Aliasnamen: Robert Hagen, Rolf Krause, Ulrich Schulte und weitere) ist ein Terrorist der Rote Armee Fraktion (RAF). 1986 wurde er zu einer Freiheitsstrafe von vier Jahren verurteilt. Nach Staub wird wegen Beteiligung an dem Sp... | null | null | null |
[DE Wikipedia] Katharinenkloster
Ein Katharinenkloster, das auf eine der Heiligen Katharinas zurückgeht, gibt es in: Deutschland Katharinenkloster Augsburg, ehemaliges Dominikanerinnenkloster Kloster Sankt Katharinen (bei Bad Kreuznach) St.-Katharinen-Kloster (Bremen) ehemaliges Katharinenkloster Dortmund Katharinenkl... | null | null | null |
null | Implement a sorting algorithm for a given array in Python. | [3, 2, 1, 4] | sorted_array = [1, 2, 3, 4] def SortArray(array): for i in range(len(array)): for j in range(len(array) - i - 1): if array[j] > array[j + 1]: array[j], array[j + 1] = array[j + 1], array[j] return array sorted_array = SortArray(array) |
null | Construct an SQL query to select all the unique values of one column from a table that appear more than twice. | column_name: 'gender' | SELECT gender FROM table_name GROUP BY gender HAVING COUNT(*) > 2; |
null | Modify the following function to print out the 'type' of each argument. | def print_args(arg1, arg2): print("Arg 1: %s" % arg1) print("Arg 2: %s" % arg2) | def print_args(arg1, arg2): print("Arg 1: %s" % str(type(arg1))) print("Arg 2: %s" % str(type(arg2))) print("Arg 1: %s" % arg1) print("Arg 2: %s" % arg2) |
[HI Wikipedia] भूटान के १० बड़े नगरों की सूची
यह भूटान के नगरों की सूची है। 1-नगर :थिम्फू नगर की जनसंख्या :98,676 जिले का नाम:थिम्फू 2-नगर :पुनाखा नगर की जनसंख्या :21,500 जिले का नाम :पुनाखा 3-नगर :तसिरंग (Tsirang) नगर की जनसंख्या :18,667 जिले का नाम:चिरांग 4-नगर :फुंतशोलिंग नगर की जनसंख्या :17,043 जिले का नाम: चूखा 5... | null | null | null |
null | Create a Python function to search for a substring in a string. The function should take two arguments, the haystack string and the needle string, and should return a boolean indicating whether the substring was found or not. | haystack: "This is a string"
needle: "is" | def contains_substring(haystack, needle):
return needle in haystack
# Usage example
contains_substring("This is a string", "is") # returns True
contains_substring("This is a string", "xyz") # returns False |
[EN Wikipedia] Army Institute of Business Administration, Sylhet
Army Institute of Business Administration (Army IBA), Sylhet, is a government military business school run by the Bangladesh Army located at Jalalabad Cantonment, Sylhet. As the institute is affiliated with the Bangladesh University of Professionals (BUP... | null | null | null |
null | Write a SQL command to get a list of customers with order total greater than 500. | TABLE customers { id INT, name VARCHAR(90), orders TOTAL DEC(10,2) } | SELECT name FROM customers WHERE orders > 500; |
null | Design a function in Python that takes a string, replaces all occurrences of the word "dog" with "cat" and returns the modified string. | "I love my dog" | def replace_word(string):
modified_string = string.replace("dog", "cat")
return modified_string
result = replace_word("I love my dog")
print(result) |
null | Write an HTML tag for a hyperlink pointing to https://www.example.com | <a href="https://www.example.com">Link</a> | |
[HI Wikipedia] हम होंगे कामयाब
हम होंगे कामयाब ( का गिरिजा कुमार माथुर द्वारा किया गया हिंदी भावानुवाद) एक प्रतिरोध गीत है। यह गीत बीसवीं सदी में नागरिक अधिकार आंदोलन का प्रधान स्वर बना। इस गीत को आमतौर पर "I'll Overcome Some Day" ("आई विल ओवरकम सम डे") से काव्यावतरित माना जाता है, जो चार्ल्स अल्बर्ट टिंडले द्वारा गाय... | null | null | null |
[DE Wikipedia] Johann Wilhelm Neumann
Johann Wilhelm Neumann (* 25. Februar 1797 in Lübben; † 16. April 1870 ebenda) war ein deutscher Jurist, Kommunalpolitiker und Historiker. Leben und Werk Der älteste Sohn des Lübbener Bürgermeisters Martin Karl Andreas Neumann (* 23. Juli 1755; † 12. April 1824) besuchte ab 1809 d... | null | null | null |
[CS Wikipedia] Farní sbor Českobratrské církve evangelické v Moravči
Farní sbor Českobratrské církve evangelické v Moravči je sborem Českobratrské církve evangelické v Moravči. Sbor spadá pod Horácký seniorát. Farářem sboru je Daniel Matějka ml. a kurátorem Daniel Trefil. Faráři sboru Jan Szalatnay st. (1783–1827) Jan... | null | null | null |
null | Generate a Python source code to print the last element from a given list. | ['Apple', 'Orange', 'Banana'] | arr = ['Apple', 'Orange', 'Banana']
last_element = arr[-1]
print(last_element) # Result: Banana |
null | Create a function in Python that takes a list of strings and replaces each string with its length. | ["apple", "banana", "mango"] | def length_strings(string_list):
new_list = []
for string in string_list:
new_list.append(len(string))
return new_list
print(length_strings(["apple", "banana", "mango"])) # [5, 6, 5] |
null | Add 10 to the last element of a given array. | [1, 2, 3, 4] | arr = [1, 2, 3,4] arr[-1] += 10 print(arr) |
null | Build a machine learning model in Python to classify animals. | #import libraries
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
#import dataset
data = load_iris()
#divide the data into independent and dependent variables
X = data.data
y = data.target
# Split the data ... | |
null | Create a Python function that reorders an integer array using the Bubble Sort algorithm. | arr = [2, 3, 1, 5, 9] | def bubble_sort(arr):
# Traverse through all array elements
for i in range(len(arr)):
# Last i elements are already in place
for j in range(0, len(arr)-i-1):
# traverse the array from 0 to n-i-1
# Swap if the element found is greater
# than the next element
if arr[j] > arr[j+1] :
arr[j], arr[... |
null | Write a JavaScript code to filter an array of strings that begin with the letter `A` and have a length of 5. | let arr = ["Apple", "Banana", "Ant", "Cat", "Arson"]; | let result = arr.filter(str => str[0] === 'A' && str.length === 5); |
[CS Wikipedia] Delegace pro přijetí mezinárodního jazyka
Delegaci pro přijetí mezinárodního jazyka založili 17. ledna 1901 v Paříži francouzští profesoři Louis Couturat a Léopold Leau. Cílem Delegace byl výběr nejperspektivnějšího z tehdy již více než tří set projektů mezinárodního jazyka. Mezinárodní svaz akademií te... | null | null | null |
null | Create a 3x3 rotation matrix with an angle of 45 degrees. | [[0.7071, -0.7071, 0.0], [0.7071, 0.7071, 0.0], [0.0, 0.0, 1.0]] | |
[HI Wikipedia] मिताक्षरा
मिताक्षरा याज्ञवल्क्य स्मृति पर विज्ञानेश्वर की टीका है जिसकी रचना 11वीं शताब्दी में हुई। यह ग्रन्थ 'जन्मना उत्तराधिकार' (inheritance by birth) के सिद्धान्त के लिए प्रसिद्ध है। हिंदू उत्तराधिकार संबंधी भारतीय कानून को लागू करने के लिए मुख्य रूप से दो मान्यताओं को माना जाता है- पहला है दायभाग म... | null | null | null |
null | Build a sentiment analysis system in Python. The system should take an input text and return its positivity, negativity, or neutral score. | Not applicable | import nltk
from nltk.sentiment.vader import SentimentIntensityAnalyzer
def sentiment_analysis(text):
# split the sentences
sentences = nltk.sent_tokenize(text)
# create a sentiment analyzer object
sid = SentimentIntensityAnalyzer()
sentiment_scores = []
for sentence in sentences:
# ge... |
null | Create a MySQL table with three columns containing values from a given list. | List: Tom, 14, 80 Mary, 27, 96 John, 8, 75 | CREATE TABLE my_table ( name TEXT NOT NULL, age INT NOT NULL, score INT NOT NULL ); INSERT INTO my_table (name, age, score) VALUES ('Tom', 14, 80), ('Mary', 27, 96), ('John', 8, 75); |
null | Write a Python program to find all numbers divisible by 5 but not a multiple of 7, between 1500 and 2700 (both included). | result = [] for i in range(1500, 2701): if i % 5 == 0 and i % 7 != 0: result.append(i) print(result) # [1505, 1540, 1575, 1610, 1645, 1680, 1715, 1750, 1785, 1820, 1855, 1890, 1925, 1960, 1995, 2030, 2065, 2100, 2135, 2170, 2205, 2240, 2275, 2310, 2345, 2380, 2415, 2450, 2485, 2520, 2555, 2590, 2625, 2660, 2695] | |
[DE Wikipedia] Reinhold Köhler
Reinhold Köhler (* 24. Juni 1830 in Weimar; † 15. August 1892 ebenda; auch Reinhold Koehler) war ein deutscher Literaturhistoriker und Bibliothekar. Köhler war der oberste Bibliothekar an der Großherzoglichen Bibliothek in Weimar. Leben Köhler war der Sohn des Hofpredigers Ernst Friedric... | null | null | null |
[HI Wikipedia] गिस्बॉर्न
गिस्बॉर्न न्यूज़ीलैण्ड के उत्तर-पूर्व में स्थित एक शहर है। यह गिस्बॉर्न क्षेत्र का सबसे बड़ा शहर है। इसकी आबादी 34,400 है। शहर को अपना यह नाम औपनिवेशिक सचिव विलियम गिस्बॉर्न के नाम से मिला है। इन्हें भी देखें गिस्बॉर्न क्षेत्र उत्तर द्वीप सन्दर्भ न्यूज़ीलैण्ड के आबाद स्थान गिस्बॉर्न क्षेत्र | null | null | null |
null | Test if a given number is a Prime or not using Python. | number = 32 | if number<=1:
print("Number is not a prime number.")
for i in range(2,int(number**0.5)+1):
if(number % i == 0):
print("Number is not a prime number.")
break
else:
print("Number is a prime number.") |
[CS Wikipedia] Teplota tání
Teplota tání je teplota, při níž krystalická pevná látka přechází ze skupenství pevného do skupenství kapalného. U amorfních látek (sklo, parafín) nelze tuto hranici určit přesně (teplota tuhnutí). Značení Značka: tt Základní jednotka: kelvin, značka K Další jednotky: viz teplota Příklady t... | null | null | null |
null | Create a function to check if a given triangle is an equilateral triangle. | a = 5, b = 5, c = 5 | def isEquilateral(a, b, c): if (a == b == c): return True else: return False isEquilateral(a, b, c) # returns True |
[HI Wikipedia] मोनोट्रीम
मोनोट्रीम (monotreme, अर्थ: एकविदर) या अंडजस्तनी स्तनधारी प्राणियों का एक जीववैज्ञानिक गण (ऑर्डर) है, जिसमें अब दो ही प्रकार के जंतु जीवित हैं। यह अण्डे देते हैं लेकिन फिर जन्मने वाले शिशु को माता के स्तन से दूध पिलाते हैं। आधुनिक जगत में मोनोट्रीम की पाँच जातियाँ अस्तित्व में हैं जिनमें से एक... | null | null | null |
[DE Wikipedia] Splint-Boots
Splint-Boots sind „Schoner“ für die Beine von Pferden. Die deutsche Bezeichnung ist Gamaschen. Splint-Boots werden besonders im Westernreitsport verwendet, damit die Pferde bei Übungen wie z. B. Sliding Stops (das Pferd bremst abrupt mit den Hinterbeinen aus vollem Galopp ab) keine Verletzu... | null | null | null |
null | Write a code to return the list of integers between two given numbers. | start = 5 end = 9 | def get_integer_between(start, end): return list(range(start, end + 1)) print(get_integer_between(start, end)) |
null | Generate a list of prime numbers from 1 to N in Python. | def generate_primes(n):
primes = []
for num in range(2, n+1):
prime = True
for i in range(2, num):
if (num % i) == 0:
prime = False
if prime:
primes.append(num)
return primes | |
[DE Wikipedia] Ahmed Jan Thirakwa
Ahmed Jan Thirakwa (* 1892 in Muradabad; † 13. Januar 1976 in Lakhnau, Uttar Pradesh) war ein indischer Tablaspieler. Er galt zu seinen Lebzeiten als bedeutendster Tablaspieler und gehörte zur Farukhabad-Gharana (Lehrtradition). Leben Er war der Sohn des Sarangi-Spielers Hussain Baksh... | null | null | null |
null | Generate a class that manages the customer data | The class should have attributes of customer name, address, phone number, and email address. | class CustomerData: def __init__(self, name, address, phone_number, email_address): self.name = name self.address = address self.phone_number = phone_number self.email_address = email_address def get_name(self): return self.name def get_address(self): return self.address def get_phone_number(self): return self.phone_nu... |
null | Create a Python program that uses the NumPy library to generate a series of random numbers. | Not applicable | import numpy as np
# Generate random integers within a specified range
x = np.random.randint(0, 10, size=(3, 3))
# Generate random floats within a specified range
y = np.random.uniform(low=0.0, high=10.0, size=(3, 3))
# Generate random numbers with numpy
z = np.random.rand(3,3)
print('Random integers:', x, '\n')
p... |
null | Write a web scraper using Python | import requests from bs4 import BeautifulSoup # Function to scrape for the specified HTML elements def scrape(url): response = requests.get(url) soup = BeautifulSoup(response.content, 'html.parser') # Use the .find, .find_all, .select and .select_one methods to scrape website titles = soup.find_all("title") content = s... | |
null | Automate a process using an AI model in Python to determine if an email is spam or not. | import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import MultinomialNB
from sklearn.metrics import confusion_matrix
# Load data
data = pd.read_csv('data.csv')
# Separate labels and features
X = data.iloc[:, :-1].values
y = data.iloc[:, -1].values
#... | |
null | Sort a list of 5 numbers in descending order. | [123, 45, 287, 398, 135] | [398, 287, 135, 123, 45] |
null | Write a Python script to generate a list of random numbers with specified length. | import random
length = 5
rand_nums = [random.randint(0,100) for i in range(length)]
print(rand_nums) | |
null | Create a Python function that takes two numbers and returns the biggest of them. | x = 3, y = 6 | def max_of_two(x, y):
if x > y:
return x
else:
return y
x = 3
y = 6
maximum = max_of_two(x, y)
print('The maximum of', x, 'and', y, 'is', maximum) |
null | Provide an input to the following code so that it prints out the sum of all numbers between 1 and 5. | # initialise sum sum = 0 # loop over given range for i in range(1, 6): sum += i print(sum) # Output: 15 | |
null | Suggest an efficient algorithm for sorting an array of integers in Python. | [1, 5, 3, 8, 4, 2] | def sort_array(array):
for i in range(len(array)):
lowest = i
for j in range(i + 1, len(array)):
if array[lowest] > array[j]:
lowest = j
array[i], array[lowest] = array[lowest], array[i]
return array
result = sort_array([1, 5, 3, 8, 4, 2])
print(result) |
null | Generate a unique and random password for a user using python. | import random characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()_+-=[ ]{}:' password = random.choices(characters, k = 16) print("".join(password)) | |
[CS Wikipedia] Minestrone
Minestrone (z italského minestra – polévka, s augmentativní příponou -one, tedy ve významu „velká polévka“) je italská hustá zeleninová polévka. Mezi obvyklé ingredience patří především rajčata, dále fazole, cibule, celer, mrkev a případně další zelenina. Neexistuje žádný pevně daný recept, v... | null | null | null |
null | Write a recursive Python function to generate a Fibonacci sequence given a lower and upper limit. | def generate_fibonacci_sequence(low, up):
"""
Generate a Fibonacci sequence
Args:
low (int): lower limit
up (int): upper limit
Returns:
list: list with Fibonacci sequence
"""
if low == up:
return [low]
else:
fib_list = generate_fibonacci_seque... | |
null | Create a Python dictionary with three keys named "Name", "Address" and "Phone". | Name = 'John';
Address = '212 Smith Street';
Phone = '732-123-4567'; | info = {
'Name':Name,
'Address':Address,
'Phone':Phone
} |
null | Construct an algorithm to find all possible combinations of a string of characters. | A possible algorithm is to use a recursive approach. The algorithm would start from the beginning of the string and for each character, generate all possible combinations for the rest of the string. Then, for each combination, the character can either be included or excluded from the combination. Finally, return the li... | |
null | Design a function in a Python program to calculate the area of a circle with a given radius. | def get_circle_area(radius):
"""Calculate and return the area of a circle with a given radius.
Args:
radius (float): The radius of the circle
Returns:
float: The area of the circle
"""
return 3.14 * (radius * radius) | |
null | Explain the benefits of using the OOP approach in programming. | Using the Object-Oriented Programming (OOP) approach in programming offers a number of advantages such as increased code reusability, easier maintenance, data hiding, and better performance. OOP makes it easier to model real-world objects and their relationships, allowing developers to reduce complexity by breaking pro... | |
[EN Wikipedia] Go Back (Chalee Tennison song)
"Go Back" is a song recorded by American country music artist Chalee Tennison. It was released in November 2000 as the first single from the album This Woman's Heart. The song reached No. 36 on the Billboard Hot Country Singles Tracks chart. The song was written by Jeremy ... | null | null | null |
null | Write a query in MySQL to delete all rows with a given ID. | DELETE FROM table_name WHERE ID = 'given_id'; | |
[HI Wikipedia] मैतै लोग
मैतै या मणिपुरी पूर्वोत्तर भारत के मणिपुर राज्य का बहुसंख्यक समुदाय है। वे मणिपुर के मूल निवासी हैं इसलिए उन्हें मणिपुरी भी कहा जाता है। धर्मिक दृष्टि से अधिकतर मैतै हिन्दू हैं। इनकी मान्यताओं में 'सनमाही' नामक विश्वास-पद्धति भी शामिल है जिसमें ओझाप्रथा के कुछ तत्त्व हैं। मैतै समुदाय के एक महत्... | null | null | null |
null | Construct an HTTP request to fetch the HTML of a given web page. | url = "example.com" | GET / HTTP/1.1 Host: example.com User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 Connection: keep-alive |
null | Write a Python program to implement an algebraic equation. | Equation: 3x2 + 7x -4 | def evaluate_eq(x):
return 3*x*x + 7*x - 4 |
null | Construct an SQL query to find all records where the column ‘department’ equals ‘sales’. | SELECT * FROM table WHERE department = 'sales'; | |
null | Write a HTML code to show a table with 2 columns and 4 rows. | <table> <tr> <th>Column 1</th> <th>Column 2</th> </tr> <tr> <td>Row 1</td> <td>Row 1</td> </tr> <tr> <td>Row 2</td> <td>Row 2</td> </tr> <tr> <td>Row 3</td> <td>Row 3</td> </tr> <tr> <td>Row 4</td> <td>Row 4</td> </tr> </table> | |
null | Optimize a code snippet in Python for maximum performance. | import time
def sleep_for_the_ night():
time.sleep(5)
while True:
sleep_for_the_ night() | import time
def sleep_for_the_night():
while True:
start_time = time.time()
time.sleep(5)
end_time = time.time()
elapsed_time = end_time - start_time
if elapsed_time < 5:
time.sleep(5-elapsed_time)
while True:
sleep_for_the_night() |
[DE Wikipedia] Clorox
Die Clorox Company ist ein Haushaltswaren- und Chemieunternehmen aus den Vereinigten Staaten mit Hauptsitz in Oakland, Kalifornien. Das Unternehmen ist im Aktienindex S&P 500 gelistet. Das Unternehmen ist insbesondere für das Bleichmittel der Marke Clorox bekannt. Unternehmensgeschichte Das Unter... | null | null | null |
null | Generate C code to swap two integers without using a third variable. | void swap_int(int * x, int * y) { *x = *x ^ *y; *y = *x ^ *y; *x = *x ^ *y; } | |
null | Produce a problem solving algorithm in Python to find the number of possible anagrams of a given word. | def anagrams_count(word):
if len(word) <= 1:
return 1
else:
c = word[0]
rem_let = word[1:]
ret = anagrams_count(rem_let)
for i in range(len(rem_let)):
if c == rem_let[i]:
continue
rem_let_i = rem_let[:i] + rem_let[i+1:]
... | |
null | In Python, how can you iterate a list in reverse order? | We can use the reversed() function to iterate a list in reverse order in Python. For example: my_list = [1, 2, 3, 4] for element in reversed(my_list): print(element) | |
[HI Wikipedia] वरुण (ग्रह)
वरुण, (अंग्रेजी : नॅप्टयून या नॅप्चयून; प्रतीक: ) हमारे सौर मण्डल में सूर्य से आठवाँ ग्रह है। व्यास के आधार पर यह सौर मण्डल का चौथा बड़ा और द्रव्यमान के आधार पर तीसरा बड़ा ग्रह है। वरुण का द्रव्यमान पृथ्वी से १७ गुना अधिक है और अपने पड़ौसी ग्रह अरुण (युरेनस) से थोड़ा अधिक है। खगोलीय इकाई के ... | null | null | null |
null | Construct a Python script to print a specific character from a string. | str = "Hello world!" index = 5 | testString = "Hello world!" print(testString[index]) # Output will be: w |
null | Write a loop to iterate through the following array and prints each element. | arr = [1, 2, 3, 4, 5] | arr = [1, 2, 3, 4, 5]; for (let i = 0; i < arr.length; i++) { console.log(arr[i]); } |
null | You need to write code for adding a column to a pandas DataFrame. | import pandas as pd df = pd.DataFrame({'A': [12, 4, 5, None, 1], 'B': [7, 2, 54, 3, None], 'C': [20, 16, 11, 3, 8], 'D': [14, 3, 17, 2, 6]}) new_col_data = [1, 1, 15, 6, 96] | import pandas as pd df = pd.DataFrame({'A': [12, 4, 5, None, 1], 'B': [7, 2, 54, 3, None], 'C': [20, 16, 11, 3, 8], 'D': [14, 3, 17, 2, 6]}) new_col_data = [1, 1, 15, 6, 96] df['new_col'] = new_col_data |
[EN Wikipedia] Marinobacter persicus
Marinobacter persicus is a Gram-negative, non-spore-forming, strictly aerobic and moderately halophilic bacterium from the genus of Marinobacter which has been isolated from the Aran-Bidgol Lake from the central desert of Iran. References External links Type strain of Marinobacter ... | null | null | null |
null | Write a SQL query to select all employees from the department with the code 'IT'. | SELECT * FROM Employees WHERE departmentCode = 'IT'; | |
[CS Wikipedia] Vůz BDbmsee447 ČD
{{DISPLAYTITLE:Vůz BDbmsee447 ČD}} Vozy řady BDbmsee447 (původně dodány jako BDmeer, potom do prosince 2010 označeny BDbmrsee), očíslované v intervalu 51 54 82-70, jsou jednou z řad osobních vozů Českých drah přizpůsobených pro přepravu vozíčkářů . Všechny tyto vozy (075–100) byly vyro... | null | null | null |
null | Introduce a condition to change the background color of a given HTML page to green when the user clicks a button. | <script> function changeBackgroundColor() { document.body.style.backgroundColor = 'green'; } </script> <button onclick="changeBackgroundColor()">Change background color!</button> | |
[HI Wikipedia] चंदन दास
चंदन दास मशहूर गज़ल गायक हैं।ुन्के प्रमुख गाने इस प्रकार है--आ भी जाओ के जिन्दगी कम है, कल खाब मे देखा सखी मैने पिया का गाओ रे, जब मेरी हकीकत जा जा कर, जब कोइ फैसला कीजिये, साथ छूटेगा कैसे मेरा आपका। सन्दर्भ गायक | null | null | null |
null | Build a simple chatbot using Python and nltk library. The chatbot should read a given set of strings as input and generate an appropriate response. | Hello, how are you? | import nltk
# sample input
input = 'Hello, how are you?'
# list of tokenized words
words = nltk.word_tokenize(input)
# list of part-of-speech tagged words
words_tagged = nltk.pos_tag(words)
# defining chatbot's greeting response
greeting_response = 'Hi there! How can I help you?'
# defining chatbot's response to ... |
null | Write a C++ code to perform selection sort on a given array of numbers. | [2, 6, 4, 1, 7, 9, 8] | void selectionSort(int arr[], int n) { int i, j, min_idx; // One by one move boundary of unsorted subarray for (i = 0; i < n-1; i++) { // Find the minimum element in unsorted array min_idx = i; for (j = i+1; j < n; j++) { if (arr[j] < arr[min_idx]) { min_idx = j; } } // Swap the found minimum element with the first // ... |
null | Write a code to multiply two matrices, assuming the two matrices can be multiplied. | A = [[1, 2], [3, 4]] B = [[5, 6], [7, 8]] | def multiply_matrices(A, B): if len(A[0]) != len(B): raise ValueError("Matrices cannot be multiplied") rows_A = len(A) columns_A = len(A[0]) rows_B = len(B) columns_B = len(B[0]) result = [[0 for column in range(columns_B)] for row in range(rows_A)] for row in range(rows_A): for column in range(columns_B): for k in ran... |
[DE Wikipedia] Edmund Weaver
Edmund Weaver (* um 1683; † 27. Dezember 1748) war ein englischer Astronom, Vermessungsingenieur und Freund von William Stukeley. Weaver's The British Telescope Ephemeriden (astronomische Tabellen) gilt als eine wichtige Publikation des 18. Jahrhunderts über die Bewegung der Planeten. Lebe... | null | null | null |
null | Write a SQL query to find the books in the library whose title included the word "Science". | SELECT * FROM books WHERE title LIKE '%Science%'; | |
[DE Wikipedia] Vessel (Struktur)
Vessel (TKA) ist eine etwa 46 Meter hohe Struktur und Besucherattraktion und Teil des Städtebauprojektes Hudson Yards auf der West Side von Manhattan in New York City. Sie ist eine Mischung zwischen Gebäude, Kunstwerk und Monument und wurde nach Plänen des britischen Designers und Arch... | null | null | null |
[EN Wikipedia] Horace C. Spencer
Horace C. Spencer (July 1832 – November 1, 1926) was a Michigan politician. Early life In 1832, Spencer was born in Springville, Erie County, New York or possibly Coutland, New York. In 1853, he married Catherine Morris. Traveling to Michigan in 1866, he entered the hardware business u... | null | null | null |
null | Create a Python program to find and remove the longest string from a given list of strings. | list_strings = ["string1", "string2", "string3", "longeststring"] | def remove_longest_string(list_strings):
longest_string = ""
for string in list_strings:
if len(string) > len(longest_string):
longest_string = string
list_strings.remove(longest_string)
return list_strings
print(remove_longest_string(list_strings)) |
[HI Wikipedia] नुआपड़ा
नुआपड़ा भारत के ओड़ीसा प्रान्त का एक शहर है। यह नुआपड़ा जिला मुख्यालय है। विवरण पश्चिमी ओड़ीशा का नुआपड़ा जिला मध्य प्रदेश के रायपुर और ओड़ीशा के बरगढ़, बलांगिर व कालाहांडी जिलों से घिरा हुआ है। 3407.05 वर्ग किलोमीटर में फैला यह जिला 1993 तक कालाहांडी का हिस्सा था, लेकिन प्रशासनिक सुविधा के लिहा... | null | null | null |
[HI Wikipedia] पानीपत
पानीपत (अँग्रेज़ी: Panipat) भारत के हरियाणा राज्य के पानीपत ज़िले में स्थित एक ऐतिहासिक नगर है। यह ज़िले का मुख्यालय भी है। कोरवो और पांडुवो में मध्य महाभारत का युद्ध पानीपत के लिए हुआ था , पांडुवों ने चार अन्य गांवों के साथ पानीपत की मांग कौरवों से की थी पर कौरवों ने सुई की नोक के बराबर भी हिस्स... | null | null | null |
null | Given a JSON document, write a Python code to query for all records with a price value greater than 5. | {
"id": "0001",
"type": "donut",
"name": "Cake",
"price": 5.99
},
{
"id": "0002",
"type": "donut",
"name": "Chocolate",
"price": 3.99
} | import json
def query_price(data):
# Load data from string
records = json.loads(data)
# Query for all records with a price value greater than 5.
return [record for record in records if record['price'] > 5] |
null | Write a python program that takes in 2 parameters, a list and a number, and returns a dictionary with the words in the list and the number of characters in each word as its value. | ['the', 'cat', 'in', 'the', 'hat'] | my_list = ['the', 'cat', 'in', 'the', 'hat']
def get_word_length_dict(my_list):
my_dict = {}
for word in my_list:
my_dict[word] = len(word)
return my_dict
print(get_word_length_dict(my_list)) |
null | Create a lambda function in Python that collects all the numbers between 0 and 10 that are divisible by 3. | lambda x: [x for x in range(0, 11) if x % 3 == 0] | |
null | Create a C++ program that finds the first 8 prime numbers. | #include <iostream> using namespace std; int main() { int n, i, c; for (n = 2; n <= 16; n++) { c = 0; for (i = 1; i <= n; i++) { if (n % i == 0) { c++; } } if (c == 2) { cout << n << endl; } } return 0; } | |
null | Modify the existing Python code to generate a Fibonacci series. | def generate_fibonacci_series(n):
print("0")
current = 0
next = 1
for i in range(0, n-1):
current, next = next, current + next
print(next) | def generate_fibonacci_series(n):
print("0")
current = 0
next = 1
for i in range(0, n):
print(current)
temp = current
current = next
next = temp + next |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.