text stringlengths 141 2.89k ⌀ | instruction stringlengths 19 1.5k ⌀ | input stringlengths 0 800 ⌀ | output stringlengths 1 2.5k ⌀ |
|---|---|---|---|
null | Create a Python class for a TV Show with attributes for title, season number, episode number, and rating. | Not applicable | class TVShow:
def __init__ (self, title, season_number, episode_number, rating):
self.title = title
self.season_number = season_number
self.episode_number = episode_number
self.rating = rating
def get_title(self):
return self.title
def get_season_number(self):
return self.season_nu... |
null | Create a Python program to print a formatted table of grades for a given set of students. | Students = [
{
'name': "John",
'grade': 92
},
{
'name': "Alice",
'grade': 95
},
{
'name': "Bob",
'grade': 87
}
] | def print_grade_table(students):
max_name_length = max(len(student['name']) for student in students)
line_template = "{{name:<{max_name_length}}} {{grade}}".format(max_name_length=max_name_length)
header = line_template.format(name='Name', grade='Grade')
sep = '-' * len(header)
print(header)
p... |
null | Create a Python function which takes a list of numbers and returns a list of median values. | list = [1, 2, 4, 16, 8, 10] | def get_medians(input_list):
'''Returns list of median values of the list of numbers given.'''
medians = []
l = len(input_list)
for i in range(l):
tuple_l = input_list[:i]+input_list[i+1:] # Exclude the current element while calculating median.
tuple_l.sort()
l_1 = len(tuple_l... |
[DE Wikipedia] Sophie Lewis
Sophie Lewis ist der Name folgender Personen: * Sophie Lewis (Autorin), deutsch-britische Autorin Sophie Lewis (Radsportlerin) (* 2002), britische Radrennfahrerin | null | null | null |
[CS Wikipedia] Římskokatolická farnost Kostelec
Římskokatolická farnost Kostelec je územním společenstvím římských katolíků v rámci vikariátu České Budějovice - venkov českobudějovické diecéze. O farnosti Historie Plebánie v Kostelci (místní části Hluboké nad Vltavou)je písemně doložena v roce 1379, později však zanik... | null | null | null |
null | Write a python program that creates and prints a range of numbers. | Start from 0, increment by 2 and end at 10 | for number in range(0, 11, 2):
print(number) |
null | Build a TensorFlow model to perform sentiment analysis on text. | import tensorflow as tf # Get the data dataset = tf.keras.utils.get_file( 'aclImdb_v1.tar.gz', 'http://ai.stanford.edu/~amaas/data/sentiment/aclImdb_v1.tar.gz') # Load the data and prepare it for the model reviews_train, reviews_test, labels_train, labels_test \ = tf.keras.datasets.imdb.load_data( path=str(dataset)[:-7... | |
[DE Wikipedia] NEPA
NEPA steht für: Nuclear Energy for the Propulsion of Aircraft; deutsch: Nuklearenergie für den Flugzeug-Antrieb, siehe Convair X-6 National Environmental Policy Act, ein Umweltgesetz in den USA von 1970, siehe auch Umweltverträglichkeitsprüfung New England Press Association, eine Nachrichtenagentur... | null | null | null |
[HI Wikipedia] चम्पावत की आदमखोर बाघिन
चम्पावत की आदमखोर बाघिन जिम कार्बेट का प्रथम शिकार थी जिसका वर्णन उन्होंने अपनी पुस्तक "कुमाओं के नरभक्षी "में किया है। जिम कार्बेट चम्पावत जिला | null | null | null |
null | Create an array from 0 to n-1. | n = 10 | arr = [x for x in range(0, n)] print(arr) |
null | Implement a program in Python to separate odd and even numbers in separate arrays. | def separate_odd_even(arr):
odd = []
even = []
for num in arr:
if num % 2 == 0:
even.append(num)
else:
odd.append(num)
return odd, even | |
null | Output the sum of numbers in a list in Python. | [1, 2, 3, 4, 5] | def list_sum(inpList):
sum = 0
for num in inpList:
sum += num
return sum
print(list_sum([1, 2, 3, 4, 5])) |
null | Write a Python program to generate an encrypted version of the given string using Caesar’s Cipher. | string='Hello World' | def encrypt(string, key):
# Create an empty output string
output = ""
# For each character in the given string
for char in string:
# Convert to ASCII value
char_ascii = ord(char)
# Add the key (shift)
shifted = char_ascii + key
# Convert to charac... |
null | Optimize a Python program to reverse an array in place. | [1, 2, 3, 4] | def reverse_in_place(arr):
low = 0
high = len(arr) - 1
while low < high:
arr[low], arr[high] = arr[high], arr[low]
low += 1
high -= 1
return arr
arr = [1, 2, 3, 4]
print(reverse_in_place(arr)) |
[CS Wikipedia] Neuilly-sur-Seine
Neuilly-sur-Seine (výslovnost: [nœji syʀ sɛn]) je město ležící na severozápadní hranici Paříže (asi 6,8 km od centra); spadá pod departement Hauts-de-Seine, region Île-de-France. Spolu se 6., 7. a 8. obvodem patří k nejhustěji obydleným čtvrtím Paříže a obydleným obcím v Evropě. Geogra... | null | null | null |
[EN Wikipedia] Amore & Vita
Amore & Vita () is a continental cycling team founded in 1989. It is registered in Ukraine and it participates in UCI Continental Circuits races. Team history The team's origins date to 1948 when Lorenzo Fanini founded an amateur cycling team. The team website states it is "the oldest profe... | null | null | null |
[HI Wikipedia] दूझे
दूझे () चीनी भाषा में जनवादी गणतंत्र चीन से छपने वाली सामान्य दिलचस्पी की एक पत्रिका है। यह चीन में सबसे ज़्यादा बिकने वाली पत्रिका है और इसमें नए लेख, अन्य पत्रिकाओं से लिए गए लेख, लघु कहानियाँ, पुस्तकों के अंश, लतीफ़े, इत्यादि छापे जाते हैं। इसका प्रकाशन १९८१ में लान्झू शहर में शुरू हुआ था और इ... | null | null | null |
null | Write a proper open-ended text classification model in Python. | import pandas as pd
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import BernoulliNB
# preprocess and load the data
data = pd.read_csv('Dataset.csv')
X = data['text']
y = data['label']
vectorizer = CountVectorizer(binary= True... | |
null | Draft an HTML page with a table that contains three columns and two rows. | <html> <head> <title>Table Example</title> </head> <body> <table> <tr> <th>Column 1</th> <th>Column 2</th> <th>Column 3</th> </tr> <tr> <td>Row 1 Data 1</td> <td>Row 1 Data 2</td> <td>Row 1 Data 3</td> </tr> <tr> <td>Row 2 Data 1</td> <td>Row 2 Data 2</td> <td>Row 2 Data 3</td> </tr> </table> </body> </html> | |
null | Write a SQL statement to select all rows in a table. | Table name: student_info | SELECT * FROM student_info; |
null | Write a function in JavaScript which takes an array of numbers and returns the average of all the numbers. | function getAverage(arr) { let sum = 0; for (let i = 0; i < arr.length; i++) { sum += arr[i]; } return sum / arr.length; } | |
null | Develop a Python script to automate the web application UI testing. | import unittest
from selenium import webdriver
class LoginForm(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.get('http://example.com/login')
def test_login_form(self):
username_field = self.driver.find_element_by_name('user[username]')
user... | |
null | Generate a classification network in a deep learning framework. | import tensorflow as tf from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Activation model = Sequential() model.add(Dense(64, input_dim = 8)) model.add(Activation('relu')) model.add(Dense(16)) model.add(Activation('sigmoid')) model.add(Dense(2)) model.add(Activation('softmax')) m... | |
null | Create a Python program to sort a list of numbers from lowest to highest. | [5, 2, 3, 7, 4] | def sort_list(numbers):
numbers.sort()
return numbers
# Driver code
numbers = [5, 2, 3, 7, 4]
print(sort_list(numbers)) |
[CS Wikipedia] Druhá vláda Oldřicha Černíka
Druhá vláda Oldřicha Černíka existovala v období od 1. ledna 1969 do 27. září 1969. Jednalo se o první československou federální vládu. Seznam členů vlády Předseda vlády: Oldřich Černík Místopředseda vlády: Peter Colotka, do 30. 1. 1969 Samuel Falťan František Hamouz Václav ... | null | null | null |
null | Write a SQL query to find the average score of students who are aged between 20 and 23. | SELECT AVG(score) FROM students WHERE age BETWEEN 20 AND 23; | |
null | What kind of data structure is used for a queue in Java? | A queue in Java is typically implemented using a linked list or an array. | |
null | Write a TensorFlow script to build a 3-layer neural network classifier. | import tensorflow as tf #Create placeholders X = tf.placeholder(tf.float32, [None, 784]) y = tf.placeholder(tf.float32, [None, 10]) #Create first layer W1 = tf.Variable(tf.truncated_normal([784, 300], stddev=0.1)) b1 = tf.Variable(tf.zeros([300])) A1 = tf.nn.relu(tf.add(tf.matmul(X, W1), b1)) #Create second layer W2 = ... | |
[HI Wikipedia] वितरणानुसार विश्व के समाचारपत्रों की सूची
यह औसत वितरण के आधार पर दुनिया के दैनिक समाचारपत्रों की सूची है। इन आंकड़ों के स्रोत 'वितरण परिक्षण संस्थानों के विश्व संघ' (International Federation of Audit Bureaux of Circulations) और 'अख़बार व समाचार प्रकाशकों की अंतर्राष्ट्रीय सभा' (World Association of Ne... | null | null | null |
[CS Wikipedia] Héctor Scarone
Héctor Pedro Scarone Beretta (26. listopadu 1898 – 4. dubna 1967) byl uruguayský fotbalista. Hrával na pozici útočníka. S uruguayskou fotbalovou reprezentací vyhrál první mistrovství světa roku 1930 (Scarone v all-stars týmu turnaje) a také fotbalový turnaj olympijských her v letech 1924 ... | null | null | null |
[DE Wikipedia] Landesärztekammer Hessen
Als Körperschaft des öffentlichen Rechts vertritt die Landesärztekammer Hessen (LÄKH) die beruflichen Belange ihrer Mitglieder auf allen Gebieten ärztlicher Berufsausübung. Sie überwacht die Einhaltung der Berufspflichten der hessischen Ärzteschaft und bietet als Dienstleister B... | null | null | null |
null | Using the list of numbers, create a function to sort the list into ascending order. | numbers = [6, 4, 3, 2, 8] | def sort_ascending(numbers): numbers.sort() return numbers |
[CS Wikipedia] Záhon
Záhon je plocha v zahradě, nebo parku určená na zpravidla dočasnou výsadbu rostlin. Květinové záhony mohou na jednu sezónu vytvořit barevný obrazec. Záhon v okrasné zahradě nebo parku je prvek úpravy zahradní architektury používaný podle zásad sadovnické tvorby. Zeleninové záhony jsou určeny k pěs... | null | null | null |
[HI Wikipedia] स्वीडन
स्वीडन (स्वीडिश: Konungariket Sverige कूनुङारीकेत् स्वेरिये) यूरोपीय महाद्वीप में उत्तर में स्केंडिनेविया प्रायद्वीप में स्थित एक देश है। स्टॉकहोल्म इसकी राजधानी और सबसे बड़ा शहर है। स्वीडिश भाषा इसकी मुख्य और राजभाषा है। यहाँ एक संवैधानिक और लोकतान्त्रिक राजतन्त्र है। स्वीडन के पश्चिम एवं उत्तर ... | null | null | null |
null | Generate code in Python to print out the common elements of two sorted lists in linear time. | def find_common_elements(list1, list2):
common_elements = []
i = 0
j = 0
while i < len(list1) and j < len(list2):
if list1[i] == list2[j]:
common_elements.append(list1[i])
i += 1
j += 1
elif list1[i] > list2[j]:
j += 1
else:
... | |
null | Optimize a Python script to find the maximum value of a series of numbers. | lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | def find_max(lst):
max_value = None
for number in lst:
if max_value is None or number > max_value:
max_value = number
return max_value
# Main
lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
max_value = find_max(lst)
print('The maximum value of the list is {}'.format(max_value)) |
[CS Wikipedia] Billboard (časopis)
Billboard (The International Music-Record-Tape Newsweekly) je americký týdeník věnující se hudebnímu průmyslu a hudebním žebříčkům. Byl založen v roce 1894, v Los Angeles. Magazín informuje o hitparádách a příčkách; nejznámější hitparáda je zřejmě Billboard Hot 100, ve které jsou pís... | null | null | null |
null | Write a JavaScript code to create a timer that counts down from 10. | let countDown = 10; let interval = setInterval(() => { countDown--; if (countDown == 0) { clearInterval(interval); } }, 1000); | |
null | Write an algorithm in Python that finds the maximum of three numbers. | Not applicable | def find_max(a, b, c):
if a > b and a > c:
max_num = a
elif b > a and b > c:
max_num = b
else:
max_num = c
return max_num
max_number = find_max(7, 5, 9)
print("The maximum of three numbers is:", max_number) |
[DE Wikipedia] Brunei Super League 2018/19
Die Brunei Super League 2018/19 war die sechste Spielzeit der höchsten Fußballliga in Brunei. Organisiert wurde die Liga von der National Football Association of Brunei Darussalam. Titelverteidiger war MS ABDB. Die Saison startete mit dem ersten Spieltag am 26. Oktober 2018 u... | null | null | null |
null | Change the following program to use a try/except/finally block to handle errors. | def read_file(file): with open(file) as f: for line in f: print(line) | try: def read_file(file): with open(file) as f: for line in f: print(line) except IOError: print("Error: Could not read file") finally: print("Closing file") f.close() |
[CS Wikipedia] T-buněčný receptor
T-buněčný receptor (TCR, z anglického T-cell receptor) je molekula nacházející se na povrchu T-lymfocytů. Ve většině případů TCR rozpoznává antigenní peptidy prezentované na molekulách hlavního histokompatibilního komplexu (MHC). Signalizace přes TCR a s ním asociované molekuly (CD3 k... | null | null | null |
null | Create a CSS style sheet to change the font color of an heading to red. | h1 { color: red; } | |
null | Create a function that will find the maximum length of increasing subarray in a list | list = [2, 3, 3, 1, 4, 5, 8, 4] | def longest_increasing_subarray(arr): max_length = 1 curr_length = 1 for i in range(1, len(arr)): if arr[i] > arr[i - 1]: curr_length += 1 else: if curr_length > max_length: max_length = curr_length curr_length = 1 if curr_length > max_length: max_length = curr_length return max_length |
null | Offer a suggestion for increasing the performance of the following Python Script | def function(arg):
for i in range(len(arg)):
print(i) | def function(arg):
for i in arg:
print(i) |
null | Optimize the following code to improve its runtime:
```Python
for x in range(10):
sum = 0
for y in range(10):
sum += y
print sum
``` | Not applicable | sum = 0
for y in range(10):
sum += y
print sum
for x in range(10):
print sum |
null | Create an HTML table containing 3 row and 3 column of text elements. | Table with 9 text elements | <table> <tr> <td>Text 1</td> <td>Text 2</td> <td>Text 3</td> </tr> <tr> <td>Text 4</td> <td>Text 5</td> <td>Text 6</td> </tr> <tr> <td>Text 7</td> <td>Text 8</td> <td>Text 9</td> </tr> </table> |
[CS Wikipedia] Hendrik Adamson
Hendrik Adamson (6. října/24. září jul. 1891 Kärstna – 7. března 1946 Tuhalaane, Estonsko) byl esperantsky píšící estonský spisovatel a učitel. Jeho hlavním dílem je román Aŭli (Auli), o životě malého chlapce. Mezi jeho básnická díla patří sbírka (Večerní píseň). Mnoho jeho básní vyšlo n... | null | null | null |
null | How does one go about creating a function in JavaScript? | In JavaScript, functions are declared using the 'function' keyword followed by the name of the function and a pair of parentheses. The code for the function should be enclosed within curly brackets. For example: function addTwoNumbers(a, b) { return a + b; } | |
null | Write a code snippet in Python to split a string by its whitespaces. | string = "This is a sample string" | string = "This is a sample string"
str_list = string.split()
print(str_list) |
null | Write a java code to calculate the sum of two numbers provided as input. | int num1 = 25; int num2 = 24; | int result = num1 + num2; System.out.println(result); |
null | Given a set of points and an origin point, calculate the distance between the origin point and each point in the set. | [(1,1),(4,4),(3,3)] (0,0) | """ Given a set of points and an origin point, calculate the distance between the origin point and each point in the set """ import math def points_distance(points, origin): distances = [] for point in points: distances.append(math.sqrt((point[0]-origin[0])**2 + (point[1]-origin[1])**2)) return distances if __name__ ==... |
null | Create a web scraping script in Python that extracts all the users and their reviews from a page on TripAdvisor. | The URL of the page: https://www.tripadvisor.com/Hotel_Review-g469893-d13034369-Reviews-The_Fountainhead_Hotel-San_Fernando_Trinidad_Tobago.html | from lxml import html
import requests
url = "https://www.tripadvisor.com/Hotel_Review-g469893-d13034369-Reviews-The_Fountainhead_Hotel-San_Fernando_Trinidad_Tobago.html"
page = requests.get(url)
tree = html.fromstring(page.content)
user_names = tree.xpath('//a[@class="scrname"]/text()')
review_texts = tree.xpath('//p... |
null | Write a Haskell program to convert a given string to an Integer. | string text = "12345" | stringToInt :: String -> Int stringToInt x = read x :: Int |
null | Write a function to calculate all the possible paths for a N x N matrix. | def calculate_paths(matrix): rows = len(matrix) cols = len(matrix[0]) dp = [[0 for _ in range(cols)] for _ in range(rows)] dp[0][0] = 1 for i in range(rows): for j in range(cols): if i-1 >= 0: dp[i][j] = dp[i][j] + dp[i-1][j] if j-1 >= 0: dp[i][j] = dp[i][j] + dp [i][j-1] return dp[rows-1][cols-1] | |
null | Design a neural network to recognize handwritten digits in Python. | Not applicable | import numpy as np
import tensorflow as tf
from tensorflow.keras import layers
# define the model
model = tf.keras.Sequential()
model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layer... |
null | Print prime numbers in the given range. | Lower range: 10 Upper range: 30 | for num in range(10, 30 + 1): # prime numbers are greater than 1 if num > 1: for i in range(2, num): if (num % i) == 0: break else: print(num) |
null | Modify the following Java code to reverse a given string. | public class SimpleStringReverser { public static String reverse(String str) { String result = ""; | public class SimpleStringReverser { public static String reverse(String str) { String result = ""; for(int i = str.length() - 1; i >= 0; i--) { result += str.charAt(i); } return result; } } |
null | Print out the names of even numbered elements from the given list. | list_of_names = ["John", "Jacob", "Michael", "Peter", "Paul"] | for i in range(0, len(list_of_names), 2): print(list_of_names[i]) |
null | Design a Python algorithm to determine if a given number x is a prime number. | def is_prime(x):
if x < 2:
return False
for i in range(2, int(x ** 0.5) + 1):
if x % i == 0:
return False
return True | |
null | Given two binary trees, check if the first tree is subtree of the second tree. | # Python program to check if
# a binary tree is subtree of another binary tree
# A binary tree node
class Node:
# Constructor to create a new node
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def isSubTree(T, S):
if S is None... | |
null | Rewrite the following code snippet so that it is compatible with Python 3 | sum = 0 for num in range(10): sum = sum + num print sum | sum = 0 for num in range(10): sum += num print(sum) |
null | Create a Python program to calculate the intersection points between two circles. | Circle 1: Center (0, 0) and Radius 3
Circle 2: Center (3, 3) and Radius 6 | """
Create a Python program to calculate the intersection points between two circles
"""
import math
def get_intersection(c1, c2):
# Calculate center distance between two circles
dist = math.sqrt((c1[0] - c2[0]) ** 2 + (c1[1] - c2[1]) ** 2)
# Check if distances between centers is equal to or greater than s... |
null | Create an optimizer in Python to maximize the output of a given function. | import numpy as np
def optimize(func, initial_params):
params = initial_params
best_params = None
best_score = -np.inf
while True:
# Update current parameters
params = update(params)
# Calculate score
score = func(params)
# Check if improved result
if sco... | |
[HI Wikipedia] फ़सल
फसल या शस्य किसी समय-चक्र के अनुसार वनस्पतियों या वृक्षों पर मानवों व पालतू पशुओं के उपभोग के लिए उगाकर काटी या तोड़ी जाने वाली पैदावार को कहते हैं। मसलन गेंहू की फ़सल तब तैयार होती है जब उसके दाने पककर पीले से हो जाएँ और उस समय किसी खेत में उग रहे समस्त गेंहू के पौधों को काट लिया जाता है और उनके क... | null | null | null |
[HI Wikipedia] ओनिकोफोरा
नखी या 'ओनिकोफोरा' (Onychophora) एक्डीसोजोवा संघ है जिसमें लगभग १८० जातियाँ हैं। परिचय 'ओनिकोफोरा' शब्द की व्युत्पत्ति ग्रीक भाषा से है। इसका अर्थ है 'नख रखनेवाले' 'नखी' (Gr. - Onychus claw+phorus - bearing)। इस समूह में चलकृमि (walking worms) आते हैं। ये छोटे नखर रखनेवाले प्राणी हैं, जिनके पै... | null | null | null |
[HI Wikipedia] अणुगति सिद्धांत
प्रत्येक पदार्थ तीन अवस्थायों में पाया जाता है : (i) ठोस (ii) द्रव (iii) गैस | पदार्थ की विभिन्न अवस्थायों में अणुओं की गति भिन्न भिन्न प्रकार की होती है, अंतरा-अणुक दूरी भिन्न-भिन्न होती है तथा अंतरा-अणुक बल भी भिन्न-भिन्न होता है | इसीलिए पदार्थ की विभिन्न अवस्थायों में भौतिक गुण भी भि... | null | null | null |
[HI Wikipedia] न्यूज़ीलैण्ड
न्यूज़ीलैंड प्रशान्त महासागर में ऑस्ट्रेलिया के पास स्थित देश है। ये दो बड़े द्वीपों से बना है। न्यूज़ीलैंड (माओरी भाषा में: आऔतैआरौआ) दक्षिण पश्चिमि प्रशांत महासागर में दो बड़े द्वीप और अन्य कई छोटे द्वीपों से बना एक देश है। न्यूज़ीलैंड के ४० लाख लोगों में से लगभग तीस लाख लोग उत्तरी द्वीप ... | null | null | null |
null | You are given two lists. Output a third list which contains only the elements common to both lists. | list1 = [1, 2, 3, 4, 5] list2 = [3, 4, 5, 6, 7] | list3 = [3,4,5] |
null | Create a basic sentence classifer in Python using NLP. The classifier should be able to classify whether a sentence is about science, technology, or sports. | science and technology has revolutionized how we live | import nltk
from nltk import word_tokenize
from nltk.corpus import stopwords
import sklearn
from sklearn.svm import SVC
# Pre-process input for the classifier
def pre_process(sentence):
stopwords_list = stopwords.words('english')
tokens = word_tokenize(sentence)
lower_tokens = [token.lower() for token in tokens ... |
null | Create a JavaScript code snippet to check the validity of a credit card number. | credit_card_number = ‘1234567891234567’ | function validateCardNumber(credit_card_number) { // remove any non-digits var card_number = credit_card_number.replace(/\D/g, ''); // add odd digits in even length strings or even digits in odd length strings var sum = 0; for (var i = 0; i < card_number.length; i++) { var intVal = parseInt(card_number.substr(i, 1)); i... |
[DE Wikipedia] Haweswater Reservoir
Das Haweswater Reservoir ist ein Stausee im nordenglischen Lake District. Der See verläuft in leicht gebogener Form von Süden nach Nordosten im Tal von Mardale und hat ein Fassungsvermögen von 28 Mio. m³. Beschreibung Ursprünglich gab es zwei natürliche Seen, High Water und Low Wate... | null | null | null |
null | Write a Python function that computes the average of 3 numbers. | 1, 2, 3 | def average(a, b, c):
return (a + b + c) / 3.0
print(average(1,2,3)) # Output: 2.0 |
null | Suggest a Python library to monitor the performance of this system | A distributed system that processes large amounts of data on multiple nodes | The Python library 'celery' can be used to monitor the performance of a distributed system. It provides scalability and concurrency capabilities to handle large amounts of data by distributing tasks across multiple nodes. It also offers task monitoring and management through custom metrics and performance logs. |
null | Implement a given design pattern in Python. | # factory pattern example
class Shape:
sides = 0
def type(self):
print("This is an abstract class")
class Triangle(Shape):
sides = 3
def type(self):
print("This is a triangle")
class Rectangle(Shape):
sides = 4
def type(self):
print("This is a rectangle")
clas... | |
null | Write a Python function to convert a given string to lowercase. | string = "FOO" | def to_lowercase(string): return string.lower() string = "FOO" print(to_lowercase(string)) |
[EN Wikipedia] Algorithm
In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing calculations and data processing. More advanced algorithms ... | null | null | null |
null | Write a code in PHP to convert Celsius to Fahrenheit. | function celsiusToFahrenheit($celsius) { return $celsius * 9 / 5 + 32; } | |
[EN Wikipedia] Percival River
The Percival River is a river of the Canterbury region of New Zealand's South Island. It flows southwest from its origins in the Hanmer Range to the northeast of Hanmer Springs, reaching the Waiau River south of the town. See also List of rivers of New Zealand References Rivers of Canterb... | null | null | null |
null | Write a query in SQL to list the most expensive item from each category. | TABLE items item_id INT PK category VARCHAR price INT | SELECT item_id, category, MAX(price) FROM items GROUP BY category; |
[DE Wikipedia] Provinz Huarmey
Die Provinz Huarmey ist eine der 20 Provinzen, die die Verwaltungsregion Ancash in Peru bilden. In dem 3.908,4 km² großen Gebiet lebten im Jahr 2017 30.560 Menschen, was einer Bevölkerungsdichte von 7,8 Einwohnern pro km² entspricht. Verwaltungssitz ist Huarmey. Geographische Lage Die Pr... | null | null | null |
null | Implement a function to return the element that appears most frequently in a list. | [5,5,5,5,6,6,7,7,7] | def find_most_frequent_element(arr): d = {} for num in arr: if num in d: d[num] += 1 else: d[num] = 1 max_freq = 0 most_frequent_element = None for num in d: if d[num] > max_freq: max_freq = d[num] most_frequent_element = num return most_frequent_element |
[DE Wikipedia] Sepp Trütsch
Sepp Trütsch (* 23. Mai 1949 in Schwyz) ist ein ehemaliger Schweizer Moderator von Volksmusiksendungen und Sänger. Leben Sepp Trütsch schloss an seine Schulzeit an der Kantonsschule Kollegium Schwyz eine Ausbildung zum Drogisten an. Seine musikalische Ausbildung umfasste Gesang und Komposit... | null | null | null |
null | Build a TensorFlow model for classification of a 2-D dataset. | X = [[1, 2], [3, 4], [5, 6]] Y = [0, 1, 1] | """ Build a TensorFlow model for classification of a 2-D dataset. Input: X = [[1, 2], [3, 4], [5, 6]] Y = [0, 1, 1] Output: import tensorflow as tf # data X = tf.constant([[1, 2], [3, 4], [5, 6]], dtype=tf.float32) Y = tf.constant([0, 1, 1], dtype=tf.float32) # model model = tf.keras.Sequential() model.add(tf.keras.lay... |
null | Create a function in Python to calculate the area of a triangle given its base and height. | def triangle_area(base, height):
return (base * height) / 2 | |
[HI Wikipedia] गंगनम जिला
गंगनम जिला (; हंजा: 江南區; गंगनम गु) दक्षिण कोरिया की प्रशासनिक इकाई - गु (स्थानीय सरकारी जिले) जिनसे मिलकर सियोल शहर बना है, में से एक है। गंगनम (강남; 江南 ) का शाब्दिक अर्थ है "(हान) नदी के दक्षिण में"। वर्ष २०१० की जनगणना के अनुसार, गंगनम जिले की कुल जनसंख्या 527,641 है, जो इसे सियोल का चौथा सर... | null | null | null |
[HI Wikipedia] अशोक चक्रधर
डॉ॰ अशोक चक्रधर (जन्म ८ फ़रवरी सन् १९५१) हिंदी के विद्वान, कवि एवं लेखक है। हास्य-व्यंग्य के क्षेत्र में अपनी विशिष्ट प्रतिभा के कारण प्रसिद्ध वे कविता की वाचिक परंपरा का विकास करने वाले प्रमुख विद्वानों में से भी एक है। टेलीफ़िल्म लेखक-निर्देशक, वृत्तचित्र लेखक निर्देशक, धारावाहिक लेखक, निर... | null | null | null |
null | Generate a valid Python program to create an alphabetically sorted list of all the words in a sentence. | "This is a great day" | def sortSentence(sentence):
words = sentence.split(" ")
words.sort()
return words
result = sortSentence("This is a great day")
print(result) |
null | Write a for-loop in Python to find the average of 5 numbers. | 5 numbers: 10, 15, 20, 25, 30 | total = 0
for num in [10, 15, 20, 25, 30]:
total += num
average = total / 5
print(average) |
[EN Wikipedia] George William Forrest
Sir George William David Stark Forrest (1845–1926) was a British educator, journalist and historian, in India from 1872 to 1900. Life He was the second son of George Forrest VC, born at Nasirabad, Ajmer. He matriculated at St John's College, Cambridge in 1866, graduating B.A. in 1... | null | null | null |
null | Write a Python program to find the three numbers from an array whose sum is closest to an given number | arr = [59, 40, 20, 90]
num = 70 | def find_closest_sum(arr, num):
arr.sort()
final_sum = None
closest_sum = None
prev_diff = float("inf")
for i in range(len(arr)):
for j in range(i+1, len(arr)):
for k in range(j+1, len(arr)):
sum = arr[i] + arr[j] + arr[k]
diff = abs(num - sum)
... |
[CS Wikipedia] Římskokatolická farnost Jiříkov
Římskokatolická farnost Jiříkov (lat. Georgswalda) je církevní správní jednotka sdružující římské katolíky na území města Jiříkov a v jeho okolí. Organizačně spadá do děčínského vikariátu, který je jedním z 10 vikariátů litoměřické diecéze. Centrem kostela je kostel svaté... | null | null | null |
null | Write a Python program that takes two strings as input and returns a list of all the words that appear in both strings. | string1 = "This is a string of text"
string2 = "This text is also a string" | string1 = "This is a string of text"
string2 = "This text is also a string"
def find_words_in_both(s1, s2):
list1 = s1.split()
list2 = s2.split()
result = []
for word1 in list1:
for word2 in list2:
if word1 == word2:
result.append(word1)
return result
print(find... |
null | Write a TensorFlow code to classify MNIST. | # Load the MNIST dataset (x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data() # Reshape and normalize the input data x_train = x_train.reshape(x_train.shape[0], 28, 28, 1) x_test = x_test.reshape(x_test.shape[0], 28, 28, 1) x_train = x_train.astype('float32') x_test = x_test.astype('float32') x_tr... | |
null | Create a function for checking valid passwords in Python. | def check_valid_password(pwd):
length_valid = (len(pwd) >= 8)
has_uppercase = False
has_lowercase = False
has_digit = False
for char in pwd:
if char.isupper():
has_uppercase = True
elif char.islower():
has_lowercase = True
elif char.isnumeric():
has_digit = True
valid = length_valid and has_uppercase and h... | |
null | Using Python, write a program to find the most common element among a list of numbers | [4, 8, 9, 4, 6, 4, 8] | def most_frequent(list):
return max(set(list), key = list.count)
list = [4, 8, 9, 4, 6, 4, 8]
print(most_frequent(list)) |
null | Write a bash script to list all subdirectories located in the current working directory. | #!/bin/bash for directory in * do if [ -d $directory ] then echo $directory fi done | |
null | Sort a list of integers in ascending order using selection sort. | [ 9, 5, 2, 0, 7, 4, 1, 8, 6, 3] | def selection_sort(list): for i in range(len(list)): min_idx = i for j in range(i+1, len(list)): if list[min_idx] > list[j]: min_idx = j list[i], list[min_idx] = list[min_idx], list[i] list = [9, 5, 2, 0, 7, 4, 1, 8, 6, 3] selection_sort(list) print ("Sorted array:", list) |
null | Write a python loop to print all the numbers from 1 to 10. | for i in range(1,11):
print(i) | |
null | Create a function in Python that takes two inputs: a number and a list of numbers. The function should return a list of numbers that sum to the input number. | number = 5
nums = [1, 2, 3, 4] | def find_sum(number, nums):
result_list = []
for i in range(len(nums)-1):
for j in range(i+1, len(nums)):
if nums[i] + nums[j] == number:
result_list.append([nums[i], nums[j]])
return result_list
result = find_sum(number, nums)
print(result) # [[1, 4], [2, 3]] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.