text stringlengths 141 2.89k ⌀ | instruction stringlengths 19 1.5k ⌀ | input stringlengths 0 800 ⌀ | output stringlengths 1 2.5k ⌀ |
|---|---|---|---|
null | Using the given variables, create an if-else statement that prints "You are an adult" when age is greater than or equal to 18, otherwise print "You are a minor". | age = 18 | if age >= 18: print("You are an adult") else: print("You are a minor") |
null | Generate a python function to find the largest number from the given list | [10, 20, 40, 19] | def largest_number(list):
largest = list[0]
for number in list:
if number > largest:
largest = number
return largest |
null | Fetch the item from the given JSON response. | JSON Response: { "results": [ { "id": 1, "name": "John" }, { "id": 2, "name": "Dave" } ] } | item = json_response['results'][1] id = item['id'] name = item['name'] |
null | Write a function in PHP that takes in two arrays, and returns a new array that contains only elements present in both arrays. | [1, 3, 4], [2, 4, 6] | function intersect_arrays($arr1, $arr2) { return array_intersect($arr1, $arr2); } |
null | Optimize a Python program that calculates the sum of the numbers up to a given integer. | integer = 5
def calculateSum(n):
sum = 0
for i in range(n+1):
sum = sum + i
return sum
print(calculateSum(integer)) | def calculateSum(n):
return (n * (n+1))//2
print(calculateSum(integer)) |
[EN Wikipedia] Billy Wootton
William Wootton (27 August 1904 – 2000) was an English footballer who played as a full-back for Stoke, Congleton Town, Port Vale, and Southend United. He later managed Northwich Victoria, Oldham Athletic, and Halifax Town. He won the Third Division North title with Port Vale in 1929–30, an... | null | null | null |
null | Write a Python function that takes a list of strings and returns the concatenation of all the elements with a separator/delimiter. | strings = ["Sample","Text","Hello"] | def concatenate_strings(strings, separator):
return separator.join(strings) |
null | Given a Python dictionary, write a program to remove all the keys whose value is greater than a specified number. | dictionary = {'a': 1, 'b': 2, 'c': 3, 'd':4}, threshold = 2 | dictionary = {'a': 1, 'b': 2, 'c': 3, 'd':4}
threshold = 2
def remove_keys(dict, threshold):
to_remove = [k for k, v in dict.items() if v > threshold]
for k in to_remove:
del dict[k]
return dict
print(remove_keys(dictionary, threshold))
# Output: {'a': 1, 'b':2} |
null | Create a REST API in Python with the Flask framework that returns a list of posts from a blog when a GET request is made. | Not applicable | from flask import Flask, jsonify
app = Flask(__name__)
posts = [
{
"id": 1,
"title": "Lorem Ipsum",
"body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
},
{
"id": 2,
"title": "Sed Ut Perspiciatis",
"body": "Sed ut perspiciatis ... |
null | Suggest a way to identify and remove duplicate elements from the list. | numbers = [2, 3, 2, 5, 8, 3, 10] | # Method 1 - Using Set numbers_set = set(numbers) numbers_set = list(numbers_set) print(numbers_set) # Output: [2, 3, 5, 8, 10] # Method 2 - Using Loop no_duplicate = [] for num in numbers: if num not in no_duplicate: no_duplicate.append(num) print(no_duplicate) # Output: [2, 3, 5, 8, 10] |
null | Explain different types of sorting algorithms in brief. | There are several types of sorting algorithms which can be used to sort a list of items. The most common ones are Bubble Sort, Insertion Sort, Selection Sort, Quick Sort, Merge Sort and Heap Sort. Bubble Sort works by repeatedly swapping adjacent elements if they are in the wrong order. Insertion Sort works by insertin... | |
null | Detect if the given URL contains a query string. | url = https://www.example.com/?food=burger | True |
null | How can you access the fourth element of a linked list in Java? | The fourth element of a linked list in Java can be accessed by traversing the list from the start node three times, where each traverse proceeds one node at a time. The fourth node can be accessed by calling getData() on the traversed node. | |
[CS Wikipedia] Jižní Amerika
Jižní Amerika je jižní část amerického kontinentu. Celá tato část se nachází na západní polokouli. Její větší část je na jižní polokouli, menší na severní polokouli (čtyři země – Venezuela, Guyana, Surinam a Francouzská Guyana – leží celým svým územím na severní polokouli). Kontinentem pro... | null | null | null |
null | Using variable A, write a code snippet in Java to iterate through ArrayList and delete odd values. | // ArrayList A ArrayList<Integer> A = new ArrayList<>(Arrays.asList(1,2,3,4,5,6)); | for(int i=0; i<A.size(); i++) { if(A.get(i) %2 != 0) { A.remove(i); i--; } } |
null | Write JavaScript code to output a square pattern of 5 stars. | for (let i = 0; i < 5; i++) { let line = ''; for (let j = 0; j < 5; j++) { line += '*'; } console.log(line); } | |
[EN Wikipedia] Galaxy 3 (disambiguation)
Galaxy 3 may refer to: Samsung Galaxy 3, an Android smartphone produced by Samsung Electronics. Galaxy 3 (satellite), a satellite belonging to the Intelsat's Galaxy fleet. | null | null | null |
null | Identify the key differences between a set and a dictionary in Python. | The key difference between a set and a dictionary in Python is that a set stores unordered elements while a dictionary stores key-value pairs. Additionally, dictionaries have a set of keys that are unique and immutable, while sets are unordered collections of unique and immutable elements. Sets are more efficient for s... | |
null | Transform the following code from JavaScript to Python. | if (cur_price > max_price) {
max_price = cur_price;
} | if cur_price > max_price:
max_price = cur_price |
null | Write a code to get the sum of all the unique values in a dictionary. | d = {'a': 2, 'b': 3, 'c': 4, 'd': 5} | total_sum = 0 for key in d: total_sum += d[key] print(total_sum) |
null | Write a function to calculate the sum of the elements of an array with float values. | def sum_float_array(float_array): total = 0 for i in float_array: total += i return total | |
[CS Wikipedia] Philip Seymour Hoffman
Philip Seymour Hoffman (23. července 1967 Fairport, New York, USA – 2. února 2014 Manhattan, New York, USA) byl americký filmový herec, režisér a producent. Byl nejlépe známý pro jeho specifický styl hraní, kdy hrál většinou tyrany a nepřizpůsobivé hrdiny. Byl nominován na mnoho o... | null | null | null |
null | Construct a web crawler in python and count the number of words in a web page. | import requests
from bs4 import BeautifulSoup
# url of the website to crawl
URL = "https://www.example.com/"
# get the whole page content in
# the form of text
page = requests.get(URL).text
# number of words in the page
word_count = 0
# create a Beautiful Soup parsable string
soup = BeautifulSoup(pag... | |
null | Create a Python program to find the nth Fibonacci number | def Fibonacci(n):
if n<0:
print("Incorrect input")
elif n==0:
return 0
elif n==1:
return 1
else:
return Fibonacci(n-1)+Fibonacci(n-2) | |
null | Construct a linked list data structure in Python | class Node:
def __init__(self, data):
self.data = data
self.next = None
# Linked List class contains a Node object
class LinkedList:
def __init__(self):
self.head = None
def push(self, data):
# Allocate the Node & Put in the data
new_node = Node(data)
... | |
null | Create an array from a given string and sort it in ascending order. | string = "cbaefd" | string = "cbaefd" array = list(string) array.sort() print(array) |
null | Develop a function in Python which takes two inputs and returns the greatest common divisor of those two numbers. | 12, 24 | def greatest_common_divisor(a, b):
if a < b:
a, b = b, a
while b > 0:
a, b = b, a % b
return a
result = greatest_common_divisor(12, 24)
print(result) |
null | Explain why this code doesn't work. | def celsius_to_fahrenheit(celsius): return celsius + 5 | This code doesn't work because it doesn't follow the formula for converting Celsius temperatures to Fahrenheit. The formula for converting Celsius to Fahrenheit is F = (C * 9/5) + 32, where F is the Fahrenheit temperature and C is the Celsius temperature. The code provided only adds 5 to the Celsius temperature, which ... |
null | Add styling to the HTML anchor tag. | <a href="index.html">Home</a> | <a style="color: blue; font-weight: bold" href="index.html">Home</a> |
[DE Wikipedia] Angeliki Papoulia
Angeliki Papoulia (, * 1975 in Agios Dimitrios bei Athen) ist eine griechische Theater- und Filmschauspielerin. Sie ist vor allem für ihre Rollen in den Filmen von Giorgos Lanthimos bekannt. Leben Nach mehreren Kurzfilmrollen zwischen 1999 und 2002 und einem kleineren Auftritt 2001 in ... | null | null | null |
null | Design a Python program to randomize a list of given integers using an optimized Fisher-Yates algorithm. | def randomized_list(num_list):
for i in range(len(num_list)-1,0,-1):
j = random.randint(0,i)
num_list[i],num_list[j] = num_list[j],num_list[i]
return num_list | |
null | Create a program that extracts a given pattern from a given string | text = "Hello world!", pattern = "l" | """ Create a program that extracts a given pattern from a given string """ def extract_pattern(text, pattern): result = [] for i in range(len(text)): if text[i] == pattern: result.append(i) return result if __name__ == '__main__': text = "Hello world!" pattern = "l" print(extract_pattern(text, pattern)) |
null | Describe how to add an element in a linked list in Python. | // To add an element in a linked list in Python: // 1. Create a new node containing the value to be added // 2. Set the "next" attribute of the new node to point to the current head node // 3. Set the head node to be the newly created node // 4. Increase the size of the linked list by 1 | |
null | Design a SVM classifier in Python to classify the given dataset for sentiment analysis. | dataset = [
{'text': 'I love this product', 'sentiment': 'positive'},
{'text': 'I hate this product', 'sentiment': 'negative'},
{'text': 'This product is awful', 'sentiment': 'negative'},
{'text': 'This product is great', 'sentiment': 'positive'}
] | import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.svm import SVC
df = pd.DataFrame(dataset)
X = df['text']
y = df['sentiment']
# Create the vectorizer
vectorizer = TfidfVectorizer()
# Fit and transform the vectorizer to X
X_vect = vectorizer.fit_transform(X)
# Initialize t... |
null | Write a Python program to generate a password of length 10 from lowercase alphabets, uppercase alphabets, digits and special characters. | import random
import string
length = 10
def generatePassword(length):
chars = string.ascii_lowercase + string.ascii_uppercase + string.digits + "!@#$%^&*"
return ''.join([random.choice(chars) for _ in range(length)])
password = generatePassword(length)
print(password) | |
[DE Wikipedia] ULEB Cup 2007/08
Die Saison 2007/08 war die 6. Spielzeit des von der ULEB ausgetragenen ULEB Cup, der heute als EuroCup firmiert. Es war die letzte Durchführung des Wettbewerbs unter diesem Namen. Am 2. Juli 2008 gaben die ULEB und FIBA Europa bekannt, dass ab der nächsten Saison dieser Wettbewerb unter... | null | null | null |
[CS Wikipedia] Tripolis (Řecko)
Tripoli (řecky , do 19. století , , italsky Tripolizza) je město v Řecku, v Peloponéském kraji Arkádie, jejímž je i hlavním městem. Žije zde 25 520 obyvatel. Název Původ jména Tripolitsa je pravděpodobně slovanský, protože se město původně nazývalo Droboglitsa (Δρομπογλίτσα), což se měl... | null | null | null |
[HI Wikipedia] वीर्य
वीर्य एक जैविक तरल पदार्थ है, जिसे औरत कि योनि मे छौड़ा जाता हैबीजीय या वीर्य तरल भी कहते हैं, जिसमे सामान्यतः शुक्राणु (स्पर्म) होते हैं। यह जननग्रन्थि (यौन ग्रंथियाँ) तथा नर या उभयलिंगी प्राणियों के अन्य अंगों द्वारा स्रावित होता है और मादा अंडाणु को निषेचित कर सकता है। इंसानों में, शुक्राणुओं क... | null | null | null |
null | Create a Python script to perform sentiment analysis on a given text. The application should use a pre-trained machine learning model to analyze the sentiment and output either 'positive', 'negative', 'neutral', or 'mixed' sentiment. | The product was amazing and I highly recommend it! | import nltk
import sklearn
nltk.download('vader_lexicon')
from nltk.sentiment.vader import SentimentIntensityAnalyzer
text = "The product was amazing and I highly recommend it!"
analyzer = SentimentIntensityAnalyzer()
sentiment = analyzer.polarity_scores(text)
if sentiment['compound'] > 0.05:
sentiment_text = "pos... |
null | Write a code to parse the following JSON into a dictionary | { "firstName": "John", "lastName": "Smith", "age": 25 } | import json def parse_json(json_data): data = json.loads(json_data) return {key: data[key] for key in data} |
null | Create a ruby method for finding the frequency of an element in an array. | array = [2, 3, 4, 3, 2, 5, 2] | def frequency(array) frequency_hash = Hash.new(0) array.each { |num| frequency_hash[num] += 1 } frequency_hash end puts frequency(array) // {2=>3, 3=>2, 4=>1, 5=>1} |
null | Debug the following code so it can print the corresponding JSON data correctly. | import json people_string = '{"name": "John Smith", "age": 50, "profession": "engineer"}' data = json.loads(people_string) print("Name: ", data["name"]) | import json people_string = '{"name": "John Smith", "age": 50, "profession": "engineer"}' data = json.loads(people_string) print("Name: ", data["name"]) print("Age: ", data["age"]) print("Profession: ", data["profession"]) |
null | Develop a C program to print a pattern like a pyramid. | #include <stdio.h> int main() { int i, j, k, rows; printf("Enter the number of rows \n"); scanf("%d",&rows); for(i=1; i<=rows; i++ ) { for(k=rows; k >= i; k--) printf(" "); for(j=1; j<= (2*i-1) ; j++ ) printf("*"); printf("\n"); } return 0; } | |
null | Implement a Python method to encrypt a given string. | text = "Hello, World!" | def encrypt(text):
result = ""
for i in range(len(text)):
char = text[i]
if (char.isupper()):
result += chr((ord(char) + 7))
else:
result += chr((ord(char) + 3))
return result
text = "Hello, World!"
print(encrypt(text)) |
null | Write a python program to clean up a list of emails and put them into a new list. | The original list of emails:
['bob@example.com', 'alice+bob@cafe.com', 'bob@gmail.com.uk', 'bob+alice@example'] | original_list = ['bob@example.com', 'alice+bob@cafe.com', 'bob@gmail.com.uk', 'bob+alice@example']
clean_list = []
for email in original_list:
email_without_plus = email.split('+')[0]
email_without_dot_uk = email_without_plus.split('.uk')[0]
clean_list.append(email_without_dot_uk)
print(clean_list) # prints ['bob... |
[HI Wikipedia] हिन्दी शब्द संसाधक
अधिकतर नये शब्द संसाधक इण्डिक समर्थन युक्त हैं, इसलिये हिन्दी में अच्छा कार्य करते हैं। माइक्रोसॉफ्ट ऑफिस हिन्दीकाफी सुविधाजनक हिन्दी शब्द संसाधक (वर्ड प्रोसैसर) है। इसके अतिरिक्त सीडैक का आइलीप, मोड्यूलर इन्फोटैक का श्रीलिपि, देशवेब का अक्षरमाला, बालेन्दु दाधीच का माध्यम (निःशुल्क), ... | null | null | null |
null | Edit the given code to fix the bug | def calculate_tax(price): tax_rate = 0.20 total = price + (price * tax_rate) return total | def calculate_tax(price): tax_rate = 0.20 total = price + (price * tax_rate) return round(total, 2) |
[DE Wikipedia] 2,4,5-Triphenylimidazol
2,4,5-Triphenylimidazol (Trivialname: Lophin) ist ein Vertreter der Imidazole, welcher unter Einwirkung von UV-Licht fluoresziert und in basischem Medium chemoluminesziert. Es wurde 1877 erstmals von dem polnischen Chemiker Bronisław Radziszewski (1838–1914) als erste künstliche,... | null | null | null |
null | Given two integers, write a Python function to find their greatest common divisor (GCD). | num1 = 24
num2 = 18 | def find_gcd(num1, num2):
gcd = 1
while num2 != 0:
temp = num2
num2 = num1 % num2
num1 = temp
gcd = num1
return gcd |
null | Create an algorithm in Python that takes a string and returns the longest palindromic substring in it. | Not applicable | # Function to find the longest palindromic substring
def longestPalindrome(string):
# Find the longest palindrome in the string
n = len(string)
start = 0
maxLength = 0
for i in xrange(1, n):
# Case 1
start = i-1
end = i
while start >= 0 and end <... |
null | Create a Python script to check the validity of a given password string | def is_valid_password(password):
if len(password) < 8:
return False
has_uppercase = False
has_lowercase = False
has_digit = False
for i in range(len(password)):
ch = password[i]
if ch.isupper():
has_uppercase = True
elif ch.islower():
ha... | |
[HI Wikipedia] ऋग्वेद संहिता
ऋग्वेद-संहिता ऋग्वैदिक वाङ्मय का मन्त्र-भाग है। इसमें १०२८ सूक्त हैं। इसे विश्व का प्राचीनतम ग्रंथ माना जाता है। विद्वानों के अनुसार ऋग्वेद ६००० इशापूर्व वर्षों से भी अधिक प्राचीन है। परिचय चारों वेदों में सर्वोच्च स्थान ऋग्वेद को ही प्राप्त है। ऋग्वेद को विश्व का प्राचीनतम ग्रन्थ होने... | null | null | null |
null | Create a method in Python to find the sum of all even numbers between two integers including the first and last number. | Low: 10
High: 20 | def even_sum(low, high):
sum = 0
for i in range(low, high+1):
if i % 2 == 0:
sum += i
return sum
result = even_sum(10, 20)
print(result) |
null | Create a Java class named "Card" to represent a standard playing card. The class should contain a constructor which takes the card's suit and number as parameters. It should also contain two getter methods to get the suit and number of the card. | < noinput > | public class Card { private String suit; private int number; public Card(String suit, int number) { this.suit = suit; this.number = number; } public String getSuit() { return suit; } public int getNumber() { return number; } } |
null | Write a code to get all the records from the users table with role "admin". | SELECT * FROM users WHERE role = 'admin'; | |
null | Write an algorithm in Python to determine the largest number in an array. | arr = [10, 8, 12, 4, 6] | def find_max(arr):
max_val = arr[0]
for i in range(1, len(arr)):
if arr[i] > max_val:
max_val = arr[i]
return max_val
# Driver code
arr = [10, 8, 12, 4, 6]
result = find_max(arr)
print(result)
# Output: 12 |
null | Generate a C++ function to print the Fibonacci series | #include <iostream> using namespace std; void Fibonacci(int n) { int f1 = 0, f2 = 1, i; if (n == 0) return; for (i = 1; i <= n; i++) { cout << f2 << " "; int next = f1 + f2; f1 = f2; f2 = next; } } int main() { int n = 10; Fibonacci(n); return 0; } | |
null | Design a Python class for an Employee, containing person's name, age, salary, and designation. | class Employee:
def __init__(self, name, age, salary, designation):
self.name = name
self.age = age
self.salary = salary
self.designation = designation
def get_details(self):
return self.name + " " + str(self.age) + " " + str(self.salary) + " " + self.designatio... | |
[HI Wikipedia] कुआलालम्पुर
कुआला लम्पुर, जिसे संक्षेप में "के एल" भी कहा जाता है, मलेशिया की संघीय राजधानी व सबसे अधिक जनसंख्या वाला नगर है। इस नगर का क्षेत्रफल है तथा 2012 की अनुमानित जनसँख्या 16 लाख है। वृहत्तर कुआला लम्पुर, जिसे क्लाँग घाटी के नाम से भी जाना जाता है, में आसपास के शहरी समुदाय भी सम्मिलित किए जाते है... | null | null | null |
null | Write a bash script that searches for a given text string in a directory tree recursively. | #!/bin/bash search_string="text string" directory="directory_name" #searching for text string recursive in the directory grep -rnw $directory -e "$search_string" | |
null | Create a Python script to print out 10 random values between 1 and 10. | import random
for i in range(10):
print(random.randint(1, 10)) | |
null | Write a for loop in Python which prints out the contents of the given stack. | sample_stack = ["first", "second", "third"] | for item in sample_stack: print(item) |
null | Write a script in Python to take an age as an input and return a boolean which indicates if a person is a minor or not. | def is_minor(age): """ Function to determine if a person is a minor or not """ if age < 18: return True else: return False # Let's test it age = 18 print(is_minor(age)) # Output: False | |
[HI Wikipedia] कायोटी
कायोटी (coyote), जिसे अमेरीकी सियार (American jackal) और झाड़ भेड़िया (brush wolf) भी कहते हैं, उत्तर अमेरिका और मध्य अमेरिका में विस्तृत एक लोमड़ी-जैसी जाति है। यह दक्षिण में पनामा से लेकर उत्तर में अलास्का व कनाडा तक पाई जाती है। अमेरिकी प्राकृतिक मंडल में इसका वही स्थान है जो यूरेशिया में सिया... | null | null | null |
[DE Wikipedia] Ondonga
Ondonga steht für: Ondonga (Clan), ein Clan der Ovambo im südlichen Afrika, siehe Könige der Ovambo #Ondonga Olukonda, andere Bezeichnung der Ansiedlung in der Region Oshikoto, Namibia | null | null | null |
null | Create a neural network with two layers using Keras, a Python library for deep learning. | import keras
from keras.models import Sequential
from keras.layers import Dense
# Define the model
model = Sequential()
model.add(Dense(8, input_dim=6, activation='relu'))
model.add(Dense(4, activation='softmax'))
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy']) | |
null | Create an optimized data structure in Python to store information about a person's profile. | profile = {
"name": "Kiran",
"age": 25,
"location": "Australia",
"hobbies": [
"Travelling",
"Swimming"
]
} | class Profile(object):
def __init__(self, name, age, location, hobbies):
self.name = name
self.age = age
self.location = location
self.hobbies = hobbies
profile = Profile("Kiran", 25, "Australia", ["Travelling", "Swimming"]) |
null | Write a Python program that takes a sequence of strings, sorts them alphabetically, and prints them to the console. | sequence = ["Hello", "world", "Welcome", "to", "the", "Coding", "Revolution"] | sequence = ["Hello", "world", "Welcome", "to", "the", "Coding", "Revolution"]
sorted_sequence = sorted(sequence)
for word in sorted_sequence:
print(word) |
null | Identify all the statements that are erroneous or have logical errors. | a = 2 b = 1 if a > b print("a is greater than b") elif a == b print("a is equal to b") else print("b is greater than a") | The statements that are erroneous or have logical errors are: 1) There is no colon (:) after the 'if' and 'elif' statements 2) There is no colon (:) after the 'else' statement. 3) The parentheses after 'print' are unnecessary. |
null | Write a Python program for linear regression using gradient descent. | A 2-dimensional sample dataset:
X = [1, 2, 3, 4]
Y = [2, 7, 3, 8] | import numpy as np
def gradient_descent(x, y, alpha, num_iters):
# Initialize theta
theta = np.ones(x.shape[1])
m = len(y)
J_history = list()
# Perform Gradient Descent
for _ in range(num_iters):
# Compute Hypothesis
h = np.dot(x, theta)
# Compute err... |
null | You need to run a loop 'n' times and print a value each time. | let n = 10; | for (let i = 0; i < n; i++) { console.log(i); } |
null | Create a neural network in Python capable of solving a multiple classification problem. | import tensorflow as tf
# Create an input layer with two input features
inputs = tf.keras.Input(shape=(2,))
# Add a dense layer with three neurons
x = tf.keras.layers.Dense(3, activation='sigmoid')(inputs)
# Add a dense layer with three neurons
outputs = tf.keras.layers.Dense(3, activation='softmax')(x)
# Create th... | |
[DE Wikipedia] Olympische Winterspiele 2014/Eisschnelllauf – 10.000 m (Männer)
Die 10.000 m im Eisschnelllauf der Männer bei den Olympischen Winterspielen 2014 wurden am 23. Februar 2014 in der Adler Arena ausgetragen. Rekorde Ergebnisse Weblinks 10.000 m (Männer) | null | null | null |
null | Create a TensorFlow model in Python to classify hand-written numbers. | Not applicable | import tensorflow as tf
# load the MNIST dataset
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()
# reshape and rescale the data
x_train = x_train.reshape(x_train.shape[0], 28, 28, 1).astype('float32')
x_test = x_test.reshape(x_test.shape[0], 28, 28, 1).astype('float32')
x_train = x_train / ... |
null | What is the SQL query to select all the values that are greater than 10 in the "Age" column in the table "Students"? | SELECT * FROM Students WHERE Age > 10 | |
null | Create a function that returns true if a given set is a subset of another set. | set1 = {1,2,3} set2 = {1,2,3,4,5,6} | def is_subset(s1, s2): for e in s1: if e not in s2: return False return True is_subset({1,2,3}, {1,2,3,4,5,6}) # Output: True |
[HI Wikipedia] गेंदबाज
क्रिकेट के खेल में गेंदबाज़ गेंद फेंकने की जिम्मेदारी लेता है और गेंद फेंकने की इस क्रिया या कला को गेंदबाज़ी कहा जाता है। सबसे तेज गेंद अभी तक शोएब़ अख्तर द्वारा फरवरी २००३ में फेंकी गेंद को सबसे तेज़ गेंद (१००.२३ मील प्रति घंटा या १६१.३ किलोमीटर प्रति घंटा) माना जाता है। प्रमुख गेंदबाज यह भी द... | null | null | null |
null | What is the maximum number of threads simultaneously running in a single process? | The maximum number of threads that can simultaneously run in a single process is limited by the resources of the system, such as the amount of available memory and the scheduling algorithm employed. Generally, a typical modern system will allow up to hundreds or even thousands of threads to run concurrently. | |
null | Design a neural network application in Python to predict the price of real estate. | Table Name: Properties
Columns:
- id: int
- location: varchar
- size: int
- price: int | # Imports
import numpy as np
import pandas as pd
from sklearn import preprocessing
import tensorflow as tf
import keras
# Read in the data
data = pd.read_csv('data/properties.csv')
# Split data into features and labels
X = data[['location', 'size']]
y = data['price']
# Preprocess the data
scaler = preprocessing.Stan... |
[CS Wikipedia] Jaroslav Mařík
Jaroslav Mařík (22. prosinec 1913 Zahradnice – 5. květen 1997 Praha) byl český esperantista, čestný člen Českého esperantského svazu a Světového esperantského svazu. Život Esperanto se naučil jako samouk v r. 1934 a v českém esperantském hnutí zastával řadu funkcí a aktivit: byl mj. vedou... | null | null | null |
null | Implement the bubble sort algorithm for an array of integers. | arr = [34, 16, 12, 9, 5] | def bubbleSort(arr): n = len(arr) # Traverse through all array elements for i in range(n): # Last i elements are already in place for j in range(0, n-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[j+1] = arr[j+1], arr[j] # Dri... |
[EN Wikipedia] Potha Bainsi
Potha Bainsi is a village in Mirpur District of Azad Kashmir, Pakistan. The nearest town is Kakra. It is approximately 8 miles east from the city of Mirpur and approx 20 miles from the city of Jhelum. Demography According to the 1998 census of Pakistan, its population was 1,391. History Pot... | null | null | null |
[DE Wikipedia] Kingston (Mississippi)
Kingston (auch Jersey Town genannt) ist eine Unincorporated Community im Adams County, Mississippi in den Vereinigten Staaten. Die Siedlung wurde 1784 im damaligen Britisch-Westflorida gegründet und war eine der ersten Niederlassungen weißer Siedler im Adams County. Geschichte Das... | null | null | null |
null | Design a function in Python to return the length of the longest common subsequence in two given strings. | "abcde", "ace" | def longestCommonSubsequence(s1, s2):
m = len(s1)
n = len(s2)
LCSuff = [[0 for k in range(n+1)] for l in range(m+1)]
result = 0
for i in range(m + 1):
for j in range(n + 1):
if (i == 0 or j == 0):
LCSuff[i][j] = 0
elif s1[i-1] == s2[j-1]:
... |
null | Create a function that compares two binary strings and returns the number of differences between them. | string1 = "100100" string2 = "100011" | def differences_in_binary_strings(string1, string2): # initialise a variable to store total differences total_differences = 0 # loop through each digit in the strings for i in range(len(string1)): # check if the digits in the same position in each string are different if string1[i] != string2[i]: # increment the total ... |
null | Devise a Python code snippet to return the last character of a given string. | string = "stackoverflow" | last_char = string[-1] print(last_char) |
null | Develop an algorithm in Python that finds the minimum number of coins required to make a given amount. | 8 | def minCoins(amount):
# Initializing the list of coins with the given amount
coins = [1, 2, 5]
num_coins = [999999999] * (amount+1)
num_coins[0] = 0
for i in range(1, amount+1):
for j in coins:
if j <= i:
sub_res = num_coins[i-j]
if ... |
null | Design a SQL query to find all records from the table "Users" where the user's name is "John". | SELECT * FROM Users WHERE name = 'John'; | |
null | Generate Python code to get all unique items in a nested dictionary. | dict1 = {
"key1": [1,2],
"key2": [2,3],
"key3": {
"key4": [3,4]
}
} | def get_all_keys(input_dict):
keys = set()
if isinstance(input_dict, dict):
keys.update(input_dict.keys())
for v in input_dict.values():
keys.update(get_all_keys(v))
return keys
dict1 = {
"key1": [1,2],
"key2": [2,3],
"key3": {
"key4": [3,4]
}
}
unique_i... |
null | Based on the following input array, return the largest two numbers in the array. | numbers = [10, 9, 8, 7, 6, 5] | # return the two largest numbers in the array largestOne = max(numbers) numbers.remove(largestOne) largestTwo = max(numbers) print(largestOne, largestTwo) 10 9 |
null | Create a function to print a table using a given dictionary. | example_dict = { 'Name': ['John', 'Stella', 'Daniel'], 'Age': [20, 23, 19] } | def print_table(dictionary): """Prints a table from a dictionary of lists.""" # retrieve the lists names = dictionary['Name'] ages = dictionary['Age'] # print the table print('\tName\tAge') print('-' * 20) for i, name in enumerate(names): age = ages[i] print(f'\t{name}\t{age}') |
[HI Wikipedia] ग्वार-बती भाषा
ग्वार-बती (Gawar-Bati, ) कुनर (कुनड़) शाखा की एक दार्दी भाषा है जो अफ़ग़ानिस्तान के कुनर प्रान्त और उसके साथ लगे पाकिस्तान के चित्राल ज़िले के कुछ भागों में बोली जाती है। इसके लगभग ९,००० मातृभाषी अफ़ग़ानिस्तान में और १,५०० पाकिस्तान में रहते हैं। सन्दर्भ हिन्द-आर्य भाषाएँ दार्दी भाषाएँ ... | null | null | null |
[CS Wikipedia] Sojuz TMA-16
Sojuz TMA-16 je ruská kosmická loď řady Sojuz k Mezinárodní vesmírné stanici (ISS), kam dopravila dva členy Expedice 21 a na nějakou dobu posledního „vesmírného turistu“. Posádka Maxim Surajev (1), velitel, CPK Jeffrey Williams (3), palubní inženýr, NASA Pouze start Guy Laliberté (1), účast... | null | null | null |
null | Write a code to connect to a remote database. | username: john password: john123 IP: 100.10.0.10 | import psycopg2 conn = psycopg2.connect(host="100.10.0.10", database="mydb", user="john", password="john123") |
null | Write a Python program that calculates the distance between two points on a two-dimensional plane. | Point1 (x1: 3, y1: 4); Point2 (x2: -9, y2: -2) | #include <iostream>
#include <math.h>
int main()
{
int x1 = 3;
int y1 = 4;
int x2 = -9;
int y2 = -2;
float distance = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
std::cout << "Distance between the two points is: " << distance << std::endl;
return 0;
} |
null | Subtract the second number from the first. | 8, 6 | 2 |
null | Design a Python program to stop a loop after some specific iterations | for i in range(100):
if (i > 10):
break
print(i) | |
[CS Wikipedia] Pražský rejdič středozobý
Pražský rejdič středozobý je plemeno holuba domácího pocházející z České republiky. Má společný původ s pražským rejdičem krátkozobým. Je to drobný holub s hranatou hlavou, lehce nazad skloněným trupem a vypjatou, zaoblenou hrudí. Má vynikající letové schopnosti, trénované hejn... | null | null | null |
null | Convert the following temperature to its equivalent Fahrenheit measurement. | Temperature: 20 degrees Celsius | The equivalent Fahrenheit measurement is 68 degrees Fahrenheit. |
null | Write Python code snippets that will convert comma separated values to a list of dictionaries. | name,age
Albert,22
Bob,24
Charles,20 | csv_data = [
{'name': 'Albert', 'age': 22},
{'name': 'Bob', 'age': 24},
{'name': 'Charles', 'age': 20}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.