text
stringlengths
141
2.89k
⌀
instruction
stringlengths
19
1.5k
⌀
input
stringlengths
0
800
⌀
output
stringlengths
1
2.5k
⌀
[EN Wikipedia] Andrius Giedraitis Andrius Giedraitis (born July 23, 1973) is a Lithuanian former professional basketball player and coach. Professional career Giedraitis started his career in the LPA Vilnius team, and he later moved to BC Sakalai. In 1998, he became a member of BC Lietuvos Rytas. He was one of the lea...
null
null
null
[CS Wikipedia] MGM-31 Pershing MGM-31 Pershing byla americká balistická raketa nahrazující rakety Redstone. Mohla být vybavena jadernou hlavicí. Podle amerického kódového označení z roku 1962 šlo o řízenou střelu odpalovanou z mobilního prostředku (vozidla) určenou k ničení povrchových cílů (včetně např. podzemních bu...
null
null
null
null
Create a bash script that prints out "Hello World" five times.
#!/bin/bash for i in `seq 1 5`; do echo "Hello World!" done
null
Create a Java program to count and print the distinct elements in an array.
int[] arr = {1, 2, 3, 2, 1, 4, 3, 2}
public class DistinctElements { public static void main(String[] args) { int[] arr = {1, 2, 3, 2, 1, 4, 3, 2}; // Initialize all element with the value 0. int[] temp = new int[arr.length]; int visited = -1; for (int i = 0; i < arr.length; i++) { int count = 1; for (int j = i + 1; j < arr.length; j++) { if (arr[i] == ar...
[DE Wikipedia] Rudi Bayerl Rudolf „Rudi“ Bayerl (* 10. März 1942 in Ballertshofen bei Lauterhofen) ist ein Oberpfälzer Heimatpfleger, Sachbuchautor, Mundartdichter und Kommunalpolitiker (UPW/FW Neumarkt). Leben Bayerl ist pensionierter Volksschul- und Sonderschullehrer. Er war zuletzt als Konrektor der Erwin-Lesch-Sch...
null
null
null
null
Write an algorithm in MIPS assembly language to determine if a given character is an uppercase letter or not.
Character: ‘A’
li $t0, 65 li $t1, 90 beq $t0, $t1, isUpperLetter j isNotUpperLetter isUpperLetter: # Do something isNotUpperLetter: # Do something
null
Using SQLite3, how can one create a table in an existing database?
CREATE TABLE table_name (column_name data_type PRIMARY KEY, ...);
null
Find the number of triplets in this array which sum up to zero.
arr = [-1, 0, 1, 2, 3, 4]
The number of triplets in this array which sum up to zero is 1. The triplets are [-1, 0, 1].
[HI Wikipedia] समता (भौतिकी) समता (अंग्रेजी : Parity) एक भौतिक राशी है। समता रूपांतरण (अथवा समता व्युत्क्रमण) कार्तिय निर्देशाकों का चिह्न परिवर्तन है। त्रिविम में, सामान्यतः तीनों कार्तिय निर्देंशाकों के एक साथ चिह्न परिवर्तन से भी समझाया जाता है: यह घटना की काइरलता (इंगिता) को समझने का विचार है, जिसमें इसके वृहत चित...
null
null
null
null
Create a function that counts the number of an specific letter in a given string.
string = "hello, world" letter = "l"
def countLetter(string, letter): count = 0 for char in string: if char == letter: count += 1 return count
null
Using a Decision Tree model, create a Python program to predict whether a customer is likely to churn given 5 different features.
Features: Purchase history, Gender, Age, Location, Billing Amount
import pandas as pd from sklearn.tree import DecisionTreeClassifier from sklearn.model_selection import train_test_split # Read the dataset dataset = pd.read_csv('data.csv') # Extract the input and output X = dataset.iloc[:, :5].values y = dataset.iloc[:, 5].values # Split the data into training and testing sets X_t...
[HI Wikipedia] खजुराहो खजुराहो(पूर्व में खजूरपुरा) भारत के मध्य प्रदेश प्रान्त में स्थित एक प्रमुख शहर है, जो अपने प्राचीन एवं मध्यकालीन मंदिरों के लिये विश्वविख्यात है। यह मध्य प्रदेश के छतरपुर जिले में स्थित है। खजुराहो को प्राचीन काल में 'खजूरपुरा'(खजूरी) और 'खजूर वाहिका' के नाम से भी जाना जाता था। यहां बहुत संख्या...
null
null
null
null
Edit the given SQL query to make it efficient.
SELECT * FROM table1, table2 WHERE table1.id = table2.id
SELECT * FROM table1 INNER JOIN table2 ON table1.id = table2.id The suggested modification is to replace the two-table join with an inner join. This will be more efficient as it reduces the number of cartesian products which have to be computed.
null
Convert the following string from lower case to upper case
hello world
HELLO WORLD
null
Edit the following code to return a length 5 array of zeros.
int[] array = new int[10];
int[] array = new int[5]; for(int i=0; i<array.length; i++){ array[i] = 0; }
null
Create a function in Python that takes a list of strings and returns a dictionary where the key is the first character of each string and the value is a list of the strings starting with that character.
[‘apple’, ‘elephant’, ‘ball’, ‘cat’]
def groupStrings(strings): # Initialize a dictionary dict = {} # Iterate over the list for string in strings: # Get the first character first_char = string[0] # Check if the first character is in the dictionary if first_char in dict: # Append the string to t...
[HI Wikipedia] करन कुन्दरा करन कुन्दरा (जन्मगत नाम: वीर करन कुन्दरा, जन्म अक्तुबर ११, १९८४, स्थान जालंधर, पंजाब) एक भारतीय टीवी अभिनेता हैं। टीवी दुनिया में आने से पहले ये अपने पारिवारिक व्यवसाय में थे। व्यक्तिगत जीवन इनका जन्म जालंधर (पंजाब, भारत) के एक व्यवसाय परिवार में हुआ था। वह अपने परिवार के सबसे युवा सदस्य हैं...
null
null
null
[DE Wikipedia] Ebru Ebru (türkisch: „Marmorpapier“) ist ein türkischer weiblicher Vorname persischer Herkunft. Namensträgerinnen Ebru Destan (* 1977), türkische Sängerin und ehemaliges Model Ebru Gündeş (* 1974), Künstlerin der türkischen arabesken Musik Ebru Polat (* 1983), türkische Pop-Sängerin Ebru Şam (* 1990), M...
null
null
null
null
Create a print statement that will print out a formatted table containing the elements of a 2D list.
2D List: [[1,2,3], [4,5,6], [7,8,9]]
# Get the list twoD_list = [[1,2,3], [4,5,6], [7,8,9]] # Print it out as a table for row in twoD_list: for val in row: print('{:4}'.format(val), end="") print() # Output # 1 2 3 # 4 5 6 # 7 8 9
null
Determine the accuracy of a model trained on a given dataset.
Accuracy of a model can be determined by computing its predictions against the actual values of the dataset, and then comparing the number of correct predictions with the total number of predictions. The accuracy of the model is then calculated as the proportion of correct predictions to the total number of predictions...
null
Sort this list of strings alphabetically.
strings = ['hello', 'world', 'this', 'is', 'a', 'list', 'of', 'strings']
strings.sort(key=lambda x: x.lower())
null
Create a Python class called 'Book' that stores an ISBN, title, author and publisher for a book.
class Book: def __init__(self, isbn, title, author, publisher): self.isbn = isbn self.title = title self.author = author self.publisher = publisher def get_isbn(self): return self.isbn def get_title(self): return self.title def get_author(self): ...
null
Develop a Python 3 function that implements a linear search algorithm.
[4, 1, 9, 6]
def linear_search(arr, target_val): """ This function performs linear search on an array to find the target value """ for idx in range(len(arr)): if arr[idx] == target_val: return idx return -1 target_val = 9 arr = [4, 1, 9, 6] target_idx = linear_search(arr, target_val) if target_idx...
[DE Wikipedia] Zollverein Zollverein steht für: Zeche Zollverein, ehemalige Zeche und Weltkulturerbe in Essen Kokerei Zollverein, ehemalige Kokerei und Weltkulturerbe in Essen Zollverein-Kubus, ein architektonisch innovatives Gebäude, das von der Folkwang Universität genutzt wird Deutscher Zollverein, ab 1834 handelsp...
null
null
null
null
Develop an Angular application that displays the current date and time.
import { Component } from '@angular/core'; @Component({ selector: 'app-root', template: ` <h1>{{ dateTime | date:'dd/MM/yyyy HH:mm:ss' }}</h1> ` }) export class AppComponent { dateTime = new Date(); }
null
Explain how a Depth-First-Search (DFS) algorithm works.
A Depth-First-Search (DFS) algorithm is a graph traversal technique used to traverse a graph or tree. It starts at the root node of the graph and visits each of its adjacent nodes in a pre-defined order. For each adjacent node, it visits the node and checks to see if the node has been visited. If the node has not been ...
null
Write HTML code to generate a table of 5 rows and 4 columns.
<table> <tr> <th>Col1</th> <th>Col2</th> <th>Col3</th> <th>Col4</th> </tr> <tr> <td>Row1</td> <td>Row1</td> <td>Row1</td> <td>Row1</td> </tr> <tr> <td>Row2</td> <td>Row2</td> <td>Row2</td> <td>Row2</td> </tr> <tr> <td>Row3</td> <td>Row3</td> <td>Row3</td> <td>Row3</td> </tr> <tr> <td>Row4</td> <td>Row4</td> <td>Row4</t...
[HI Wikipedia] राहुल द्रविड़ राहुल शरद द्रविड़ (कन्नड़: ರಾಹುಲ್ ಶರದ್ ದ್ರಾವಿಡ, ) (जन्म - 11 जनवरी 1973) भारतीय क्रिकेट टीम के सबसे अनुभवी खिलाड़ियों में से एक हैं, 1996 से वे इसके नियमित सदस्य रहें हैं। अक्टूबर 2005 में वे भारतीय क्रिकेट टीम के कप्तान के रूप में नियुक्त किये गए और सितम्बर 2007 में उन्होंने अपने इस पद से...
null
null
null
[DE Wikipedia] Mercédès Jellinek Mercédès Adrienne Ramona Manuela von Weigl, geborene Jellinek, geschiedene von Schlosser (* 16. September 1889 in Wien; † 23. Februar 1929 ebenda), ist die Namenspatin der Automobilmarke Mercedes und in Folge von Mercedes-Benz. Leben Mercédès Jellineks Eltern waren der österreichisch-u...
null
null
null
[HI Wikipedia] पश्चिमी विक्षोभ पश्चिमी विक्षोभ या वेस्टर्न डिस्टर्बन्स (Western Disturbance) भारतीय उपमहाद्वीप के उत्तरी इलाक़ों में सर्दियों के मौसम में आने वाले ऐसे तूफ़ान को कहते हैं जो वायुमंडल की ऊँची तहों में भूमध्य सागर, अन्ध महासागर और कुछ हद तक कैस्पियन सागर से नमी लाकर उसे अचानक वर्षा और बर्फ़ के रूप में उत्...
null
null
null
[CS Wikipedia] Esperanto Esperanto (původně Lingvo Internacia – „mezinárodní jazyk“) je nejrozšířenějším mezinárodním plánovým jazykem. Název esperanto je odvozen ze pseudonymu, pod nímž roku 1887 polský židovský lékař Ludvík Lazar Zamenhof základy této řeči publikoval. Záměrem tvůrce bylo vytvořit snadno naučitelný n...
null
null
null
[DE Wikipedia] W. Kerr Scott William Kerr Scott (* 17. April 1896 in Haw River, Alamance County, North Carolina; † 16. April 1958 in Burlington, North Carolina) war ein US-amerikanischer Politiker (Demokratische Partei) und von 1949 bis 1953 Gouverneur von North Carolina. Von 1954 bis 1958 vertrat er diesen Bundesstaa...
null
null
null
[EN Wikipedia] North Carolina General Assembly of 1862–1864 The North Carolina General Assembly of 1862–1864 met in Raleigh from November 17, 1862, to December 22, 1862. Extra sessions were held on January 19, 1863 – February 12, 1863; June 30, 1863 – July 7, 1863; November 23, 1863 – December 14, 1863; and May 17–30,...
null
null
null
[CS Wikipedia] Adolf Staňura Adolf Staňura (12. března 1915 – 16. března 2004) byl přední český esperantský literát. Zabýval se především překlady děl českých autorů do esperanta: La perdita vizaĝo (Ztracená tvář) — vědeckofantastický román Josefa Nesvadby Meze de Eŭropo… skize pri la historio de Ĉeĥoslovakio — přelož...
null
null
null
null
Construct a SQL query to find the maximum salary from a table named "employees".
SELECT MAX(salary) FROM employees;
null
Design a regular expression for validating email address.
^[a-z0-9]+@[a-z]+\.[a-z]+$
null
Write a CSS code to style all links (a element) with a red color.
a { color: red; }
[EN Wikipedia] Halectinosoma Halectinosoma is a genus of copepods belonging to the family Ectinosomatidae. The genus has almost cosmopolitan distribution. Species: Halectinosoma abyssicola Bodin, 1968 Halectinosoma angulifrons (Sars, 1919) References Harpacticoida Copepod genera
null
null
null
null
Create a class in Python for a Pizza. The Pizza class should have attributes for size, crust, and toppings
Not applicable
class Pizza: def __init__(self, size, crust, *toppings): self.size = size self.crust = crust self.toppings = toppings def describe_pizza(self): print(f"This pizza is a {self.size}-inch pizza with a {self.crust} crust and the following toppings:") for topping in self.toppings: print(f"- {topping}") my_pizza = ...
[HI Wikipedia] किशनगंगा नदी किशनगंगा नदी (Kishanganga River) भारत के जम्मू और कश्मीर प्रदेश में बहने वाली एक नदी है। यह कृशनसर में उत्पन्न होती है और झेलम नदी की एक उपनदी है, जो स्वयं सिन्धु नदी की उपनदी है। इसके प्रवाह मार्ग का कुछ भाग पाक-अधिकृत कश्मीर में है, जहाँ भारत अपनी सम्प्रभुता का दावा करता है। पाकिस्तान अपन...
null
null
null
null
Sort the list of numbers [3,2,7,9,1] in ascending order.
list = [3,2,7,9,1]
list.sort() print(list) # Output [1,2,3,7,9]
[HI Wikipedia] एर्नाकुलम एर्नाकुलम (Ernakulam) भारत के केरल राज्य का एक नगर है। यह कोच्चि महानगर का केन्द्रीय भाग है। इसके नाम पर एर्नाकुलम ज़िले का नाम रखा गया है। विवरण एर्नाकुलम केरल राज्य के मध्य में स्थित है। यह कोच्चि शहर के पूर्वी, मुख्यभूमि हिस्से को संदर्भित करता है। यह कोच्चि का सबसे शहरी भाग है। एरनाकुलम को...
null
null
null
null
Create a Python Class to handle JSON formatted data
import json class JSONHandler(): '''A class to handle JSON-formatted data''' def __init__(self, json_string): self.json_string = json_string self.data = self.__parse_json_data() def __parse_json_data(self): parsed_data = json.loads(self.json_string) return pars...
null
Generate a solution in python that takes a string containing letters and numbers and returns the frequency of each character.
"helloWorld12345"
def count_frequency(string): counts = {} for char in string: if char in counts: counts[char] += 1 else: counts[char] = 1 return counts
[CS Wikipedia] Walter Bedell Smith Generál Walter Bedell Smith (5. října 1895 Indianapolis – 9. srpna 1961 Washington, D.C.) byl americký voják, zpravodajský důstojník, diplomat a státní úředník. Působil jako náčelník štábu vrchního velitele západních Spojenců ve 2. světové válce Dwighta D. Eisenhowera, v období 1946–...
null
null
null
null
Write a Python code snippet to calculate the area of a triangle with side lengths 3, 4, and 5.
def area(a, b, c): s = (a + b + c) / 2 return (s*(s-a)*(s-b)*(s-c)) ** 0.5 print(area(3, 4, 5)) # 6.0
null
Write a code to create a sentence from a given list of words.
words = ["Today","I","am","happy"]
def create_sentence(words): sentence = "" for word in words: sentence += word + " " return sentence.strip() if __name__ == "__main__": words = ["Today","I","am","happy"] print(create_sentence(words)) Output: Today I am happy
null
Create a C# class that contains two private fields, one public method, and one property.
public class myClass { private int myField1; private string myField2; public void myMethod() { Console.WriteLine("myMethod is called"); } public int MyProperty { get { return myField1; } set { myField1 = value; } } }
null
Write a Python program to create a tic-tac-toe game.
# define a function to draw the board def draw_board(): print("\n") print(" --- | --- | --- ") print(" 7 | 8 | 9 ") print(" --- | --- | --- ") print(" 4 | 5 | 6 ") print(" --- | --- | --- ") print(" 1 | 2 | 3 ") print(" --- | --- | --- ") # ...
null
Organize the following array of objects in ascending order by the 'name' field.
[ { name: 'Jill', lastname: 'Smith' }, { name: 'Bob', lastname: 'Jones' }, { name: 'Jack', lastname: 'Bauer' } ]
let arr = [ { name: 'Jill', lastname: 'Smith' }, { name: 'Bob', lastname: 'Jones' }, { name: 'Jack', lastname: 'Bauer' } ]; arr.sort((a, b) => (a.name > b.name) ? 1 : -1); console.log(arr);
[CS Wikipedia] Jindřich IV. z Hradce Jindřich IV. z Hradce (13. dubna 1442 – 17. ledna 1507) byl český šlechtic z rodu pánů z Hradce, který za Vladislava Jagellonského zastával funkce nejvyššího komorníka Českého království a nejvyššího pražského purkrabího. Život Byl synem Jana IV. z Hradce, zvaného Telecký, a Kateři...
null
null
null
[DE Wikipedia] Château d’Urville Das Château d’Urville (Schloss Urville) ist ein Schloss in der historischen Landschaft Lothringen. Bekannt ist es vor allem, weil es von 1890 bis 1918 Kaiser Wilhelm II. gehörte. Geographie Das Schloss liegt am linken Ufer der Nied auf dem Gebiet der Gemeinde Courcelles-Chaussy im Dépa...
null
null
null
null
Write a function which takes a number and returns the Fibonacci sequence up to that number.
n = 10
def fibonacci(n): fib_list = [1] if n == 1: return fib_list else: fib_list.append(1) while len(fib_list) < n: fib_list.append(fib_list[-1] + fib_list[-2]) return fib_list
null
Modify the code to convert any temperature from Celsius to Fahrenheit
def CtoF(x): #TODO
def CtoF(x): F = (9/5 * x) + 32 return F
null
Write a web scraper in Python that can extract the text content from a block of HTML.
<div> <h1>This is an example block of HTML</h1> <ul> <li>This is the first item</li> <li>This is the second item</li> </ul> </div>
import requests from bs4 import BeautifulSoup html = '<div> <h1>This is an example block of HTML</h1> <ul> <li>This is the first item</li> <li>This is the second item</li> </ul> </div>' soup = BeautifulSoup(html, 'html.parser') for item in soup.find_all('li'): print(item.text) # Output # This is the first item # T...
null
Create a program in Python to find the maximum value in a given sequence.
[3, 4, 6, 2, 8, 9, 5]
def findMaxValue(arr): max_val = arr[0] for i in range(1, len(arr)): if arr[i] > max_val: max_val = arr[i] return max_val arr = [3, 4, 6, 2, 8, 9, 5] maxValue = findMaxValue(arr) print('Max value in given array is: {}'.format(maxValue))
null
Generate a random sample of size 10 using numpy
import numpy as np rand_sample = np.random.randint(low=0, high=100, size=10)
null
Create a JavaScript function that takes an array of numbers and returns the median value from the array.
function getMedian(arr) { arr.sort(function (a, b) { return a - b; }); let mid = Math.floor(arr.length / 2); if (arr.length % 2 === 0) { return (arr[mid - 1] + arr[mid]) / 2; } else { return arr[mid]; } }
null
Construct a JavaScript object with three properties: name, age, and profession.
const person = { name: 'John Doe', age: 36, profession: 'developer' };
null
Update the following HTML page so that it refreshes the page every 5 seconds.
<html> <head> <title>My Webpage</title> </head> <body> Hello World! </body> </html>
<html> <head> <title>My Webpage</title> <meta http-equiv="refresh" content="5"> </head> <body> Hello World! </body> </html>
[CS Wikipedia] Terminologie Terminologie je nauka o termínech, tj. o odborných názvech, a o způsobu jejich vytváření a sestavování do systémů. Výraz terminologie se častěji používá pro označení konkrétních systémů termínů, česky označovaných též slovem názvosloví, případně odborné názvosloví. Rozdělení názvosloví Neod...
null
null
null
null
Write an SQL query for finding all books with the title “The Great Gatsby”.
SELECT * FROM BOOKS WHERE Title = 'The Great Gatsby'
null
Given an array of numbers, write a Python program to calculate the sum of the integers in the array.
[5, 2, 8, 4, 23]
def sum_integer(arr): """ Args : arr (list): List of integer Returns : int : Sum of integers """ res = 0 for num in arr: res += num return res sum_integer([5, 2, 8, 4, 23]) # output: 42
null
Create a JavaScript function for the linear search algorithm.
// Linear search algorithm function linearSearch(array, item) { for (let i = 0; i < array.length; i++) { if (array[i] === item) { return i; } } return -1; } // Example Usage let array = [2, 3, 4, 5, 6, 7]; let item = 5; let index = linearSearch(array, item); // index should be 3
null
Create a SQL query to count all buyers from a country.
TableName: Customers Columns: CustomerID INT Name VARCHAR(40) Country VARCHAR(20) TableName: Purchases Columns: PurchaseID INT CustomerID INT
SELECT COUNT(*) FROM Customers c INNER JOIN Purchases p ON c.CustomerID = p.CustomerID WHERE c.Country = 'CountryName';
null
Write a Python script to convert a given temperature from Fahrenheit to Celsius.
def fahrenheit_to_celsius(fahrenheit): return (fahrenheit - 32) * 5/9
null
Edit the following function to only accept lowercase parameters.
def greeting(name): print('Hello, ' + name + '!')
def greeting(name): name = name.lower() print('Hello, ' + name + '!')
null
Create two classes, Dog and Cat, that extend the Animal class.
class Animal: def __init__(self, name): self.name = name self.health = 100
class Animal: def __init__(self, name): self.name = name self.health = 100 class Dog(Animal): def bark(self): print("Woof!") class Cat(Animal): def meow(self): print("Meow!")
null
Generate all possible permutations of this list.
my_list = [1, 2, 3]
from itertools import permutations permutation_list = list(permutations(my_list)) print(permutation_list) # Output: [(1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1)]
[DE Wikipedia] 9. Panzergrenadierbrigade Die 9. Panzergrenadierbrigade war eine Brigade des Österreichischen Bundesheeres und bestand aus Bataillonen verschiedener Waffengattungen in Niederösterreich. Die Brigade wurde im Zuge der Neuausrichtung des Bundesheeres 1998 aufgelöst. Geschichte Die 9. Panzergrenadierbrigade...
null
null
null
null
Create a function to search for a given element in a list and output its index.
list_numbers = [1, 2, 3, 4, 5]
def search_list(list_numbers, element): for i in range(len(list_numbers)): if list_numbers[i] == element: return i
null
Create a Java program to list out all prime numbers between 1 and n.
n = 20
public class AllPrimeNumbers { public static void main(String args[]) { int n = 20; System.out.print("All Prime Numbers between 1 and " + n + " are: "); for (int i = 2; i <= n; i++) { boolean isPrime = true; for (int j = 2; j < i; j++) { if (i % j == 0) { isPrime = false; break; } } if (isPrime) { System.out.print(i + ...
null
Construct a simple algorithm to check if a number is prime
11
def is_prime(n): # check if n is divisible by any number between 2 and n-1 for i in range (2, n): # if a number is divisible, then return False if (n % i == 0): return False # if n is only divisible by itself, return True return True if __name__ == '__main__': n = 11 if(is_prime(n)): print(n, "is a prime number") else:...
null
Create a Python script that takes an array of integers and prints the number of positive,negative, and zero elements in the array.
[1, 0, -2, 3, 4, -6]
# Defining the function def count_positive_negative_zero(arr): # Keeping track of the counts positive_count = 0 negative_count = 0 zero_count = 0 # Iterating over the array of integers for number in arr: if number > 0: positive_count += 1 elif number == 0: zero_count += 1 elif number < 0: negative_count +=...
[HI Wikipedia] होली होली वसंत ऋतु में मनाया जाने वाला एक महत्वपूर्ण भारतीय और नेपाली लोगों का त्यौहार है। यह पर्व हिंदू पंचांग के अनुसार फाल्गुन मास की पूर्णिमा को मनाया जाता है। होली रंगों का तथा हँसी-खुशी का त्योहार है। यह भारत का एक प्रमुख और प्रसिद्ध त्योहार है, जो आज विश्वभर में मनाया जाने लगा है। रंगों का त्यौहा...
null
null
null
null
Define a function in Python that takes a number as an argument and returns its cube.
def cube(number): return number**3
null
Calculate the area of a circle using a Python program
radius = 7
import math def areaOfCircle(radius): area = round(math.pi * (radius ** 2), 2) return area area = areaOfCircle(7) print(area)
null
Build a Python program to compute the sum of the two given integers.
a = 10 b = 20
def add_two_ints(a, b): return a + b
null
Generate a neural network model in Python to predict the outcome of a basketball match given the players' stats.
Player 1: Height: 185cm; Weight: 80kg, Number of Points scored: 20 Player 2: Height: 202cm; Weight: 100kg, Number of Points scored: 30
model = Sequental() model.add(Dense(units=64, input_shape=(3,))) model.add(Activation('relu')) model.add(Dropout(.2)) model.add(Dense(32)) model.add(Activation('relu')) model.add(Dropout(.2)) model.add(Dense(1)) model.add(Activation('sigmoid')) model.compile(loss='binary_crossentropy', optimizer='Adam',...
null
Create a basic class in JavaScript that includes a constructor, a method for changing the greeting, and a method for saying the greeting.
""" Basic class in JavaScript with a constructor, a method for changing the greeting and a method for saying the greeting """ class GreetingGenerator { constructor(greeting) { this.greeting = greeting } setGreeting(greeting) { this.greeting = greeting } sayGreeting() { console.log(this.greeting) } } const greet = new G...
null
Develop a program to encrypt a text
#include <stdio.h> #include <string.h> // Encode a string using Ceasar cipher string ceasar_encode(string s, int k) { // Declare a variable to store the encoded string string encoded_str = ""; // Loop through the string and encode each character for (int i=0; i<strlen(s); i++) { // Shift each character with the given k...
null
Create an array in Python with 6 elements and print the last three elements.
my_array = [1, 2, 3, 4, 5, 6] #Print the last three elements print (my_array[-3:]) #Output:[4, 5, 6]
null
Provide a Python program that sorts a list of strings based on the length of the strings.
["banana", "apple", "watermelon"]
my_list = ["banana", "apple", "watermelon"] my_list.sort(key=len) # my_list is now ["apple", "banana", "watermelon"]
null
Craft a Python program to extract characters from the odd positions of a given string.
def extract_odd_pos(string): odd_position = "" for i in range(len(string)): if i%2 == 0: odd_position += string[i] return odd_position
[EN Wikipedia] Serbia and Montenegro women's national under-20 basketball team The Serbia and Montenegro women's national under-20 basketball team was a national basketball team of Serbia and Montenegro, administered by the Basketball Federation of Serbia and Montenegro. It represented the country in women's internati...
null
null
null
null
What are the advantages of using MapReduce over Hadoop?
The advantages of using MapReduce over Hadoop include: 1. Charges less money due to its parallel processing capabilities. 2. Can handle much larger data sets than Hadoop since it uses distributed computing paradigm. 3. Increases in scalability and performance due to its ability to horizontally scale computing nodes. 4....
null
Build a HTML table using the given JSON data
data = { "col1": ["One", "Two", "Three"], "col2": ["Alpha", "Beta","Gamma"] }
<table> <tr> <th>Col1</th> <th>Col2</th> </tr> <tr> <td>One</td> <td>Alpha</td> </tr> <tr> <td>Two</td> <td>Beta</td> </tr> <tr> <td>Three</td> <td>Gamma</td> </tr> </table>
null
Write a python program to create a class called cube.
class Cube: def __init__(self, length, width, height): self.length = length self.width = width self.height = height def calculate_volume(self): return self.length * self.width * self.height
null
Provide an example of a valid JSON object.
{ "name": "John Doe", "age": 25, "address": { "street": "123 Main Street", "city": "New York", "state": "NY" }, "hobbies": ["sports", "reading", "writing"] }
null
How would you create a table in a database using SQL commands?
To create a table in a database using SQL commands, you would use the following SQL statement: CREATE TABLE <table_name>(column_name datatype);
null
Write a python program to complete this task.
Given two strings, find the length of the smallest substring that contains both of them. Input: "abbcd" and "accde"
def shortest_substring(s1, s2): s1_len = len(s1) s2_len = len(s2) res_str = "" res_len = s1_len + s2_len for i in range(s1_len): for j in range(s2_len): # Initializing starting and ending indexes # of current substring ...
null
Create a C# function to edit the contents of a list.
public void EditList(List<string> list, string oldVal, string newVal) { for(int i = 0; i < list.Count; i++ ) { if (list[i] == oldVal){ list[i] = newVal; } } }
null
Write a Python function to convert a list of integers into a comma separated string.
int_list = [1, 4, 5, 6, 7]
def list_to_string(int_list): string = "" for i in int_list: string += str(i) + "," # Remove trailing comma string = string[:-1] return string int_list = [1, 4, 5, 6, 7] print(list_to_string(int_list)) // "1,4,5,6,7"
null
Create a SQL query to select the rows with column B equal to "test" and column C equal to "example"
SELECT * FROM table WHERE B = 'test' AND C = 'example'
null
Syntax to declare an array in JavaScript.
const arrayName = [];
null
Update the given array to replace all the zeroes with ones.
my_array = [1, 0, 2, 0, 3, 0]
my_array = [1, 1, 2, 1, 3, 1]
[EN Wikipedia] Atlantic Ocean The Atlantic Ocean is the second-largest of the world's five oceans, with an area of about . It covers approximately 17% of Earth's surface and about 24% of its water surface area. It is known to separate the "Old World" of Africa, Europe, and Asia from the "New World" of the Americas in ...
null
null
null
[CS Wikipedia] Paul Neergaard Pierre Paul Ferdinand Mourier de Neergaard, , známější jako Paul Neergard (19. února 1907 – 13. listopadu 1987), byl dánský profesor agronomie, esperantista a redaktor.. Dílo Atakoj kontraü gardenplantoj, La vivo de I.A Plantoj, dílo bylo přeloženo do mnoha jazyků Terminaro hortikultura S...
null
null
null
null
Write C++ code to calculate the sum of the elements in an array.
int sumArrayElements(int arr[], int n) { int sum = 0; for (int i = 0; i < n; i++) sum += arr[i]; return sum; }
null
Write an algorithm in Python that takes an input of positive integers and for each element in the list multiplies it by 2 if it is even and divide it by 3 if it is odd.
[2, 3, 4, 6, 8, 10]
def multiplyOddDivideEven(lst): new_list = [] for element in lst: if element % 2 == 0: new_list.append(element / 3) else: new_list.append(element * 2) return new_list print(multiplyOddDivideEven([2, 3, 4, 6, 8, 10])) # prints [1.0, 6, 2.0, 4.0, 4.0, 5.0]