text stringlengths 141 2.89k ⌀ | instruction stringlengths 19 1.5k ⌀ | input stringlengths 0 800 ⌀ | output stringlengths 1 2.5k ⌀ |
|---|---|---|---|
[EN Wikipedia] Ceux de la Libération
Ceux de la Libération (CDLL; "Those of the Liberation") was a French resistance movement during the German occupation of France in World War II. CDLL was one of the eight major resistance groups of the Conseil National de la Résistance (CNR). History was formed in November 1940 by ... | null | null | null |
null | What type of data structure is this? | array = [1, 2, 3, 4, 5] | This is an array data structure. |
null | Write a function to check for palindrome | str = "abcba" | def is_palindrome(str): # First convert all to the same case str = str.lower() return str == str[::-1] |
null | Implement a chatbot in Python that can provide customer support in a restaurant. | random_user_question.txt
What meals do you serve? | import random
# list of possible answers
possible_responses = [
'We serve a variety of dishes - from salads to pizzas to steaks!',
'Check out our menu for a full list of options',
'We serve a variety of dishes, including traditional Italian, Mexican, and American fare. What would you like to try?',
'We have a grea... |
[DE Wikipedia] Dankmarshäuser Rhäden
Der Dankmarshäuser Rhäden nimmt den südlichen Teil eines großen Feuchtgebiets ein, das in einer durch Salzauslaugungsprozesse und tektonische Vorgänge entstandenen Senke im thüringisch-hessischem Grenzland liegt. Einst war das Gelände eine der größten Sumpflandschaften in der breit... | null | null | null |
null | Using Python, edit the following dataset to discard outliers. | Dataset: [12, 34, 37, 10, 89, 67, 99, 101] | import numpy as np
dataset = [12, 34, 37, 10, 89, 67, 99, 101]
dataset_without_outliers = [x for x in dataset if abs(x-np.mean(dataset)) < 3*np.std(dataset)]
print(dataset_without_outliers) # prints [12, 34, 37, 10, 89, 67, 99] |
null | Write an AppleScript to open a given link in Safari. | https://www.google.com | tell application "Safari" open location "https://www.google.com" end tell |
null | How do you convert a JSON object to a string? | The JSON.stringify() method can be used to convert a JSON object to a string. This method takes two arguments: the JSON object to be converted and an optional replacer function that can be used to alter the output. | |
null | Develop a code to delete a given element from a list. | [3, 6, 8, 14], element: 14 | def delete_element(given_list, element): for i in range(len(given_list)): if given_list[i] == element: del given_list[i] break return given_list |
null | Write a C++ code to create a function which prints the sum of two integers. | #include <iostream> using namespace std; // Function to print the sum of two integers void printSumOfIntegers(int first, int second) { cout << first + second << endl; } | |
null | Edit the Python code block below to print the text in reverse. | word = "Hello" print (word) | word = "Hello" print (word[::-1]) |
null | Write a SQL query which returns the number of customers from the following "customers" table that are from France. | SELECT COUNT(*) FROM customers WHERE country = 'France'; | |
[DE Wikipedia] Beteiligter
Der Begriff des Beteiligten wird in der deutschen Rechtssprache unterschiedlich verwendet: Verwaltungsrecht Behördliches Verfahren Antragsteller und Antragsgegner Adressat eines Verwaltungsaktes Beteiligter bei öffentlich-rechtlichem Vertrag Hinzugezogener bzw. Hinzuzuziehender Siehe VwVfG, ... | null | null | null |
null | Generate an artificial neural network in python that calculates the output for the given input matrix. | Input matrix:
[[3, -0.5, 2],
[-0.5, 0.7, 1.2],
[0.2, -0.3, 0.8]] | # import the necessary libraries
import numpy as np
import tensorflow as tf
# define the input matrix
input_matrix = np.array([[3, -0.5, 2],
[-0.5, 0.7, 1.2],
[0.2, -0.3, 0.8]])
# create a 3x3 weight matrix
weights = tf.Variable(tf.truncated_normal(shape=[3, 3], mean=0, stddev=0.1, dtype=tf.float32))
# define th... |
null | Implement a function that will return the intersection of two given arrays. | arr_1 = [2,3,4,7] arr_2 = [1,3, 5, 6, 7] | def intersection(arr_1, arr_2): intersect = [] for i in arr_1: if i in arr_2: intersect.append(i) return intersect if __name__ == '__main__': arr_1 = [2,3,4,7] arr_2 = [1,3, 5, 6, 7] print(intersection(arr_1, arr_2)) # Output: [3, 7] |
null | Write a function in Java to remove duplicates from a list of Strings. | public List<String> removeDuplicates(List<String> inputList) { // Create a new HashSet HashSet<String> hs = new HashSet<>(); // Add the contents of inputList to the HashSet hs // HashSet does not allow duplicates hs.addAll(inputList); // Clear inputList inputList.clear(); // add the elements of hs to inputList inputLis... | |
[CS Wikipedia] Jan Daniel Bláha
Jan Daniel Bláha (* 13. března 1981 Havlíčkův Brod) je český kulturní geograf, antropolog a kartograf realizující vlastní výzkumy v mimoevropských lokalitách, zejména na Papui Nové Guineji. Život Dětství prožil v Chotěboři na Vysočině. Vystudoval Přírodovědeckou fakultu Univerzity Karlo... | null | null | null |
[CS Wikipedia] Time (Clock of the Heart)
"Time (Clock of the Heart)" je New Wave/R&B píseň od skupiny Culture Club. Time je druhý singl z jejich debutního alba Kissing to Be Clever. Píseň byla vydán firmou Virgin, trvala 3:42, sepsal ji Culture Club a byla produkována Steve Levinem. Kanadským a britským fonografickým ... | null | null | null |
null | Write a loop that iterates over the characters in a string, and if the character is an 'o', print the character. | "Hello World" | for char in "Hello World": if char == 'o': print(char) |
null | Create a CSS code to set the font-family of the content inside a div. | div { font-family: 'roboto', sans-serif; } | |
[HI Wikipedia] काकूवाला
काकूवाला () पंजाब के संगरूर ज़िले के सुनाम ब्लॉक का एक गाँव है, जो संगरूर-पातड़ां राष्ट्रीय राजमार्ग 17 पर स्थित है। भौगोलिक स्थिति मुताबिक इसके उत्तर की तरफ़ दिढ़बा और गाँव खेतला, दक्षिण-पश्चिम की तरफ़ गाँव लाडबंजारा कल, दक्षिण-पूर्व की तरफ़ पातड़ां और गाँव दुगाल पड़ते हैं। इसका नाम काकू सिंह ... | null | null | null |
[CS Wikipedia] Čtyři vraždy stačí, drahoušku
Čtyři vraždy stačí, drahoušku je česká filmová komedie režiséra Oldřicha Lipského z roku 1970 s Lubomírem Lipským v hlavní roli. Film je doplněn komiksovými kresbami Káji Saudka. Děj Cestující ve vlaku si čte komiks. V němž se v bytě nic netušícího učitele literatury George... | null | null | null |
null | Using SQL, write a query to find the maximum price of a product in the database. | SELECT MAX(price) FROM products; | |
null | Create a class in Python for a 2D vector with the basic vector operations- addition, subtraction, dot product and cross product. | class Vector2D:
"""Represents a 2D vector with the basic vector operations- addition, subtraction, dot product, and cross product."""
def __init__(self, x, y):
self.x = x
self.y = y
def __add__(self, other):
"""Adds two vectors."""
x = self.x + other.x
y = s... | |
null | Edit the following HTML code to include a new form field. | <html> <head> <title>My Form</title> </head> <body> <form> <label for="name">Name</label> <input type="text" id="name"> </form> </body> </html> | <html> <head> <title>My Form</title> </head> <body> <form> <label for="name">Name</label> <input type="text" id="name"> <label for="address">Address</label> <input type="text" id="address"> </form> </body> </html> |
[CS Wikipedia] Simply Red
Simply Red je britská soulová kapela založená v roce 1984 Mickem Hucknallem. Během dvaceti pěti let působení prodala přes 50 milionů nosičů. Skupina vytvořila několik hitů jako It's Only Love (1989), Stars (1991), Fairground (1995) nebo Sunrise (2000). Z převzatých písní pak například Money's... | null | null | null |
[DE Wikipedia] August Portius
August Portius (* 14. August 1834 in Leipzig; † 7. September 1912 in Dresden) war ein sächsischer Generalmajor und der Erbauer der Dresdner Albertstadt. Leben Herkunft Portius war Sohn des Kaufmanns Ferdinand Portius und dessen zweiter Ehefrau August Brockhaus, Tochter des Buchhändlers Fr... | null | null | null |
null | Convert the Python Dictionary given below into a valid JSON | { "firstName": "John", "lastName": "Doe", "age": 23 } | { "firstName": "John", "lastName": "Doe", "age": 23 } |
null | Reverse a string using a stack. | string: hello | def reverse_string_using_stack(string): stack = [] for char in string: stack.append(char) reversed_string = '' while len(stack) > 0: reversed_string += stack.pop() return reversed_string |
[HI Wikipedia] बहादुरगढ़
बहादुरगढ़ (Bahadurgarh) भारत के हरियाणा राज्य के झज्जर ज़िले में स्थित एक नगर है। विवरण बहादुरगढ़ दिल्ली के टिकरी बॉर्डर से केवल 2 किलोमीटर आगे हरियाणा के झज्जर जिले में स्थित है। यह राष्ट्रीय राजधानी क्षेत्र का एक मुख्य औद्योगिक शहर है। बहादुरगढ में हरियाणा सरकार द्वारा स्थापित हरियाणा राज्य ... | null | null | null |
null | Suggest a way to get a substring of a given string in Python. | def substring(string, start, end):
'''This function takes a string, start index and end index, and returns the substring between the two given indexes.'''
return string[start:end] | |
null | Create a Python script to print characters from the "abcd" string until the total of characters printed reaches 50. | string = "abcd"
count = 0
while count < 50:
for ch in string:
print(ch)
count += 1
if count >= 50:
break | |
null | Write a Python program to create an editable table showing a list of quote objects. | quoteList = [{name: "Albert Einstein", quote: "Imagination is more important than knowledge."},
{name: "Mahatma Gandhi", quote: "Be the change you wish to see in the world."},
{name: "J.K. Rowling", quote: "The power of imagination makes us infinite."}
] | import tkinter as tk
from tkinter import ttk
root = tk.Tk()
root.title('Quotes Table')
# create a table of quote objects
tree = ttk.Treeview(root, columns=['name', 'quote'], show = 'headings')
tree.column('name', width=100, anchor='w')
tree.heading('name', text='Name')
tree.column('quote', width=300, anchor='w')
tr... |
[EN Wikipedia] Gmina Łaskarzew
Gmina Łaskarzew is a rural gmina (administrative district) in Garwolin County, Masovian Voivodeship, in east-central Poland. Its seat is the town of Łaskarzew, although the town is not part of the territory of the gmina. The gmina covers an area of , and as of 2006 its total population i... | null | null | null |
[CS Wikipedia] Ahascragh
Ahascragh (, v překladu Eskerský brod) je vesnice na východním okraji hrabství Galway v Irsku. Na východ od vesnice protéká říčka Bunowen. Přes vesnici prochází silnice R358. Externí odkazy Geografie Irska | null | null | null |
[HI Wikipedia] ओस्तरयोतलान्द लैन
ओस्तरयोतलान्द लैन (स्वीडी: Östergötlands län, अंग्रेज़ी: Östergötland) स्वीडन का एक लैन है। 'लैन' स्वीडन का उच्च-स्तरीय प्रशासनिक विभाग होता है, जिसे कभी-कभी 'काउंटी' भी कहते हैं। इन्हें भी देखें स्वीडन की काउंटियाँ सन्दर्भ ओस्तरयोतलान्द लैन स्वीडन की काउंटियाँ स्वीडन | null | null | null |
[DE Wikipedia] Jiyar Jahan Fard
Sajjad Jahanfard, kurdisch „Jiyar“ ist ein Schriftsteller aus dem Iran (Ostkurdistan). Er ist Vorstandsmitglied der kurdischen Pen Association. Leben Jahan Fard („Jiyar“) wurde 1985 in Gilan-e-Gharb, Provinz Kermanshah, geboren. Aufgrund seines Engagements für die kurdische Sprache und ... | null | null | null |
null | You need to reverse the following array using JavaScript. | [1,3,5,7] | function reverseArray(arr) { let revArray = []; for (let i = arr.length - 1; i >= 0; i--) { revArray.push(arr[i]); } return revArray; } |
[EN Wikipedia] Adobe
Adobe ( ; ) is a building material made from earth and organic materials. is Spanish for mudbrick. In some English-speaking regions of Spanish heritage, such as the Southwestern United States, the term is used to refer to any kind of earthen construction, or various architectural styles like Puebl... | null | null | null |
null | Compare two dates in JavaScript and return 1 if the first date is after the second date. | date1 = new Date('August 19, 2025'); date2 = new Date('August 20, 2025'); | function compareDates(date1, date2) { const timeDifference = date1.getTime() - date2.getTime(); if(timeDifference > 0) { // date1 is after date2 return 1; } else { // date2 is after date1 return 0; } } if __name__ == '__main__': date1 = new Date('August 19, 2025'); date2 = new Date('August 20, 2025'); print(compareDate... |
null | Write a Python program to calculate the simple interest on a loan of $1000 over 10 years at an interest rate of 5%. | Not applicable | loan_amount = 1000
interest_rate = 5
number_of_years = 10
simple_interest = loan_amount * (interest_rate/100) * number_of_years
print("Simple interest = %.2f" %simple_interest) |
null | Create a machine learning model in Python for predicting house prices. This model should use data from a dataset that includes features such as number of bedrooms, square footage, and location. | Not applicable | import pandas as pd
import numpy as np
from sklearn import linear_model
from sklearn.model_selection import train_test_split
# Load the house price data
data = pd.read_csv('house_prices_data.csv')
# Separate features and labels
X = data.iloc[:,0:3].values
y = data.iloc[:,3].values
# Split the data into training an... |
null | Explain what is the purpose of the try-except block | The purpose of the try-except block is to handle exceptions that may be raised while a program is executing, so as to avoid crashing of the program. | |
null | Generate a Python program to convert Fahrenheit to Celsius using a given formula. | def fahrenheit_to_celsius(fahrenheit):
celsius = (fahrenheit - 32) * 5 / 9
return celsius | |
null | Explain the concept of Strassen's Matrix multiplicatiom algorithm. | Strassen's Matrix multiplication algorithm is an improvement over the traditional matrix multiplication algorithm. This algorithm divides the two matrices into four sub-matrices of size n/2 × n/2 and then performs 7 multiplications and adds the resulting values to calculate the final result. It reduces the number of mu... | |
[EN Wikipedia] List of movie misquotes
Following is a list of movie misquotes, ordered by release date. Quotes may be changed for a number of reasons. Long ones, such as Apocalypse Now "I love the smell of napalm ..." or Gold Hat's rant about badges in The Treasure of the Sierra Madre, may be shortened. Sometimes misq... | null | null | null |
null | Create one line of code to sum the contents in a given array. | my_array = [2, 3, 5, 7, 11] | sum_of_array = sum(my_array) |
[DE Wikipedia] Rhenaer Viadukt
Der Rhenaer Viadukt ist eine einspurige Eisenbahnbrücke der Uplandbahn bei Rhena, einem Stadtteil von Korbach im nordhessischen Landkreis Waldeck-Frankenberg (Deutschland). Es handelt sich um eine Bogenbrücke aus Naturstein und Schüttbeton mit vier Brückenbögen, drei Brückenpfeilern und ... | null | null | null |
null | Write a function to determine if two rectangles intersect. | rect1 = (x1, y1, w1, h1) rect2 = (x2, y2, w2, h2) | def is_intersect(rect1, rect2): if rect1[0] > rect2[0] + rect2[2] or rect1[0] + rect1[2] < rect2[0] or rect1[1] > rect2[1] + rect2[3] or rect1[1] + rect1[3] < rect2[1]: return False else: return True |
null | Convert the following JSON string to a Python dictionary. | {"name": "John", "age": 30, "city": "New York"} | import json json_str = '{"name": "John", "age": 30, "city": "New York"}' py_dict = json.loads(json_str) # py_dict would be {"name": "John", "age": 30, "city": "New York"} |
null | Create a HTML select element with the given list of countries as options. | CountryList = ['India','United States','Canada','Australia','New Zealand','Singapore','Japan'] | <select> <option value="India">India</option> <option value="United States">United States</option> <option value="Canada">Canada</option> <option value="Australia">Australia</option> <option value="New Zealand">New Zealand</option> <option value="Singapore">Singapore</option> <option value="Japan">Japan</option> </sele... |
null | Sort a given list in increasing order. | my_list = [3, 4, 2, 6] | def sort_list(my_list): """Function to sort the list in increasing order""" for i in range(len(my_list)): min_idx = i for j in range(i+1, len(my_list)): if my_list[min_idx] > my_list[j]: min_idx = j my_list[i], my_list[min_idx] = my_list[min_idx], my_list[i] return my_list if __name__ == '__main__': my_list = [3, 4, 2,... |
null | Create an HTML web page that contains two text fields and two buttons | <!DOCTYPE html> <html> <head> <title>Two Text Fields and Two Buttons</title> </head> <body> <form action=""> <input type="text" placeholder="Input 1" /> <input type="text" placeholder="Input 2" /> <button type="submit">Button 1</button> <button type="reset">Button 2</button> </form> </body> </html> | |
null | Create a list of 5 integers and print out their product. | """ Create a list of 5 integers and print out their product """ list_of_ints = [1, 2, 3, 4, 5] product = 1 for i in list_of_ints: product *= i print(product) | |
null | Generate a python program that takes two strings and outputs the longest common substring | def longestCommonSubstring(s1, s2):
m = [[0] * (1 + len(s2)) for i in range(1 + len(s1))]
longest, x_longest = 0, 0
for x in range(1, 1 + len(s1)):
for y in range(1, 1 + len(s2)):
if s1[x - 1] == s2[y - 1]:
m[x][y] = m[x - 1][y - 1] + 1
if m[x][y] > l... | |
null | Create a CSS class to make all the text in the body of the page blue. | body { font-color: blue; } | |
null | Edit the following JavaScript code to remove any warnings given by the linter. | let favoriteNumber = [7,9,42]; const printNumber = (number) => console.log(number); for (let idx = 0; idx < favoriteNumber.length; idx +=1) { printNumber(favoriteNumber[idx]) } | let favoriteNumber = [7, 9, 42]; const printNumber = (number) => console.log(number); for (let idx = 0; idx < favoriteNumber.length; idx += 1) { printNumber(favoriteNumber[idx]); } |
null | Convert a LinkedList to an array of objects | Object[] array = linkedList.toArray(); | |
[EN Wikipedia] Terry Lowe
Terence John Lowe (born 27 May 1943) is an English former footballer who played at right-back for Port Vale between 1960 and 1966. Career In his youth, Lowe played for Stoke City before joining Port Vale in June 1960. His debut came in the Potteries derby 1–0 win over Stoke in the Supporters'... | null | null | null |
null | Write a function that takes in two strings, compares them, and returns the longer string. | String 1: Python
String 2: C++ | def compareLongestString(str1, str2):
if len(str1) > len(str2):
longestString = str1
elif len(str2) > len(str1):
longestString = str2
else:
longestString = "Strings have the same length"
return longestString
print(compareLongestString("Python", "C++")) |
null | Write a Python program that sorts a list of integers in ascending order without using the built-in sort() method. | [4, 5, 13, 2, 9, 7] | def selection_sort(arr):
n = len(arr)
for i in range(n):
min_idx = i
for j in range(i+1, n):
if arr[min_idx] > arr[j]:
min_idx = j
arr[i], arr[min_idx] = arr[min_idx], arr[i]
arr = [4, 5, 13, 2, 9, 7]
selection_sort(arr)
print(arr)
# Output: [2, 4, 5, 7, 9, 13] |
null | Code a program in PHP to swap the values of two variables. | a = 10 b = 15 | $a = 10; $b = 15; list($a, $b) = array($b, $a); echo $a; // Outputs 15 echo $b; // Outputs 10 |
[HI Wikipedia] वाले कैन्टन
वाले कैन्टन (फ़्रान्सीसी: Valais) या वालिस कैन्टन (जर्मन: Wallis) स्विट्ज़रलैंड के दक्षिण-पश्चिमी भाग में स्थित एक कैन्टन (प्रान्त से मिलता-जुलता प्रशासनिक विभाग) है। यह कैन्टन सन् १८१५ में स्विस परिसंघ का हिस्सा बना था। हालाँकि अधिकतर स्विस कैन्टोनों एकभाषीय होते हैं, वाले कैन्टन में फ़्रान... | null | null | null |
null | Write a Python script to implement a linear search algorithm. | lst = [1, 2, 3, 4, 5, 6]
target = 4 | def linearSearch(lst, target):
for i in range(len(lst)):
if lst[i] == target:
return i
return -1
lst = [1, 2, 3, 4, 5, 6]
target = 4
result = linearSearch(lst, target)
if result == -1:
print("Element is not present in the list")
else:
print("Element is present at index", result) |
null | Write a code snippet in Python to compute the maximum of an array of numbers. | [2, 4, 6, 8] | def find_max(nums):
max_num = nums[0]
for num in nums:
if num > max_num:
max_num = num
return max_num
print(find_max([2, 4, 6, 8])) |
null | Write a Python script to generate a random password of 8 characters with at least 2 letters, 2 numbers, and 2 symbols. | Not applicable | import random
import string
def generate_password():
letter_lowercase = string.ascii_lowercase
letter_uppercase = string.ascii_uppercase
numbers = string.digits
symbols = string.punctuation
all_chars = letter_lowercase + letter_uppercase + numbers + symbols
password = ""
for i in range(2):
password += ... |
null | Create a Ruby code to remove all items that starts with the letter 'a' from a given array. | arr: [apple, banana, avocado, orange] | arr = arr.reject {|element| element.start_with?('a') } |
null | Create a HTML page with a fixed header bar and a scrolling content area. | <html> <head> </head> <body> <div id="header"> <!-- header content --> </div> <div id="content" style="overflow-y:scroll;"> <!-- content here --> </div> </body> </html> | |
null | Create a class in Python with all five common inheritance options (parent class, subclasses, multiple inheritance, abstract class, etc). | class Parent:
# Constructor
def __init__(self):
self.value = 'parent'
def parent_method(self):
# Parent method here
return self.value
class ChildOne(Parent):
# Constructor
def __init__(self):
Parent.__init__(self)
self.value = 'child one'
class ChildTwo... | |
null | Create a function in Python that takes two strings as inputs and prints out the longer of the two strings. | Hello
World | def longestString(str1, str2):
if len(str1) > len(str2):
return str1
else:
return str2
print(longestString("Hello", "World")) |
[EN Wikipedia] Hercule Poirot
Hercule Poirot (, ) is a fictional Belgian detective created by British writer Agatha Christie. Poirot is one of Christie's most famous and long-running characters, appearing in 33 novels, two plays (Black Coffee and Alibi), and 51 short stories published between 1920 and 1975. Poirot has... | null | null | null |
null | Write a JavaScript function that takes a string argument and returns a count of all the times the letter 'a' appears in the string. | function countA(str) { let count = 0; for (let i=0; i<str.length; i++) { if (str[i] === 'a') { count += 1; } } return count; } | |
null | Create a Python program to retrieve data from a given URL. | url = "https://example.com/index.html" | # Import the built-in "requests" package
import requests
# Set the URL
url = "https://example.com/index.html"
# Retrieve the data
data = requests.get(url)
# Output the retrieved data
print(data.text) |
null | Generate a program in Python for predicting the price of a given house, given the characteristics of the house such as size, number of bedrooms, number of bathrooms, etc. | size = 1,600
bedrooms = 3
bathrooms = 2
garage_size = 1 | import pandas as pd
# Create dataframe
data = {
'size': [1,600],
'bedrooms': [3],
'bathrooms': [2],
'garage_size': [1]
}
df = pd.DataFrame(data)
# Define the features and target
features = df[['size','bedrooms','bathrooms','garage_size']]
target = df['house_price']
# Split the data into training... |
null | Create a simple python script to parse a given JSON string and print all the keys and their corresponding values. | {"name": "John", "age": 30, "city": "New York"} | import json
json_str = '{"name": "John", "age": 30, "city": "New York"}'
json_data = json.loads(json_str)
for key, value in json_data.items():
print('{}: {}'.format(key, value)) |
null | Write a python program to generate random passwords of 8 characters, containing uppercase and lowercase alphabets and numbers. | import string
import random
def generate_password():
characters = string.ascii_letters + string.digits
return ''.join(random.choice(characters) for i in range (8))
print(generate_password()) | |
null | Generate a function in Python to print the sum of two integers. | Not applicable | def print_sum(a, b):
"""
Print the sum of the two numbers
"""
print(a+b) |
null | Create a Python script that fetches the top 10 posts from Reddit using the PRAW package | Input a subreddit: news | # Fetch the top 10 posts from reddit
import praw
# Reddit API credentials
client_id = 'YOUR_CLIENT_ID'
client_secret = 'YOUR_CLIENT_SECRET'
user_agent = 'YOUR_USER_AGENT'
# Initialize the reddit client
reddit = praw.Reddit(
client_id=client_id,
client_secret=client_secret,
user_agent=user_agent
)
subreddit = inpu... |
null | Design and implement a neural network in Python to predict the price of a house given a set of features. | [0.8, 0.4, 0.7] | import numpy as np
from keras.models import Sequential
from keras.layers import Dense
features = np.array([[0.8, 0.4, 0.7]])
model = Sequential()
model.add(Dense(64, input_dim=3, activation='relu'))
model.add(Dense(32, activation='relu'))
model.add(Dense(1, activation='linear'))
model.compile(loss='mse', optimizer='... |
null | Implement a function in Python that takes a list of integers and a number and returns a list of numbers that have the given number as their sum. | lst = [1, 2, 3, 4]
num = 4 | def find_combos(lst, num):
result = []
for i in range(len(lst)):
for j in range(i+1, len(lst)):
if lst[i] + lst[j] == num:
result.append([lst[i], lst[j]])
return result
print(find_combos([1, 2, 3, 4], 4))
# Output: [[1, 3], [2, 2], [3, 1]] |
null | Write a Python program to optimize an array of integers to produce the greatest possible sum. | [5, 3, 8, 10] | def optimize_sum(arr):
n = len(arr)
dp =[[0 for x in range(n)] for x in range(n)]
# initialize base cases
for i in range(n):
dp[i][i] = arr[i]
# Fill entries in dp[][] from bottom to top
for start in range(n-2, -1, -1):
for end in range(start + 1, n):
dp[start][end] = max(arr[start] + min(... |
null | Create a RESTful API using Python Django for a book library. The API should allow users to manipulate and list books, authors, and reviews. | Not applicable | from django.conf import settings
from django.contrib.auth.models import User
from django.db import models
class Book(models.Model):
title = models.CharField(max_length=255)
description = models.TextField()
author = models.ForeignKey(User, on_delete=models.CASCADE)
class Author(models.Model):
first_name = models.C... |
null | Fix the following syntax error. | myList = [1, 2, 3 | myList = [1, 2, 3] |
[HI Wikipedia] लाज़िम्पाट
लाजिम्पाट काठमाडौं के लग भाग बीच के भाग में है जो पूर्व राजा के दरबार के पास है। इस क्षेत्र में बहुत से देशों के राजदूतों का निवास है जहाँ भारत और ब्रिटिश का राजदूतावास भी हैं। काठमाडौं जिला | null | null | null |
[DE Wikipedia] Abbott (Familienname)
Abbott ist ein englischer Familienname, der „Abt“ (im Neuenglischen abbot geschrieben) bedeutet. Namensträger A Alain Abbott (* 1938), französischer Akkordeonspieler und Komponist Alan Abbott (* 1926) britischer Komponist Alexander Crever Abbott (1860–1935), US-amerikanischer Hygie... | null | null | null |
null | Create a Python function to input a string and then return the number of vowels found in the string. | hello | def count_vowels(string):
vowels = ["a", "e", "i", "o", "u"]
count = 0
for letter in string.lower():
if letter in vowels:
count += 1
return count
output = count_vowels("Hello")
print(output) # output = 2 |
null | Create a class in python with three functions, two of which must be called `add` and `subtract`. | class MathOperations: def add(self, a, b): return a + b def subtract(self, a, b): return a - b def multiply(self, a, b): return a * b | |
[HI Wikipedia] कविता
कविता एक स्त्री नाम है। जिसका अर्थ है काव्य। सुप्रसिद्ध कोरोजयी कवि गोलेन्द्र पटेल ने कविता के संदर्भ में कहा है कि "कविता आत्मा की औषधि है।" उल्लेखनीय लोग कविता के. बड़जात्या (जन्म 12 नवंबर, 1977), भारतीय निर्माता। कविता दासवानी (जन्म 1971), अमेरिकी-भारतीय लेखिका। कविता कौशिक (जन्म 15 फरवरी, 1981... | null | null | null |
null | Generate a Python program to generate random passwords of length n. | Length: 8 | import string
import random
def random_password(length):
chars = string.ascii_uppercase + string.ascii_lowercase + string.digits
random_password = ''.join(random.choice(chars) for i in range(length))
return random_password
length = 8
print(random_password(length)) |
[HI Wikipedia] पोप फ़्रांसिस
फ्रांसिस ( ; जन्म : ख़ोर्ख़े मारिआ बेर्गोल्यो; १७ दिसम्बर १९३६, ब्यूनस आयर्स) कैथोलिक समुदाय के २६६वें पोप चुने गये हैं। पोप फ्रांसिस प्रथम को १३ मर्च २०१३ को पोंटिफ़ के रूप में चुना गया। सन्दर्भ जीवित लोग 1936 में जन्मे लोग अर्जेण्टीना के लोग पोप | null | null | null |
[EN Wikipedia] Swin River
The Swin River is a river of the Canterbury region of New Zealand's South Island. It flows southwest from the Taylor Range to reach the southeastern shore of Lake Heron. See also List of rivers of New Zealand References Rivers of Canterbury, New Zealand Rivers of New Zealand | null | null | null |
null | How can we increment the counter by 20 without manually specifying the value 20? | counter = 0 | counter += 20; // Increment counter by 20 without using the number 20 directly. |
null | Using Regular Expressions, search for all 3-digit occurrences in the given text. | text = "The ship had a 590 foot cargo hold, filled with 204 tons of goods." | 590 and 204. |
null | Design a SQL query to find the average age of your group's members | SELECT AVG(age) FROM members GROUP BY group_name; | |
[HI Wikipedia] महान अफ़्रीकी झीलें
महान अफ़्रीकी झीलें (अंग्रेज़ी: African Great Lakes) अफ़्रीका में पूर्वी अफ़्रीकी दरार के क्षेत्र में स्थित बड़े आकार की झीलों की एक शृंखला है। इनमें विक्टोरिया झील (सतही क्षेत्रफल के हिसाब से दुनिया की दूसरी सबसे बड़ी मीठे पानी की झील) और तांगान्यीका झील (घनफल व गहराई के अनुसार विश्... | null | null | null |
null | Write a function in Python to extract the domain name from an email address. | test@example.com | def get_domain_name_from_email(email):
return email.split('@')[-1] |
null | Create a basic Python script for categorizing incoming emails. This script should read incoming emails from an IMAP server, categorize them into spam and not spam, and save them in different folders. | Not applicable | import imaplib
import email
import re
# connect to the IMAP server
imap = imaplib.IMAP4_SSL('imap.gmail.com')
# login
imap.login('example@gmail.com', 'password')
imap.select('inbox')
# fetch messages
status, data = imap.search(None, '(UNSEEN)')
# loop through messages
for msg_id in data[0].split():
typ, messag... |
[CS Wikipedia] Jenő Fuchs
Dr. Jenő Fuchs (29. října 1882 Budapešť – 14. března 1955 tamtéž) byl maďarský sportovní šermíř, specialista na šerm šavlí. Narodil se v Budapešti v židovské rodině. Vyhrál soutěž jednotlivců i družstev na Letních olympijských hrách 1908 i Letních olympijských hrách 1912. Jeho celková olympij... | null | null | null |
null | Write a function that takes in a string and returns a list of all the words that have more than 5 characters | def long_words(string): words = string.split() long_words_list = [] for word in words: if len(word) > 5: long_words_list.append(word) return long_words_list | |
null | Create a for loop that prints the contents of a list of strings. | list_of_strings = ["John", "Bob", "Jill", "Sara"] | list_of_strings = ["John", "Bob", "Jill", "Sara"] for name in list_of_strings: print(name) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.