text
stringlengths
141
2.89k
⌀
instruction
stringlengths
19
1.5k
⌀
input
stringlengths
0
800
⌀
output
stringlengths
1
2.5k
⌀
null
Implement a basic machine learning model in Python that performs binary classification on the given data.
[ [0.3, 0.2, 0.6], [0.3, 0.1, 0.4], [0.2, 0.3, 0.4], [0.7, 0.4, 0.2], [0.5, 0.2, 0.1] ]
from sklearn import linear_model from sklearn.metrics import accuracy_score X = [[0.3, 0.2, 0.6], [0.3, 0.1, 0.4], [0.2, 0.3, 0.4], [0.7, 0.4, 0.2], [0.5, 0.2, 0.1]] y = [1, 0, 0, 1, 0] model = linear_model.LogisticRegression() model.fit(X, y) y_pred = model.predict(X) accuracy = accuracy_score(y, y_pred) print('Mo...
null
Generate a Python program to clean a string of HTML tags.
Example Input: "<p>This is a <b>test</b> string</p>".
import re # Clean a string of HTML tags def clean_html_tags(str): clean_str = re.sub("<.*?>", "", str) return clean_str html_string = "<p>This is a <b>test</b> string</p>" clean_str = clean_html_tags(html_string) print(clean_str) #This is a test string
null
Write a C++ function which allows the user to input two strings and prints the longest string.
void getLongestString(string str1, string str2) { // variables to store length of both strings int l1 = str1.length(), l2 = str2.length(); if (l1 > l2) cout << str1; else cout << str2; }
[DE Wikipedia] Philipp-Melanchthon-Gymnasium (Meine) Das Philipp-Melanchthon-Gymnasium ist ein staatlich anerkanntes, vierzügiges allgemeinbildendes Gymnasium in der Gemeinde Meine im Landkreis Gifhorn in Trägerschaft der Evangelisch-lutherischen Landeskirche Hannovers. Es ist benannt nach Philipp Melanchthon (1497–15...
null
null
null
null
Generate SQL code to create a table of users with the columns (user_id, name, email, age).
CREATE TABLE users ( user_id INT NOT NULL AUTO_INCREMENT, name VARCHAR(255), email VARCHAR(255), age INT, PRIMARY KEY (user_id) );
null
Create a Python script to find the most frequently occurring element in an array.
[5, 4, 6, 7, 4, 5, 12, 8]
def most_frequent(arr): arr.sort() max_count = 1 max_item = arr[0] curr_count = 1 for i in range(1, len(arr)): if arr[i] == arr[i - 1]: curr_count += 1 if curr_count > max_count: max_count = curr_count max_item = arr[i] els...
[EN Wikipedia] Michael Bonacini Michael Bonacini (born March 1, 1960) is a Welsh-Canadian chef who owns eleven restaurants (including Jump, Canoe, Luma, and Bannock) in Toronto, Ontario and is a co-founder of Oliver & Bonacini Restaurants. Bonacini trained in London and immigrated to Canada in 1985. He founded his fir...
null
null
null
[CS Wikipedia] Čas Čas (značka t) je jednou ze základních fyzikálních veličin soustavy SI, která se měří v sekundách (s) pomocí hodin. Čas označuje dobu, která uplyne mezi dvěma okamžiky. V jiném chápání je čas pojímán jako čtvrtý rozměr 3D prostoru, v teorii relativity součást časoprostoru. Pojem „čas“ může také ozna...
null
null
null
null
Develop an algorithm in Python to create a Fibonacci sequence up to the nth number.
n=10
def fibonacci(n): if n<0: print("Incorrect input") elif n==1: return 0 elif n==2: return 1 else: return fibonacci(n-1)+fibonacci(n-2) print("Fibonacci series up to",n,":") for i in range(1,n+1): print(fibonacci(i))
null
Write a Javascript function to determine if the given number is an even number or not.
function isEven(num) { return num % 2 === 0; }
null
Write a JavaScript function that takes in two arrays of equal length, and returns a third array with elements from both arrays.
[1, 2, 3], [10, 20, 30]
function combine(arr1, arr2) { const combinedArr = []; for(let i=0; i<arr1.length; i++) { combinedArr.push(arr1[i], arr2[i]); } return combinedArr; }
[DE Wikipedia] Wally Zepler Wally Zepler (* 8. November 1865 in Hirschberg, Niederschlesien; † 23. September 1940 in Bendorf) war eine deutsche Publizistin und sozialdemokratische Politikerin. Leben Zepler wuchs als Tochter von Max Meir Wÿgodzinski (1834–1909) und seiner Frau Nanny Wÿgodzinski geb. Sorauer in großbürg...
null
null
null
null
Generate a Python Program to generate a Bar Chart from a given list of data
data=[2,4,6,7]
import matplotlib.pyplot as plt def generate_bar_chart(data): plt.bar(list(range(len(data))), data) plt.xlabel('x') plt.ylabel('y') plt.title('Bar Chart') plt.show() if __name__ == '__main__': generate_bar_chart(data)
null
Create a HTML program to simulate a digital clock
<html> <head> <title>Digital Clock</title> <script> function showTime(){ var date = new Date(); var h = date.getHours(); // 0 - 23 var m = date.getMinutes(); // 0 - 59 var s = date.getSeconds(); // 0 - 59 var session = "AM"; if(h == 0){ h = 12; } if(h > 12){ h = h - 12; session = "PM"; } h = (h < 10) ? "0" + h : h; m =...
null
Edit the following HTML to make all text 16px font size.
<h1>This is a heading</h1> <p>This is a paragraph.</p>
<h1 style="font-size: 16px;">This is a heading</h1> <p style="font-size: 16px;">This is a paragraph.</p>
[HI Wikipedia] रॉल प्रमेय कलन विधियों में रॉल प्रमेय अथवा रोल का प्रमेय (Rolle's theorem) के अनुसार यदि किसी अवकलनीय फलन का मान दो अलग-अलग बिन्दुओं पर समान है तो आवश्यक रूप से उन दोनो बिन्दुओं के मध्य कम से कम एक बिन्दु ऐसा होगा जिसका अवकलज (फलन के ग्राफ में स्पर्शज्या का ढाल) शून्य अर्थात (०) होगा। रॉल का प्रमेय, माध...
null
null
null
[CS Wikipedia] Élysion Élysion, starořecky Ἠλύσιον, latinsky Elysium, bylo v řecké mytologii místo na západním okraji Země, kam bohové mohou za živa přenést své oblíbence. Později místo pobytu spravedlivých duší v podsvětí. Starověká mytologie Nesmrtelní hrdinové tam blaženě žijí za stálého jara a bez starostí. Hésiod...
null
null
null
null
Using jQuery, write a snippet to add a click event handler to a given HTML element.
#html element <div class="my-button">Click Me!</div>
$('.my-button').click(function(){ // Code here });
null
What is the significance of the ‘except’ statement in Python?
The ‘except’ statement in python is used to handle exceptions that may arise while executing a program. Exceptions can be either syntactic or logical errors. The ‘except’ statement can be used to catch the specific type of exception and handle them appropriately. For example, it can be used to catch a ValueError, TypeE...
[HI Wikipedia] क़ाहिरा मुहाफ़ज़ाह क़ाहिरा मुहाफ़ज़ाह (अरबी: , अंग्रेज़ी: Cairo) मिस्र का एक मुहाफ़ज़ाह (उच्च-स्तरीय प्रशासनिक विभाग) है। मिस्र की राजधानि क़ाहिरा इस मुहाफ़ज़ाह की राजधानी भी है। यह एक पूर्ण शहरी मुहाफ़ज़ाह है जिसके कोई 'मरकज़' नामक विभाग नहीं हैं। इन्हें भी देखें मिस्र के मुहाफ़ज़ात‎ सन्दर्भ क़ाहिरा मु...
null
null
null
[DE Wikipedia] A62 road Die A62 road (englisch für Straße A62) ist eine nur in der Nähe von Manchester bis Oldham als Primary route ausgewiesene Fernverkehrsstraße in England, die von Manchester nach Leeds führt und dabei die Pennines quert. Sie verläuft südlich des weitgehend parallelen M62 motorway. Verlauf In Manch...
null
null
null
[DE Wikipedia] Evangelische Kirche (Merzhausen) Die Evangelische Kirche Merzhausen ist ein denkmalgeschütztes Kirchengebäude in Merzhausen, einem Stadtteil von Usingen im Hochtaunuskreis in Hessen. Die Kirche gehört zur Kirchengemeinde Merzhausen-Lauken im Dekanat Hochtaunus der Propstei Rhein-Main der Evangelischen K...
null
null
null
null
This code is a DNS server that listens for queries and responds based on pre-defined rules. To use it, run the "run" function with input and output file objects. The input file should contain lines representing DNS queries in the format "cmd\tqname\tqclass\tqtype\tid\tremote-ip\tlocal-ip\tedns-subnet-address". The outp...
#!/usr/bin/env python from sys import exit, stdin, stderr, argv, stdout from inspect import stack from config import * import os import csv CONT=0 FINAL=1 default_ttl=60 loglevel=3 class istr(str): def __eq__(self, text): return str.__eq__(self.lower(), text.lower()) class qname(istr): def __new__(c...
null
Construct an object in JavaScript to store the details of a person with the fields "name","age" and "address".
let person = { "name": "John Doe", "age": 25, "address": "123 Main St, New York, NY 10001" }
null
Create a program that will generate random sequence of words.
import random def generate_random_words(n): words = ["hello", "world", "foobar", "python", "code"] output = "" for _ in range(n): output += random.choice(words) output += " " return output[:-1]
[DE Wikipedia] Liste der Alben in den Billboard-Charts (1946) Die Liste der Billboard-Alben (1946) ist eine vollständige Liste der Alben, die sich im Kalenderjahr 1946 platzieren konnten. Die über das Jahr ermittelten Top 5 setzten sich aus den Verkaufszahlen von mehr als zweihundert Vertriebsläden im Gesamtgebiet der...
null
null
null
null
Generate the Fibonacci sequence of length 8 (starting from 0) in Python.
def fibonacciSequence(n): a = 0 b = 1 if n < 0: print("Incorrect input") elif n == 0: return a elif n == 1: return b else: for i in range(2,n+1): c = a + b a = b b = c return b fibonacciSequence(8) # Output...
[DE Wikipedia] Kendal (Regierungsbezirk) Kendal ist ein indonesischer Regierungsbezirk (Kabupaten) in der Provinz Jawa Tengah, im Zentrum der Insel Java. Mitte 2022 leben hier über eine Million Menschen. Hauptstadt und Regierungssitz des Verwaltungsbezirks ist die Stadt Kendal, etwa 25 km nordwestlich der Provinzhaupt...
null
null
null
[CS Wikipedia] Goslar Goslar je město ležící uprostřed Německa v Dolním Sasku v pohoří Harz. Je okresním městem stejnojmenného okresu. Má titul "Velké samostatné město". Historie Goslaru je úzce svázána s těžbou rud v nedalekém Rammelsbergu. Místní doly a Goslar jsou od roku 1992 součástí světového dědictví UNESCO. Os...
null
null
null
null
Debug the following Python code
def f(x): if x > 0: return -1 else: return 1
""" Debug the following Python code def f(x): if x > 0: return -1 else: return 1 """ # incorrect indentation of the else statement def f(x): if x > 0: return -1 else: return 1 # correct indentation
null
Optimize the following Python function to calculate the sum of natural numbers up to a given number.
n = 10
def sum_natural_numbers(n): total = 0 for i in range(1, n + 1): total += i return total def sum_natural_numbers(n): return n * (n + 1) // 2 print(sum_natural_numbers(10))
null
Build a web application in Python using the Django web framework.
Not applicable
# Create a project directory mkdir myproject cd myproject # Create a virtual environment to isolate our package dependencies locally python3 -m venv env # Activate the virtual environment source env/bin/activate # Install Django and Django Rest Framework pip install django pip install djangorestframework # Start a new ...
null
Create a web scraper in Python using BeautifulSoup that extracts information about all the movies on IMDb in a specified year.
Year: 2020
import requests from bs4 import BeautifulSoup def get_movie_info(year): url = f'https://www.imdb.com/search/title/?title_type=feature&release_date={year}-01-01,{year}-12-31' response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') movie_containers = soup.find_all('div', class_ = ...
null
Construct a Java method to convert a string to its equivalent title case format.
String: this is the string to be converted
public static String toTitleCase(String input) { StringBuilder titleCase = new StringBuilder(); boolean nextTitleCase = true; for (char c : input.toCharArray()) { if (Character.isSpaceChar(c)) { nextTitleCase = true; } else if (nextTitleCase) { c = Character.toTitleCase(c); nextTitleCase = false; } titleCase.append(c);...
null
Implement a quick-sort algorithm in Python to sort a given array in ascending order.
def quick_sort(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 quick_sort(left) + middle + quick_sort(right)
[HI Wikipedia] त्रिपुरा त्रिपुरा उत्तर-पूर्वी सीमा पर स्थित भारत का एक राज्य है।यह भारत का तीसरा सबसे छोटा राज्य है जिसका क्षेत्रफल १०,४९१ वर्ग किमी है। इसके उत्तर, पश्चिम और दक्षिण में बांग्लादेश स्थित है जबकि पूर्व में असम और मिजोरम स्थित हैं।सन २०११ में इस राज्य की जनसंख्या लगभग ३६ लाख ७१ हजार थी। अगरतला त्रिपुरा क...
null
null
null
null
Create a Python program to calculate the output of a given system of linear equations.
3x + 2y = 8 x - y = 0
def calcSystem(equations): ans = [] M = [equations[0][0],equations[1][0],equations[0][2]] N = [equations[0][1],equations[1][1],equations[1][2]] for x in range(3): if N[x] != 0: ans.append(M[x]/N[x]) M[(x+1)%3] = M[(x+1)%3] - (M[x]/N[x]) * N[(x+1)%3] N[(x+1)%3] = N[(x+1)%3] - (M[x]/N[x]) * ...
null
Find a Python library to create a connection to a MongoDB database and import the data.
# Import the necessary library import pymongo # Establish a connection to the MongoDB database client = pymongo.MongoClient("mongodb://localhost:27017/") # Import the data into the database db = client.myDatabase records = db.myCollection with open('data.json', 'r') as f: data = json.load(f) records.insert_ma...
null
Generate a Python dictionary from a given list of strings.
["Apple", "Banana", "Carrot"]
# Create a dictionary from a list my_dict = {key: value for key, value in enumerate(["Apple", "Banana", "Carrot"])} # Print dictionary print(my_dict)
null
Write Python code to include exception handling in this code.
a = 1 b = 0 c = a / b print (c)
try: a = 1 b = 0 c = a / b print(c) except ZeroDivisionError: print("Cannot divide by zero")
[DE Wikipedia] Leichtathletik-Europameisterschaften 1998/Weitsprung der Frauen Der Weitsprung der Frauen bei den Leichtathletik-Europameisterschaften 1998 wurde am 21. und 22. August 1998 im Népstadion der ungarischen Hauptstadt Budapest ausgetragen. Zum vierten Mal in Folge wurde die Deutsche Heike Drechsler Europame...
null
null
null
null
Identify the most efficient algorithm to find the maximum element in an array.
The most efficient algorithm to find the maximum element in an array is the Linear Search algorithm. This algorithm works by looping through the array and comparing each element to find the maximum element. This algorithm takes O(n) time and requires no additional space.
null
Create a Python script to scrape content from a website.
Website URL: 'https://example.com'
import requests from bs4 import BeautifulSoup url = 'https://example.com' page = requests.get(url) soup = BeautifulSoup(page.content, 'html.parser') for content in soup.find_all('div', class_='content'): print(content.text)
null
Name a built-in function that rounds off a given number to the nearest whole number.
The built-in function to round off a given number to the nearest whole number is the round() function.
null
Optimize a Python program to count occurrences of each letter in a given string.
"This is a sample string"
from collections import Counter def count_letters(string): return Counter(string) print(count_letters("This is a sample string"))
null
Convert the following Algorithm into Python code. Input: two numbers Algorithm: 1. Check if the two numbers are equal. 2. If true, return 0. 3. Else check the which is higher. 4. Return 1 if the first number is higher than the second one. 5. Return -1 otherwise.
num1 : 5 num2 : 10
def compare_numbers(num1, num2): if num1 == num2: return 0 elif num1 > num2: return 1 else: return -1 num1 = 5 num2 = 10 result = compare_numbers(num1, num2) print(result)
null
Edit the provided code so that the output is 2021.
x = 2020 y = 1 print(x + y)
x = 2020 y = 1 print(x + y + 1)
[EN Wikipedia] Anthony Elujoba Anthony Elujoba (born 1948) is a Nigerian professor of Pharmacognosy, fondly referred to as the "village chemist" because of his involvement in research into medicinal plants. He was acting vice chancellor of Obafemi Awolowo University, Nigeria. References See also List of vice chancello...
null
null
null
[HI Wikipedia] जूनो जूनो (अंग्रेज़ी : :en:Juno, लातिनी : IVNO यूनो ) प्राचीन रोमन धर्म में देवराज बृहस्पति की पत्नी और मंगल, वल्कन, बेलोना तथा जुवेंटस की माँ तथा प्रमुख देवियों में से एक थीं। वे राज्य की संरक्षिका और विशेष सलाहकार थीं। वे देवताओं की रानी और स्त्रियों और विवाहों की देवी थीं। उनके समतुल्य प्राचीन यूनानी...
null
null
null
null
Create a function in Python to convert a hexadecimal string (e.g. "0xBA") to a binary string (e.g. "10111010").
"0xA2"
def hex_to_binary(hex_str): # convert hex to int num = int(hex_str, 16) # convert int to binary string bin_str = bin(num)[2:] return bin_str print(hex_to_binary("0xA2")) # Output: "10100010"
null
Write a Python script to compute the area of the circle using its radius.
import math def compute_area_of_the_circle(radius): return math.pi * (radius**2)
null
Construct a C# program to display Fibonacci series.
using System; class Fibonacci { static void Main() { int n1 = 0, n2 = 1, n3, i, number; Console.Write("Enter the number of elements: "); number = int.Parse(Console.ReadLine()); Console.Write(n1 + " " + n2 + " "); for (i = 2; i < number; ++i) { n3 = n1 + n2; Console.Write(n3 + " "); n1 = n2; n2 = n3; } } }
null
Create a Java program that prints out the Fibonacci series within a given range
Range = (5, 15)
public class FibonacciRange { public static void main(String args[]) { // Set the range int lowerLimit=5, upperLimit=15; // Print the fibonacci series for (int number = lowerLimit; number <= upperLimit; number++) { System.out.print(fibonacciSeries(number) +" "); } } // Generates the fibonacci series public static int f...
[DE Wikipedia] Fußball-Europameisterschaft der Frauen 1984/Frankreich Dieser Artikel befasst sich mit der französischen Nationalelf bei der Fußball-Europameisterschaft der Frauen 1984. Erste Runde Für diese erste, von der UEFA organisierte Fraueneuropameisterschaft hatten insgesamt 16 Nationalfrauschaften gemeldet. Di...
null
null
null
[EN Wikipedia] Parapara River The Parapara River is a river of the Tasman Region of New Zealand's South Island. It flows generally north from its watershed in the Kahurangi National Park, reaching Golden Bay at the small settlement of Parapara, 5 kilometres south of Collingwood. In Māori tradition, the river is inhabi...
null
null
null
null
Write Python code to store odd numbers from the given list in a separate list.
list = [1, 2, 3, 4, 5, 6, 7]
odds = [] for num in list: if num % 2 != 0: odds.append(num)
null
Create a WebSocket server in Python.
Not applicable
import asyncio import websockets async def hello(websocket, path): greeting = await websocket.recv() print(f"< {greeting}") async def hello_server(): server = await websockets.serve(hello, '127.0.0.1', 8765) await server.wait_closed() asyncio.get_event_loop().run_until_complete(hello_server()) asyncio.get_event_...
null
Create a machine learning model in Python that predecits customer lifetime value given a customer's past transactions.
Not applicable
import pandas as pd import numpy as np from sklearn.preprocessing import StandardScaler from sklearn.ensemble import RandomForestRegressor # Preprocessing df = pd.read_csv('transactions.csv') X = df.iloc[:,:-1].values y = df.iloc[:,-1].values scaler = StandardScaler() X = scaler.fit_transform(X) # Model Training mod...
null
Convert a string into list of characters.
string = "Hello World!"
char_list = list(string) print(char_list) # Output: ['H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', '!']
null
Create a SQL query that finds the average salary of employees aged between 25 and 30.
SELECT AVG(salary) FROM Employees WHERE age BETWEEN 25 AND 30;
null
Sort the given list using the quicksort algorithm.
my_list = [8, 5, 3, 9, 6, 1]
def quick_sort(arr): if len(arr) <= 1: return arr else: pivot = arr[0] left, right = [], [] # pivot for x in arr[1:]: if x > pivot: right.append(x) else: left.append(x) # concatenate return quick_sort(left) + [pivot] + quick_sort(right) quick_sort(my_list)
null
Create a code to print the nth Fibonacci number in Python.
def fibonacci_n(n): a = 0 b = 1 if n < 0: print("Incorrect input") elif n == 0: return a elif n == 1: return b else: for i in range(2,n): c = a + b a = b b = c return b n = 9 print(fibonacci_n(n))
[EN Wikipedia] Barney Mellows Herbert Charles Mellows (29 March 1896 – 25 February 1942) was an Irish Sinn Féin politician, and the brother of Liam Mellows. He was Director of Finance and commander of the 2nd Company in Dolphins Barn in the organisation, Fianna Éireann from August 1915 until the Easter Rising in 1916....
null
null
null
null
Make the following Python code snippet more efficient.
def determine_commission_rate(gross_sales): if gross_sales >= 10000: commission_rate = 0.1 elif gross_sales >= 5000 and gross_sales < 10000: commission_rate = 0.07 elif gross_sales < 5000: commission_rate = 0.05 return commission_rate
def determine_commission_rate(gross_sales): if gross_sales >= 10000: return 0.1 elif gross_sales >= 5000: return 0.07 else: return 0.05
null
Create an HTML button that opens an alert message with the words "Welcome".
<button onclick="alert('Welcome')">Click Me</button>
null
Write a SQL query to find the titles of all movies directed by Steven Spielberg.
SELECT title FROM movies WHERE director = 'Steven Spielberg';
null
Write a Python script that filters a list of integers and returns only even numbers.
list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
def filter_even_numbers(lst): # Filter out even numbers from the given list even_numbers = [num for num in lst if num % 2 == 0] return even_numbers list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] result = filter_even_numbers(list) print(result)
[DE Wikipedia] Florian Heinke Florian Heinke (* 1981 in Frankfurt am Main) ist ein deutscher Maler. Er lebt und arbeitet in Frankfurt am Main. Leben Florian Heinke studierte von 2004 bis 2005 an der Kunsthochschule Mainz bei Friedemann Hahn. Von 2005 bis 2009 führte er sein Studium an der Städelschule in Frankfurt am ...
null
null
null
null
Construct a React component to display a login form.
function LoginForm(){ return ( <form> <label> Username: <input type="text" name="username" /> </label> <label> Password: <input type="password" name="password" /> </label> <input type="submit" value="Submit" /> </form> ); }
null
Construct a lambda function to find all odd numbers in a given list.
List of numbers: [2, 3, 7, 8, 10]
list_of_nums = [2, 3, 7, 8, 10] odd_nums = list(filter(lambda num: num % 2 != 0, list_of_nums))
[HI Wikipedia] मिशेल फूको मिशेल फूको की राज्य की अवधारणा राज्य की संस्था लोगों से कैसे अपनी बात मनवाती है— इस समझ में सबसे ताजा और विचारोत्तेजक विकास मिशेल फ़ूको ने किया है। पूँजीपति वर्ग राज्य में अपनी सामाजिक सत्ता केवल हिंसा के उपकरणों (सेना, पुलिस आदि) के द्वारा ही स्थापित नहीं करता। वह तरह-तरह के सांस्कृतिक रूपों...
null
null
null
[EN Wikipedia] Dennis Burgess Dennis Burgess (February 18, 1926 – November 3, 1980) was a British television actor born in Neath, Glamorgan, Wales. He married Glenys Maria Hare at Neath, in 1958. Burgess came from Port Talbot, attended Port Talbot Secondary School and worked as a drama teacher for most of his adult li...
null
null
null
[DE Wikipedia] Pistazien Die Pistazien (Pistacia) sind eine Pflanzengattung mit etwa zehn bis zwölf Arten aus der Familie der Sumachgewächse (Anacardiaceae). Sie kommen auf der Nordhalbkugel sowohl in Asien als auch in Europa und Amerika vor. Einige Arten werden zur Gewinnung von Pistazien genutzt. Merkmale Die Pistaz...
null
null
null
[EN Wikipedia] Sarane Ferret Étienne "Sarane" Ferret (1912–1970) (surname also later spelled Ferré on occasion) was a French musette and gypsy jazz guitarist and composer, a contemporary and musical associate of Django Reinhardt, and the brother of noted Gitan (gypsy) guitar players Baro and Matelo Ferret. He recorded...
null
null
null
null
Construct a switch statement to log different grades messages based on the grade variable.
var grade = "A+";
switch(grade){ case "A+": console.log("Excellent job!"); break; case "A": console.log("Well done!"); break; case "B": console.log("Good job!"); break; case "C": console.log("Keep up the good work!"); break; default: console.log("Keep up the hard work!"); break; }
[DE Wikipedia] Pakt Simon-Gagern Als Pakt Simon-Gagern bezeichnet man eine Absprache in der Frankfurter Nationalversammlung Anfang 1849. Sie führte dazu, dass bedeutende demokratische Elemente in die Reichsverfassung vom 28. März gelangten. Ohne die Absprache wäre die Verfassung monarchistischer und rechtsliberaler au...
null
null
null
null
Create a Python program that prints a welcome message to the user based on their input.
"Welcome to my program!"
name = input("Enter your name:") print("Welcome to my program " + name + "!")
null
Create an algorithm using Python to find the largest number in a list.
[8, 5, 10, 3]
def find_largest_number(numbers): # Finds the largest number from the given list largest = 0 for num in numbers: if num > largest: largest = num return largest numbers = [8, 5, 10, 3] largest = find_largest_number(numbers) print(largest)
null
Generate a function in Python that returns the cumulative sum of a list of numbers.
[1, 2, 3, 4]
def cumulative_sum(nums): sums = [] current_sum = 0 for n in nums: current_sum += n sums.append(current_sum) return sums print(cumulative_sum([1, 2, 3, 4])) # [1, 3, 6, 10]
[EN Wikipedia] Maria Clara Eimmart Maria Clara Eimmart (27 May 1676 – 29 October 1707), was a German astronomer, engraver and designer. She was the daughter and assistant of Georg Christoph Eimmart the Younger. Biography Maria Clara Eimmart was a German astronomer born in Nuremberg. She was the daughter of painter, en...
null
null
null
[EN Wikipedia] Ratna Ram Chaudhary Ratna Ram Chaudhary ( – 28 November 2019) was an Indian politician from Rajasthan belonging to Indian National Congress. He was a member of the Rajasthan Legislative Assembly. Chaudhary was elected Sarpanch for the first time in the year 1959 in the Panchayat Raj formed after indepen...
null
null
null
null
Create a solution that detects the presence of a character in a string.
Python
def detect_character(string, char): for ch in string: if ch == char: return True return False string = 'Python' char = 'y' print(detect_character(string, char))
null
Generate a valid VHDL code for given design
Implement a 4-to-1 multiplexer using the given data ports
LIBRARY ieee; USE ieee.std_logic_1164.all; entity Multiplexer is Port ( a,b,c,d: in std_logic; sel: in std_logic; y : out std_logic); end Multiplexer; architecture Behavioral of Multiplexer is begin process(a,b,c,d,sel) begin if sel = '0' then y <= a; elsif sel = '1' then y <= b; elsif sel = '2' then y <= c; elsif sel ...
[CS Wikipedia] Hordubalové Hordubalové je český film z roku 1937, který natočil režisér Martin Frič podle novely Hordubal Karla Čapka. Film vypráví o návratu slovenského emigranta z Ameriky (Jaroslav Vojta) na svůj statek ke své ženě a dcerce. Žena kromě peněz však už o něj nemá zájem, intimně žije s čeledínem, což sk...
null
null
null
[HI Wikipedia] जलालपुर जट्टां जलालपुर जट्टां (अंग्रेज़ी:Jalalpur Jattan उर्दू:) पाकिस्तानी पंजाब के ज़िला गुजरात का एक शहर है। इतिहास जब सिकंदर महान ने महाराजा पुरूवास को हराया तो उस ने दो शहर आबाद किये। एक शहर झेलम नदी और दूसरा शहर चेनाब नदी के पास बसाये। चेनाब के पास आबाद किया गया दूसरा शहर आज का जलालपुर जट्टां है। ...
null
null
null
null
Write a function in Python to count the number of vowels in a string.
def count_vowels(string): count = 0 vowels = set("aeiouAEIOU") for letter in string: if letter in vowels: count += 1 return count
null
Compose a code to find the mean and median of a given list
[1, 6, 4, 9, 5, 8, 2]
def get_mean_median(nums): num_count = len(nums) num_sum = 0.0 for num in nums: num_sum += num mean = num_sum / num_count nums.sort() if num_count % 2 == 0: median1 = nums[num_count//2] median2 = nums[num_count//2 - 1] median = (median1 + median2)/2 else: median = nums[num_count//2] return mean, median
[EN Wikipedia] List of place names of Dutch origin in the United States This is a list of place names in the United States that either are Dutch, were translated from Dutch, or were heavily inspired by a Dutch name or term. Many originate from the Dutch colony of New Netherland. California Delft Colony, California Col...
null
null
null
[EN Wikipedia] Akçayurt, Hani Akçayurt () is a neighbourhood in the municipality and district of Hani, Diyarbakır Province in Turkey. The village is populated by Kurds and had a population of 65 in 2022. Disappearance of the village muhtar A Kurdish muhtar (elected village head) after being released stated in a press ...
null
null
null
null
Write a Python program to sort the given list of lists by their third elements.
my_list = [[1, 2, 5], [3, 4, 1], [7, 8, 9]]
def sort_by_third_elements(list_of_lists): return sorted(list_of_lists, key=lambda x: x[2]) my_list = [[1, 2, 5], [3, 4, 1], [7, 8, 9]] print(sort_by_third_elements(my_list)) # Output: [[3, 4, 1], [1, 2, 5], [7, 8, 9]]
null
Change the response to now fulfill the following purpose
Find the number of ones in a binary number 101011
def find_ones(n): count = 0 while n > 0: if n % 10 == 1: count += 1 n //= 10 return count
null
Write a regex expression to match strings that start with "abc" and end with "xyz".
^abc.*xyz$
null
Create an array of prime numbers between 0 and 100 and print them out.
Array = [] for num in range(2,101): if all(num % i != 0 for i in range(2,num)): Array.append(num) print(Array)
[DE Wikipedia] Noah Gregor Noah Gregor (* 28. Juli 1998 in Beaumont, Alberta) ist ein kanadischer Eishockeyspieler, der seit Oktober 2023 bei den Toronto Maple Leafs aus der National Hockey League (NHL) unter Vertrag steht und dort auf der Position des Centers spielt. Zuvor war Gregor vier Spielzeiten bei den San Jose...
null
null
null
null
Write a Python program to find the longest palindromic subsequence of a given string.
roadrace
def longest_palindromic_subsequence(string): n = len(string) dp = [[0 for _ in range(n)] for _ in range(n)] for i in range(n): dp[i][i] = 1 for i in range(n-1): if string[i] == string[i+1]: dp[i][i+1] = 2 for l in range(3, n+1): for i in range(n-l+1): ...
null
Create a function in Python that takes a list of strings, converts it to camelCase, and returns a new list with the converted strings.
list = ["this", "is", "an", "example"]
def convertToCamelCase(list): camelCaseList = [] for string in list: string = string.capitalize() camelCaseList.append(string) return ''.join(camelCaseList)
null
Develop a C++ code to print the numbers 1 to 10 in descending order.
for(int i=10; i>0; i--) cout << i << " ";
[EN Wikipedia] Abacus The abacus (: abaci or abacuses), also called a counting frame, is a hand-operated calculating tool of unknown origin used since ancient times in the ancient Near East, Europe, China, and Russia, millennia before the adoption of the Hindu-Arabic numeral system. The abacus consists of a two-dimens...
null
null
null
null
Suggest a solution to print the third character from a string in Python.
String = "Hello, world!"
print(string[2]) # Output: l
null
Create a program in Python to measure the performance of a code snippet. The program should measure the execution time for a piece of code and display the results in milliseconds.
def add(x,y): return x+y
import time def measure_performance(fn, data): start = time.perf_counter() result = fn(*data) elapsed = 1000 * (time.perf_counter() - start) return result, elapsed def add(x, y): return x + y data = (3, 5) result, elapsed = measure_performance(add, data) print('Result:', result) print('Elapsed time (ms):', elap...