text stringlengths 141 2.89k ⌀ | instruction stringlengths 19 1.5k ⌀ | input stringlengths 0 800 ⌀ | output stringlengths 1 2.5k ⌀ |
|---|---|---|---|
null | Design an algorithm in Python that checks if a given number is even or odd. | def is_even(n):
if n % 2 == 0:
return True
else:
return False | |
null | Write an HTML code snippet to create a checkbox with the label “Terms of Service” | <input type="checkbox" id="terms" name="terms" value="agree" /> <label for="terms">Terms of Service</label> | |
null | Generate a python program to display the largest and smallest elements in a given array | [2, 3, 8, 5, 10, 6] | def display_min_max(arr):
# initializing max and min element
max_element = arr[0]
min_element = arr[0]
# traverse through the array elements
for x in arr:
if (x > max_element):
max_element = x
if (x < min_element):
min_element = x
# display max and min e... |
null | Edit the previous code to print out the total salary of all employees whose salary is between 40,000 and 50,000. | SELECT SUM(salary) as total_salary FROM employees WHERE salary BETWEEN 40000 AND 50000; | |
null | Write a code to convert a given string of English characters to corresponding Morse code. | "Hello World!" | def morse_encode(input_string): morse_encoder = { "A":".- ", "B":"-... ", "C":"-.-. ", "D":"-.. ", "E":" . ", "F":"..-. ", "G":"--. ", "H":".... ", "I":".. ", "J":".--- ", "K":"-.- ", "L":".-.. ", "M":"-- ", "N":"-. ", "O":"--- ", "P":".--. ", "Q":"--.- ", "R":".-. ", "S":"... ", "T":"- ", "U":"..- ", "V":"...- ", "W":... |
[HI Wikipedia] रेलवे प्लेटफार्म
महत्वपूर्ण तथ्य कॉपर का उपयोग बिजली के तारों को बनाने में किया जाता है। आयरन का उपयोग, खाना बनाने के बर्तनों और दरवाजों की कुंडियो को बनाने में किया जाता है। गोल्ड और सिल्वर का उपयोग, आभूषण बनाने में किया जाता है। मर्करी का उपयोग, थर्मोमीटर बनाने में किया जाता है। धातुओं को पोलिश किया ज... | null | null | null |
[EN Wikipedia] Newham Generals
Newham Generals are a grime duo from East London, currently consisting of MCs D Double E and Footsie. They are best known for their singles "Frontline", "Hard" and "Like It Or Not" as well as their live performances. The group was founded in 2004, after D Double E had a disagreement with... | null | null | null |
null | Optimize an existing Python program using the scikit-learn library. | An existing Python program to classify spam emails. | # Load required modules
import pandas as pd
from sklearn.pipeline import make_pipeline
from sklearn.naive_bayes import MultinomialNB
from sklearn.feature_extraction.text import CountVectorizer, TfidfTransformer
# Load spam emails
spam_df = pd.read_csv("spam.csv")
# Split into independent and dependent features
X = sp... |
null | Write a Python program to divide a list of numbers into two equal lists. | [1,2,3,4,5,6,7,8,9,10] | list_a = [1,2,3,4,5]
list_b = [6,7,8,9,10] |
null | Implement an algorithm in C++ for finding the largest number in an array. | int arr[] = {3, 7, 1, -2, 9, 5}; | #include <iostream> using namespace std; int largestNumber(int arr[], int n) { int max = arr[0]; for (int i = 0; i < n; i++) { if (arr[i] > max) max = arr[i]; } return max; } int main() { int arr[] = {3, 7, 1, -2, 9, 5}; int n = sizeof(arr) / sizeof(arr[0]); cout <<"The largest element is "<< largestNumber(arr, n); ret... |
[HI Wikipedia] कन्हैयालाल शर्मा
डॉ कन्हैयालाल शर्मा (24 जनवरी सन् 1924 ई. -) हिन्दी के कवि, हिन्दी-विभागाध्यक्ष एवं भाषा-शोधक थे। उनका जन्म राजस्थान के कोटा जिले के कनवास नामक ग्राम में एक अल्प-मध्यवर्गीय परिवार में हुआ था। कृतियाँ हाड़ोती बोली और साहित्य (1965) हाड़ोती साहित्य और स्वरूप (1973) तेजाजी-लोक गाथा बाहरी क... | null | null | null |
null | What is the reason for the failure of a unit test? | The reason for the failure of a unit test can be any number of things, including incorrect expectations, incorrect or missing test data, or a problem with the code being tested. It can also be due to a lack of suitable code coverage. In any case, it is important to identify the source of the failure to ensure that the ... | |
[DE Wikipedia] Amt Hüttenberg
Das Amt Hüttenberg war ein hessen-darmstädtisches und nassau-weilburgisches kondominial verwaltetes Amt. Nach einer Realteilung bestand sowohl ein hessisches als auch ein nassauisches „Amt Hüttenberg“. Geografie Im 16. Jahrhundert bestand es aus: dem Hüttenberg mit den Orten Allendorf/Lah... | null | null | null |
null | Create a class in Python which can be used to store data about books. | class Book:
def __init__(self, title, author, pages):
self.title = title
self.author = author
self.pages = pages
def __str__(self):
return '{} by {} ({} pages)'.format(self.title, self.author, self.pages) | |
null | Develop a Python program to check if a triangle is valid or not. | Length of sides: 3, 4, 5 | # A function to check if the triangle is valid
def valid_triangle(side1, side2, side3):
# Check the sum of any two sides should be
# greater than the third one.
a = side1 + side2
b = side1 + side3
c = side2 + side3
if (a > side3) and (b > side2) and (c > side1):
return Tru... |
null | Optimize the following Python code for counting the number of words in an input string. | s = "This is a sample string" | # Count number of words in a string
def count_words(s):
# remove unnecessary characters
s = s.replace(',', '').replace('.', '')
# split string into list of words
words = s.split(' ')
# return the length of the list (number of words)
return len(words)
s = "This is a sample string"
words_count =... |
null | Create an HTML document to display "Hello, World!" in bold. | <!DOCTYPE html> <html> <head> <title>Hello World</title> </head> <body> <b>Hello, World!</b> </body> </html> | |
[EN Wikipedia] Robert Dawson
Robert or Bob Dawson may refer to: Academia Robert MacGregor Dawson (1895–1958), Canadian political scientist and academic Robert L. Dawson (1943–2007), American professor of French language and literature Robert Dawson (photographer) (born 1950), American photographer and instructor of ph... | null | null | null |
null | Come up with a Python program to print out the sum of all the numbers from 0 to a given number. | def sum_numbers(n):
total = 0
for i in range(n+1):
total += i
return total
print(sum_numbers(20)) | |
[CS Wikipedia] Milan Kratochvíl (fotbalista)
Milan Kratochvíl (26. listopadu 1939) je bývalý český fotbalista, útočník. Sportovní kariéra V československé lize hrál za Bohemians Praha. Nastoupil ke 116 ligovým utkáním a dal 8 gólů. Ligová bilance Literatura JEŘÁBEK, Luboš: Český a československý fotbal: lexikon osobno... | null | null | null |
null | Find the number of elements in an array of integers [1,2,3,4,5]. | arr = [1,2,3,4,5] | length = len(arr) print(length) # Output 5 |
null | Write a Python function to compare two lists and return the elements that are not common in both lists. | list1=[1, 2, 3, 4, 5]
list2=[4, 5, 6, 7, 8] | def get_unique_elements(list1, list2):
return list(set(list1) - set(list2)) |
null | Create a Java method that takes two integer arguments and returns their multiplication. | public static int multiply(int a, int b) { return a * b; } | |
null | Create an algorithm in JavaScript to merge two sorted arrays into one. | arr1 = [1, 3, 5, 7] arr2 = [2, 4, 6, 8] | function mergeArrays(arr1, arr2) { let result = []; let index1 = 0; let index2 = 0; while (index1 < arr1.length && index2 < arr2.length) { if (arr1[index1] < arr2[index2]) { result.push(arr1[index1]); index1++; } else { result.push(arr2[index2]); index2++; } } while (index1 < arr1.length) { result.push(arr1[index1]); i... |
null | Write a Python program to compare the results of two sorting algorithms. | Algorithms: QuickSort, MergeSort
Array: [3, 8, 1, 9, 5, 2] | def quicksort(arr):
if len(arr) <= 1:
return arr
else:
pivot = arr[len(arr) // 2]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return quicksort(left) + middle + quicksort(right)
def mergesort(... |
null | Build a linear regression model using Python's scikit learn library. | import pandas as pd import numpy as np data = pd.DataFrame({ 'x': [2.5, 0.5, 2.2, 1.9, 3.1, 2.3, 2, 1, 1.5, 1.1], 'y': [2.4, 0.7, 2.9, 2.2, 3, 2.7, 1.6, 1.1, 1.6, 0.9] }) X = data['x'].values.reshape(-1, 1) y = data['y'].values.reshape(-1, 1) | from sklearn.linear_model import LinearRegression # Create linear regression model model = LinearRegression() # Train the model using the training set model.fit(X, y) # Make predictions using the testing set y_pred = model.predict(X) |
[EN Wikipedia] Allegiance
An allegiance is a duty of fidelity said to be owed, or freely committed, by the people, subjects or citizens to their state or sovereign. Etymology The word allegiance comes from Middle English (see Medieval Latin , "a liegance"). The al- prefix was probably added through confusion with anot... | null | null | null |
[HI Wikipedia] कुंचन नम्बियार
कुंचन नंबियार (लगभग १७०५- १७७० ई.) मलयालम के आरम्भिक कवि, व्यंगकार थे। परिचय इनका जन्म मध्य केरल के कोच्चिस्थान में हुआ था। अंपलप्पुष के देवनारायण नामक शासक के संरक्षण में वहीं बस गए और बाद में त्रावणकोर के शासक मार्तण्ड वर्मा के दरबार में प्रविष्ट हुए। अपने यौवनकाल के प्रारंभिक दिनों में... | null | null | null |
[EN Wikipedia] Şölen, Ergani
Şölen is a neighbourhood of the municipality and district of Ergani, Diyarbakır Province, Turkey. Its population is 1,556 (2022). Before the 2013 reorganisation, it was a town (belde). References Neighbourhoods in Ergani District | null | null | null |
[EN Wikipedia] Gmina Górzno, Masovian Voivodeship
Gmina Górzno is a rural gmina (administrative district) in Garwolin County, Masovian Voivodeship, in east-central Poland. Its seat is the village of Górzno, which lies approximately 8 kilometres (5 mi) south-east of Garwolin and 64 km (40 mi) south-east of Warsaw. The ... | null | null | null |
[HI Wikipedia] भारत-चीन सम्बन्ध
भारत - चीन सम्बन्ध ( ; देवनागरीकृत : च्रुङ्ग्¹यिन्² क्वाङ्¹शी² ); दो पड़ोसी एवं विश्व की दो उभरती शक्तियाँ हैं। दोनों के बीच लम्बी सीमारेखा है। इन दोनों में प्रचीन काल से ही सांस्कृतिक तथा आर्थिक सम्बन्ध रहे हैं। भारत से बौद्ध धर्म का प्रचार चीन की भूमि पर हुआ है। चीन के लोगों ने प्राच... | null | null | null |
null | You need to generate a Javascript program that prints "Hello World". | console.log("Hello World"); | |
null | Edit this code snippet to reverse a string in Python. | def reverse_string(s): # Edit here return reversed_string | def reverse_string(s): reversed_string = "" for char in s: reversed_string = char + reversed_string return reversed_string |
[CS Wikipedia] Aneroid
Aneroid (barometre anéroide, holosterikbarometer) je deformační přístroj určený k měření atmosférického tlaku (tlaku vzduchu). Aneroid (kovový tlakoměr) vynalezl v roce 1843 francouzský fyzik Lucien Vidie. Principem činnosti mechanického aneroidu je deformace pružného systému (čidla) působením t... | null | null | null |
null | Write a procedure to subtract two numbers in MySQL. | CREATE PROCEDURE subtract_numbers ( IN num_1 INT, IN num_2 INT ) BEGIN SET num_1 = num_1 - num_2; END; | |
null | Can you detect if a given number is even or odd? | def is_even(n): return n % 2 == 0 | |
null | Write a C++ program that prints the Fibonacci numbers up to the number specified by the user. | #include <iostream> using namespace std; int main() { int n, t1 = 0, t2 = 1, nextTerm; cout << "Enter the number of terms: "; cin >> n; cout << "Fibonacci Series: "; for (int i = 1; i <= n; ++i) { if (i == 1) { cout << " " << t1; continue; } if (i == 2) { cout << t2 << " "; continue; } nextTerm = t1 + t2; t1 = t2; t2 =... | |
null | Develop a code to predict the sentiment of a sentence using a pre-trained sentiment analysis model in Python. | from textblob import TextBlob
from textblob.sentiments import NaiveBayesAnalyzer
# Create a TextBlob object using the NaiveBayesAnalyzer
sentiment_analyzer = TextBlob(analyzer=NaiveBayesAnalyzer())
# Method to predict the sentiment of a given sentence
def predict_sentiment(sentence):
# Get the polarity score of t... | |
null | Using recursion, write 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) | |
[DE Wikipedia] Fred Etchen
Fred Rudolph Etchen (* 25. September 1884 in Coffeyville; † 6. November 1961 in Phoenix) war ein US-amerikanischer Sportschütze. Erfolge Fred Etchen nahm an den Olympischen Spielen 1924 in Paris im Trap teil. Im Mannschaftswettbewerb belegte er mit der US-amerikanischen Mannschaft vor Kanada... | null | null | null |
null | Given a list of names, capitalize the first letter of each name. | names = ["john", "sarah", "joe", "dave"] | def capitalize_names(names): capitalized_names = [] for name in names: capitalized_name = name[0].upper() + name[1:] capitalized_names.append(capitalized_name) return capitalized_names |
null | Calculate the result of XORing two binary numbers. | 1010, 0101 | The result of XORing 1010 and 0101 is 1111. |
null | Write a function in Python that takes a string of text as an input and returns a list of all possible anagrams of the string. | "aabc" | def getAnagrams(string):
#base case
if len(string) <= 1:
return [string]
#recursive case
all_possible_anagrams = []
for i, letter in enumerate(string):
#recursively iterate over the string without the fixed letter
sub_string = string[:i] + string[i+1:]
#get anagr... |
[CS Wikipedia] Štěpán Kučera (spisovatel)
Štěpán Kučera (* 13. února 1985 Jablonec nad Nisou) je český spisovatel. Vystudoval žurnalistiku a mediální studia na Karlově univerzitě v Praze, pracuje jako redaktor Salon Práva. Napsal sbírku povídek Tajná kronika Rychlých šípů… a jiné příběhy (Host, 2006), povídkovou knihu... | null | null | null |
null | Generate a random array of size n in Python. | Size of array: 5 | import numpy as np size = 5 # Create an array of size 5 arr = np.random.randint(100, size = (size)) print (arr) |
null | Create a Machine Learning algorithm in Python that predicts the price of a car based on its features. | Not applicable | import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestRegressor
# Read the data
data = pd.read_csv('cars.csv')
# Split the data in features (X) and labels (y)
X = data.drop('price', axis=1)
y = data['price']
# Split the data into training and test sets
X_tr... |
null | Improve the following Python code by making it faster and more efficient. | def multiply(a, b):
result = 0
for x in range(a):
result += b
return result | def multiply(a, b):
result = 0
while a != 0:
if a & 1:
result += b
a >>= 1
b <<= 1
return result |
null | Invert the given dictionary. | Dictionary: {'a': 1, 'b': 2, 'c':3} | Inverted dictionary: {1: 'a', 2: 'b', 3: 'c'} |
null | Create a function in Python to construct a 3-dimensional array from two 2-dimensional arrays. | [[0, 0, 0], [1, 1, 1]]
[[2, 2, 2], [3, 3, 3]] | def construct_3d_array(arr1, arr2):
result = []
for i in range(len(arr1)):
sub_arr = []
for j in range(len(arr1[i])):
sub_arr.append([arr1[i][j], arr2[i][j]])
result.append(sub_arr)
return result
arr1 = [[0, 0, 0], [1, 1, 1]]
arr2 = [[2, 2, 2], [3, 3, 3]]
print(construc... |
null | Given an array of strings, build an algorithm in Python to determine the index of the element that contains the smallest number of characters. | ["Hello", "World", "Python", "is", "Fun"] | def min_length_index(arr):
min = float('infinity')
min_i = 0
for i in range(len(arr)):
if len(arr[i]) < min:
min = len(arr[i])
min_i = i
return min_i
print(min_length_index(["Hello", "World", "Python", "is", "Fun"])) # 3 |
null | Generate a Python program to scrape the content of an HTTPS website and output the result. | Not applicable | import requests
from bs4 import BeautifulSoup
# make a get request to fetch the contents of the page
r = requests.get('https://example.com')
# parse the html content
soup = BeautifulSoup(r.content, 'html.parser')
# print out the result
print(soup.prettify()) |
null | Using JavaScript, convert the following JSON object into a string. | JObj = { “name” : “John”, “age” : 42 } | const JString = JSON.stringify(JObj); console.log(JString); // { “name” : “John”, “age” : 42 } |
null | Construct a database schema for a "Products" table. | CREATE TABLE Products ( id INTEGER PRIMARY KEY AUTOINCREMENT, product_name TEXT NOT NULL, product_price REAL NOT NULL, product_image TEXT, product_description TEXT ); | |
null | Create a program in Python that takes a URL as input and prints out all the links (href) that appear in the page. | Not applicable | import requests
from bs4 import BeautifulSoup
url = 'http://www.example.com'
html = requests.get(url).text
soup = BeautifulSoup(html, 'html.parser')
for link in soup.find_all('a'):
print(link.get('href')) |
null | Explain the process of quicksort. | Quicksort is a sorting algorithm that uses a divide-and-conquer approach to sort a given array. The process starts by selecting a pivot which is used to partition the array into two subarrays: one containing elements smaller than the pivot, and the other containing elements larger than the pivot. The same process is th... | |
[CS Wikipedia] Pala (přítok Minije)
Pala je řeka na západě Litvy (Telšiaiský kraj). Je dlouhá 20,2 km. Řeka teče směrem jihozápadním, od Tverského lesa směrem severozápadním, později severním. Vlévá se do řeky Minija 172,3 km od jejího ústí jako levý přítok. Průběh toku Horní tok začíná velikým obloukem obkružujícím v... | null | null | null |
null | Generate a Python code to multiply all the items of a given list. | [2, 3, 4] | product = 1
for value in [2, 3, 4]:
product *= value
print(product) |
null | Suggest a python code to merge two sorted list and maintain the order | list1 = [1, 5, 11, 15]
list2 = [3, 10, 12] | def merge_sorted_lists(list1, list2):
result = []
while len(list1) > 0 and len(list2) > 0:
if list1[0] < list2[0]:
result.append(list1.pop(0))
else:
result.append(list2.pop(0))
if len(list1) > 0:
result += list1
else:
result += list2
return result
list1 = [1, 5, 11, 15]
list2 = ... |
null | Suggest a code to execute when a condition is met. | if volume > 10: | if volume > 10: # Do something print("Volume is greater than 10") |
[EN Wikipedia] Gmina Szczawin Kościelny
Gmina Szczawin Kościelny (1943-1945, German Schauenkirch) is a rural gmina (administrative district) in Gostynin County, Masovian Voivodeship, in east-central Poland. Its seat is the village of Szczawin Kościelny, which lies approximately south-east of Gostynin and west of Warsa... | null | null | null |
[HI Wikipedia] मनोरंजन
मनोरंजन एक ऐसी क्रिया है जिसमें सम्मिलित होने वाले को आनन्द आता है एवं मन शान्त होता हैं। मनोरंजन सीधे भाग लेकर हो सकता है या कुछ लोगों को कुछ करते हुए देखने से हो सकता है। मनोरंजन के साधन क्रेजी ज्ञान टेलिविज़न चलचित्र रेडियो नाटक नौटंकी संगीत नृत्य डिस्को हास्य रस गोष्ठी कवि सम्मेलन जादू सर्कस... | null | null | null |
null | Create a Supplier model with a name, type, stock management, module identifier, and module data fields. The model should implement the ModuleInterface and ShuupModel. It should also have methods to get orderability errors, stock statuses, suppliable products, and adjust/update stock. Finally, define a SupplierLogEntry ... | # -*- coding: utf-8 -*-
# This file is part of Shuup.
#
# Copyright (c) 2012-2016, Shoop Ltd. All rights reserved.
#
# This source code is licensed under the AGPLv3 license found in the
# LICENSE file in the root directory of this source tree.
from django.db import models
from django.utils.encoding import python_2_unic... | |
null | Output the 5th Fibonacci number. | 5 | |
[EN Wikipedia] Taumona River
The Taumona River is a small river of the Manawatū-Whanganui region of New Zealand's North Island. It flows southwest from its origins west of Taumarunui to reach the Ohura River. See also List of rivers of New Zealand References Rivers of Manawatū-Whanganui Rivers of New Zealand | null | null | null |
null | Create an array of 10 integers, starting from 0 and increasing with each element. | my_array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
null | Suggeste a completion of the following code: | def flatten(nested_list): | def flatten(nested_list): flat_list = [] for item in nested_list: if isinstance(item, list): flat_list.extend(flatten(item)) else: flat_list.append(item) return flat_list |
null | Generate a program which accepts a sentence as an input and returns the total number of characters in it? | "<noinput>" | # Python program to find number of characters in a sentence
# Function to calculate number of characters
def find_char(s):
return(len(s))
# Taking the sentence from the user
str = input("Enter a sentence: ")
# Calling the function
count = find_char(str)
# Printing the result
print("Number of ch... |
[EN Wikipedia] Juho Reinvall
Juho Reinvall (born 24 August 1988) is a Finnish judoka. He competed at the 2016 Summer Olympics in the men's 60 kg event, in which he was eliminated in the second round by Tsogtbaatar Tsend-Ochir. References External links 1988 births Living people Finnish male judoka Olympic judoka for F... | null | null | null |
null | Read the provided string and print the number of vowels in it. | "GPT-3 is an advanced language model" | 7 |
null | Create a program in Python that asks the user for a number, multiplies the number by 7, and then prints the result. | num = int(input("Please enter a number: "))
print("The result of multiplying your number by 7 is " + str(num * 7)) | |
null | Generate a SQL query to select all the columns from a table named 'department' where the department name is 'Marketing'. | SELECT * FROM department WHERE department_name = 'Marketing'; | |
null | Explain the purpose of a web browser. | A web browser is a software application used to retrieve, render and traverse information on the World Wide Web. It uses Hypertext Transfer Protocol (HTTP) to request pages from from web servers, receive them, and display them in an organised way on our device. It also provides tools to allow users to traverse the web ... | |
null | Propose a fast sorting algorithm for a list of integers | The QuickSort algorithm is a fast sorting algorithm for a list of integers. QuickSort is a divide and conquer algorithm, meaning it divides a list into smaller lists and then sorts and combines the lists. It starts by partitioning the input list around a pivot element, then recursively sorts the two partitions and reco... | |
null | Modify the following Python code for calculating the factorial of a number. | def factorial(n):
fact = 1
for i in range(1,n+1):
fact = fact*i
return fact | def factorial(n):
if n == 0:
return 1
else:
fact = 1
for i in range(1,n+1):
fact = fact*i
return fact |
null | Create a GUI in Python with 4 buttons. | import tkinter
root = tkinter.Tk()
frame = tkinter.Frame(root)
frame.pack()
button1 = tkinter.Button(frame, text = "Button 1", fg = "red")
button2 = tkinter.Button(frame, text = "Button 2", fg = "blue")
button3 = tkinter.Button(frame, text = "Button 3", fg = "green")
button4 = tkinter.Button(frame, text = "Button 4",... | |
null | Create a Mastermind game in any language of your choice. | #include <iostream> #include <vector> #include <cstdlib> #include <ctime> using namespace std; int main() { srand(time(0)); //define random numbers to be guessed int max_limit = 6; vector<int> ans; for (int i = 0; i < 4; i++) { ans.push_back((rand() % max_limit) + 1); } int attempts = 0; while (true) { //Take input fro... | |
[HI Wikipedia] कुम्भ मेला
कुम्भ मेला हिन्दू धर्म का एक महत्वपूर्ण पर्व है, जिसमें करोड़ों श्रद्धालु कुम्भ पर्व स्थल प्रयाग, हरिद्वार, उज्जैन और नासिक में एकत्र होते हैं और नदी में स्नान करते हैं। इनमें से प्रत्येक स्थान पर प्रति १२वें वर्ष तथा प्रयाग में दो कुम्भ पर्वों के बीच छह वर्ष के अन्तराल में अर्धकुम्भ भी होता ... | null | null | null |
null | Change this code to print the reversed version of a string. | string s = "Hello World!"; | string s = "Hello World!"; reverse(s.begin(), s.end()); cout << s; // Outputs: !dlroW olleH |
null | Design an algorithm that can efficiently search for an element in a given sorted array | def binary_search(arr, x): start = 0 end = len(arr) - 1 while start <= end: mid = start + (end - start)//2 if arr[mid] == x: return mid elif arr[mid] < x: start = mid + 1 else: end = mid - 1 return -1 | |
null | Create a Python program to render a grid of numbers and letters. | Not applicable | def print_grid(rows, columns):
for i in range(rows):
for j in range(columns):
print(chr(i*j+65), end=' ')
print('\n')
print_grid(5,5)
#Output:
A B C D E
A C E G I
A F K P U
A I P W E
A N U E N |
null | Create a Deep Learning Program in Python to Predict Stock Price. | from keras.models import Sequential
from keras.layers import Dense
from keras.layers import LSTM
from keras.layers import Dropout
import numpy as np
# define constants
time_steps = 60
batch_size = 32
# build the model
model = Sequential()
model.add(LSTM(units=50, return_sequences=True, input_shape=(time_steps, 1)))
m... | |
null | Write a Python program to classify the set of strings into two categories based on their length. | strings = ['short', 'longer_string', 'medium_length', 'very_long_string'] | def classify_strings(strings):
# initialize lists for each classification
short = []
long = []
# classify each string
for s in strings:
if len(s) <= 6:
short.append(s)
else:
long.append(s)
# return classified lists
return [short, long]
if __name__ == ... |
[CS Wikipedia] Vladimir Šilykovskij
Vladimir Sergejevič Šilykovskij (; 3. dubna 1933 Vladimir – 7. dubna 1987 Moskva) byl sovětský rychlobruslař. Na mezinárodní scéně se poprvé představil v roce 1956, kdy startoval na Zimních olympijských hrách (10 000 m – 16. místo). Největších úspěchů dosáhl v sezóně 1958/1959, kdy ... | null | null | null |
null | Classify the following words as noun, verb, adverb or adjective. | Words: slowly, frog, kick | Adverb: slowly Noun: frog Verb: kick |
[CS Wikipedia] Megumi Ogata
Megumi Ogata (, Ogata Megumi) (6. června, 1965 v Tokiu) je J-popová zpěvačka a hlasová herečka. Jako zpěvačka působí pod pseudonymem em:óu. Chodila na univerzitu Tókai, ale odešla z ní kvůli nedostatku zájmu. V roce 2004 se podruhé vdala. Megumi měří 168 cm a má krevní skupinu B. Vybrané ro... | null | null | null |
[DE Wikipedia] Kleinstböckchen
Das Kleinstböckchen (Neotragus pygmaeus), manchmal auch Zwergböckchen genannt, ist eine Antilopenart, die zu den kleinsten Vertretern der Hornträger gehört. Sie bewohnt die westafrikanischen Regenwälder zwischen Sierra Leone und Ghana. Über die Lebensweise ist nur wenig bekannt. Die Erst... | null | null | null |
null | What will be the output of this code snippet? | a = [1, 2, 3, 4, 5] b = [x**2 for x in a] print(b) | [1, 4, 9, 16, 25] |
[DE Wikipedia] Konzentrationselement
Ein Konzentrationselement (auch Konzentrationszelle) ist eine galvanische Zelle, in der aufgrund chemischer Reaktionen ähnlich einer Batterie eine nutzbare elektrische Spannung entsteht. Das Besondere an einer solchen Konzentrationskette ist, dass sie aus zwei Halbzellen besteht, d... | null | null | null |
null | Find the minimum among a list of integers. | [1, 15, 22, -5, 87] | def find_min(numbers): min_value = numbers[0] for n in numbers: if n < min_value: min_value = n return min_value if __name__ == '__main__': numbers = [1, 15, 22, -5, 87] print(find_min(numbers)) |
null | Generate a list of integers in Python with no duplicates. | def generate_unique_list(n):
res = []
for i in range(n):
res.append(random.randint(1, n))
# ensure no duplicates occur
while len(res) != len(set(res)):
res.pop()
res.append(random.randint(1, n))
return res | |
null | Using regex, search for all occurrences of the substring "cat" in the following string: | The dog ran away, but the cat stayed | The regular expression to search for all occurrences of the substring "cat" in the string is /\bcat\b/g. |
null | Write an algorithm in Python to convert a given binary string to decimal number. | "11010" | def bin2dec(binary):
decimal, i = 0, 0
while binary != 0:
dec = binary % 10
decimal = decimal + dec * pow(2, i)
binary = binary//10
i += 1
return decimal
binary = 11010
print(bin2dec(binary)) |
null | Generate a Python program to fetch data from a website. | import requests
def main():
url = 'https://www.example.com'
r = requests.get(url)
if r.status_code == 200:
content = r.content
print(content)
else:
print("Failed to fetch data.")
if __name__ == "__main__":
main() | |
null | Update a given line of code to make a function return 'True' if both values are equal. | def compare(val1, val2): if val1 == val2: | def compare(val1, val2): if val1 == val2: return True |
[CS Wikipedia] Marc Almond
Marc Almond, rodným jménem Peter Mark Sinclear Almond, (* 9. července 1957 Southport, Spojené království) je anglický zpěvák, skladatel a herec. Ve své hudbě míchal new wave se synthpopem, popem a dancem. Proslavil se zejména členstvím ve vlivné kapele Soft Cell, se kterým měl i několik hitů... | null | null | null |
null | Design a JavaScript function that will accept two numbers and return their sum. | function add(a, b) { return a + b; } | |
null | Create a class in Python that has five methods: | class MyClass:
def __init__(self):
pass
def method1(self):
pass
def method2(self):
pass
def method3(self):
pass
def method4(self):
pass
def method5(self):
pass | |
null | Provide the output from executing the given program. | matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] for row in matrix: print(row[1]) | 2 5 8 |
null | Generate a predictive model using Python that can accurately determine the average temperature in a city according to previous temperature records. | Temperature data for the previous 5 years. | import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
data = pd.read_csv("temperature_data.csv")
X = data[["Year", "Month", "Day"]]
y = data["Temperature"]
model = LinearRegression()
model.fit(X, y)
#The model is now created and we can use it to make predictions |
null | Generate a numerical sequence in a given range using Python. | start = 3
end = 15 | def generate_sequence(start, end):
nums = []
for i in range(start, end+1):
nums.append(i)
return nums
nums = generate_sequence(3, 15)
print(nums) // [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.