text stringlengths 141 2.89k ⌀ | instruction stringlengths 19 1.5k ⌀ | input stringlengths 0 800 ⌀ | output stringlengths 1 2.5k ⌀ |
|---|---|---|---|
null | Find the position of a string within another string. | haystack = "This is a sample string with the word 'sample' in it" needle = "sample" | const position = haystack.indexOf(needle) console.log(position) // 15 |
null | Modify the given code to accept input in Celsius and convert it to Fahrenheit. | def c2f(): return ((9/5)*temp + 32) | def c2f(temp): return ((9/5)*temp + 32) |
null | Write a python code snippet to square the number 12. | x = 12 y = x**2 print(y) | |
[HI Wikipedia] मानस
मानस अथवा मनास () का सन्दर्भ निम्न से हो सकता हैं: सांस्कृतिक मानवशास्त्र मनास की दास्तान (एपिक ऑफ़ मनास), ५००,००० वाक्यों वाली एक किरगिज़ महाकाव्य मन के लिए पाली और संस्कृत शब्द; देखें" मानस (प्रारम्भिक बौद्ध धर्म) मानस-विज्ञान, योगाचार बौद्ध धर्म में सिखाई गई आठ चेतनाओं में से एक रामचरित मानस लोग... | null | null | null |
null | Write a Python program to find the sum of all the divisors of a given integer. | 90 | def calculate_sum_divisors(n):
total_sum = 0
for i in range(1, n + 1):
if n % i == 0:
total_sum += i
return total_sum
print(calculate_sum_divisors(90)) |
null | Generate a Python class to represent a car. The class should include attributes for make, model, year, and color. | Not applicable | class Car:
def __init__(self, make, model, year, color):
self.make = make
self.model = model
self.year = year
self.color = color
def get_info(self):
return f'This car is a {self.color} {self.year} {self.make} {self.model}.' |
null | Create a Python class to represent a bank account, with appropriate methods and fields for holding the balance | No input. | class BankAccount:
def __init__(self):
self._balance = 0
def get_balance(self):
return self._balance
def deposit(self, amount):
if amount < 0:
raise ValueError("Amount must be greater than 0")
self._balance += amount
def withdraw(self, amount):
if ... |
null | Write a JavaScript program to remove all the occurrences of a specified character from a string. | The quick brown fox | function removeChar(str, char){ return str.replace(new RegExp(char, 'g'), ''); } |
null | Write a Python program to create a dictionary with numbers from 0 to 4 as keys and corresponding values as given below. | [1, 2, 3, 4] | d = {0:1, 1:2, 2:3, 3:4, 4:4} |
null | Construct a Python program to split a string at a given character occurrence index. | Input String: Hello World
Index: 6 | def split_string(string, index):
return string[:index] + "," + string[index+1:]
s = "Hello World"
index = 6
new_string = split_string(s, index)
print(new_string)
Output:
Hello,World |
null | Create a program in Python that can extract data from an HTML page. | Not applicable | import requests
from bs4 import BeautifulSoup
# Get the specified URL
url = 'https://example.com/'
response = requests.get(url)
# Parse the response
soup = BeautifulSoup(response.text, 'html.parser')
# Extract the desired data
title = soup.find('title').text
body = soup.find('body').text
# Print the extracted data
... |
null | Create a SQL query to get the list of employees working in the IT department. | SELECT e.name FROM employees e JOIN departments d on e.department_id = d.id WHERE d.name = 'IT' | |
[CS Wikipedia] EUR
Zkratka EUR může znamenat: Euro – společná evropská měnová jednotka Esposizione Universale di Roma – městská čtvrť v Římě | null | null | null |
[HI Wikipedia] मलावी झील
मलावी झील (अंग्रेज़ी: Lake Malawi) या न्यासा झील (अंग्रेज़ी: Lake Nyasa) महान अफ़्रीकी झीलों में से एक है और पूर्वी अफ़्रीकी दरार की दक्षिणतम झील है। यह मलावी, मोज़ाम्बीक और तान्ज़ानिया के बीच स्थित है। यह अफ़्रीका की तीसरी सबसे बड़ी और दूसरी सबसे गहरी झील है। यह पूरे विश्व की नौवीं सबसे बड़ी ... | null | null | null |
null | Create an artificial neural network in PyTorch to predict the next word in a sentence. | import torch import torch.nn as nn class ANN(nn.Module): def __init__(self, vocab_size, embedding_dim, hidden_dim): super().__init__() self.embedding = nn.Embedding(vocab_size, embedding_dim) self.fc1 = nn.Linear(embedding_dim, hidden_dim) self.fc2 = nn.Linear(hidden_dim, vocab_size) def forward(self, x): embedded = se... | |
null | Given a numeric array and a length, find the longest increasing subsequence in the array. | Array: [3, 4, 1, 5, 10, 9, 8, 11] Length: 8 | [3, 4, 5, 10, 11] |
null | Write a Python program to generate a list of the first 10 Fibonacci numbers, starting from 0. | def generate_fibonacci_list(n):
fibonacci = [0, 1]
for _ in range(2, n):
fibonacci.append(fibonacci[-2] + fibonacci[-1])
return fibonacci
fibonacci_list = generate_fibonacci_list(10)
print(fibonacci_list) | |
[HI Wikipedia] भूटान
भूटान का राजतंत्र (भोटान्त) हिमालय पर बसा दक्षिण एशिया का एक छोटा और महत्वपूर्ण देश है। यह चीन (तिब्बत) और भारत के बीच स्थित भूमि आबद्ध देश है। इस देश का स्थानीय नाम ड्रुग युल है, जिसका अर्थ होता है अझ़दहा का देश। यह देश मुख्यतः पहाड़ी है और केवल दक्षिणी भाग में थोड़ी सी समतल भूमि है। यह सांस्कृति... | null | null | null |
null | Create a regex expression in Python that finds all numbers from 1 to 100 inclusive. | import re regex = re.compile('[1-9]|[1-9][0-9]|100') | |
null | Find the most frequent integer in the list: [3, 5, 2, 3, 1, 5, 3, 3, 2]. | my_list = [3, 5, 2, 3, 1, 5, 3, 3, 2] max_freq = 0 max_num = 0 # Use a dictionary to store the frequence of each number dict = { i : my_list.count(i) for i in my_list } for num, freq in dict.items(): if freq > max_freq: max_freq = freq max_num = num print(max_num) # Output: 3 | |
null | Using Python, create a basic web application for a Contact List. The application should include a form for adding, editing, and deleting contacts. | Not applicable | import os
from flask import Flask, render_template, request
app = Flask(__name__)
contact_list = [
{'name': 'John Doe', 'email': 'john@example.com'},
{'name': 'Jane Doe', 'email': 'jane@example.com'},
]
@app.route('/')
def index():
return render_template('index.html', contacts=contact_list)
@app.route('/add', m... |
[CS Wikipedia] Národní park Noel Kempff Mercado
Národní park Noel Kempff Mercado je rozlehlé chráněné území na východě Bolívie v departementu Santa Cruz na hranicích s Brazílií. Byl založen roku 1979 a od roku 2000 je zapsán na seznamu světového přírodního dědictví UNESCO. Svůj název nese na počest významného bolivijs... | null | null | null |
null | Write a code to select records from a database where the country name is identical to the input. | Australia | """ Select records from the database where the country name is identical to the input """ import sqlite3 country = 'Australia' conn = sqlite3.connect('database.db') c = conn.cursor() query = "SELECT * FROM countries WHERE name = ?" c.execute(query, (country,)) data = c.fetchall() conn.close() |
null | Write a Python program to test if the inputs are equal and return a boolean value. | 28, 48 | def equals(a, b):
return a == b
equal = equals(28, 48)
print(equal) |
null | Construct a switch statement to return either "Nick" or "Jack" base on the value of the input | Input: "Nick" | switch (input) { case "Nick": return "Nick"; break; case "Jack": return "Jack"; break; default: return "Invalid Input"; } |
null | Write a lambda expression to select all records from a list of dictionaries with the name "John". | selected_records = list(filter(lambda x:x['name']=='John', records)) | |
null | Create a Python serverless function that takes in a JSON payload and performs the appropriate action based on the payload content. | Payload Example:
{
action: “send_email”,
recipient: “jane@example.com”,
subject: “Hello!”,
message: “This is a message from Jane.”
} | import json
import boto3
def send_email(event, context):
recipient = event['recipient']
subject = event['subject']
message = event['message']
#send email here
client = boto3.client('ses')
response = client.send_email(
Source='sender@example.com',
Destination={
'ToAddresses': [recipient,],
},
Message=... |
null | Rewrite the following Java program in Python. | public class QuadraticEquation {
private double a;
private double b;
private double c;
QuadraticEquation(double a, double b, double c) {
this.a = a;
this.b = b;
this.c = c;
}
public double getDiscriminant() {
return (this.b*this.b) - 4*this.a*this.c;
... | class QuadraticEquation:
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
def getDiscriminant(self):
return (self.b**2) - 4*self.a*self.c
def getRoot1(self):
if self.getDiscriminant() >= 0:
return ((-self.b + (self.getDiscriminant(... |
null | Create a Python function to replace all the vowels in a string with 'x'. | def replace_vowels(s):
vowels = ['a', 'e', 'i', 'o', 'u']
for char in s:
if char in vowels:
s = s.replace(char, 'x')
return s | |
[HI Wikipedia] मेरठ
मेरठ भारत के उत्तर प्रदेश राज्य के मेरठ ज़िले में स्थित एक नगर है। यह ज़िले का मुख्यालय और पश्चिमी उत्तर प्रदेश का एक बड़ा शहर है। मेरठ दिल्ली से 72 किमी (44 मील) उत्तर पूर्व में स्थित है। मेरठ राष्ट्रीय राजधानी क्षेत्र (ऍन.सी.आर) का हिस्सा है। यहाँ भारतीय सेना की एक छावनी भी है। यह उत्तर प्रदेश के... | null | null | null |
null | Create a website for the company ACME with all the following pages: Home, About Us, Contact Us, FAQ and Privacy Policy. | <html> <head> <title>ACME</title> </head> <body> <header> <h1>ACME</h1> </header> <nav> <ul> <li><a href="index.html">Home</a></li> <li><a href="about.html">About Us</a></li> <li><a href="contact.html">Contact Us</a></li> <li><a href="faq.html">FAQ</a></li> <li><a href="privacy-policy.html">Privacy Policy</a></li> </ul... | |
null | Implement an R program to calculate the median of an integer array. | [2, 3, 4, 5] | calculate median <- function(arr){ sorted <- sort(arr) n <- length(arr) if(n%%2 == 0){ mid <- n/2 median <- (sorted[mid] + sorted[mid + 1] ) / 2 } else { mid <- (n + 1) / 2 median <- sorted[mid] } return(median) } calculate_median(c(2, 3, 4, 5)) |
null | Compute the modulo of following two numbers | 56 % 7 | 0 |
null | Use HTML and CSS to format a page with three columns, two of which contain two paragraphs each and the last containing a list of 10 items. | <!DOCTYPE html> <html> <head> <title>3 Column Layout</title> <style> body { width: 1000px; margin: 0 auto; } .column-left { float: left; width: 33%; } .column-center { float: left; width: 33%; } .column-right { float: left; width: 33%; } </style> </head> <body> <div class="column-left"> <p>Paragraph 1</p> <p>Paragraph ... | |
null | Write a SQL query to get the employee ID, first name and last name of the all employees with the last name starting with 'G' | SELECT employee_id, first_name, last_name FROM employees WHERE last_name LIKE 'G%'; | |
null | Construct a class in Java that creates methods for finding the area and circumference of a circle. | public class Circle { double radius; public Circle(double radius) { this.radius = radius; } public double getArea(){ return Math.PI * Math.pow(radius, 2); } public double getCircumference(){ return 2 * Math.PI * radius; } } | |
null | Develop a Python script that prints the unique words in a string, along with their respective counts. | "The quick brown fox jumped over the lazy dog." | from collections import Counter
string = "The quick brown fox jumped over the lazy dog."
words = string.split()
word_counts = Counter(words)
unique_words = set(words)
for word in unique_words:
print(f"{word:15} {word_counts[word]:3}") |
null | Create a Python script to interact with a PostgreSQL database. The script should be able to add new entries to the database. | Not applicable | import psycopg2
try:
connection = psycopg2.connect(
user = "postgres",
password = "your_password",
host = "localhost",
port = "5432",
database = "your_database"
)
cursor = connection.cursor()
postgreSQL_select_Query = "select * from table_name"
cursor.execute(postgreSQL_select_Query)
print("Table Bef... |
null | Write a python program to repeatedly ask the user for a string and print the number of vowels in the string. | Example string: hello | while True:
s = input("Enter a string: ")
count = 0
for i in s:
if(i=='a' or i=='e' or i=='i' or i=='o' or i=='u'):
count+=1
print("The number of vowels in the string:", count) |
null | Write a PHP code for finding the longest word in an array of strings. | $arr = ["Hello", "World", "My", "Name", "Is"]; | <?php $arr = ["Hello", "World", "My", "Name", "Is"]; //Finding the longest word in the array $longestWord = ""; foreach($arr as $word) { if (strlen($word) > strlen($longestWord)) { $longestWord = $word; } } echo "The longest word is: " . $longestWord; ?> |
[DE Wikipedia] Pacific Remote Islands Marine National Monument
Das Pacific Remote Islands Marine National Monument ist ein US-amerikanisches National Monument westlich und südlich von Hawaii. Es liegt in einem sogenannten „nicht-inkorporierten Territorium“ der Vereinigten Staaten, das zu statistischen Zwecken den Unit... | null | null | null |
[HI Wikipedia] जावास्क्रिप्ट
जावास्क्रिप्ट, संक्षेप में जेएस, एचटीएमएल और सीएसएस के साथ, वर्ल्ड वाइड वेब की एक मुख्य भाषा है। 2022 तक, 98% वेबसाइट क्लाइंट साइट में जावास्क्रिप्ट का इस्तेमाल करती है। ज़्यादातर ब्राउज़र में यूज़र के तरफ से कोड चालू करने के लिए कोई जावास्क्रिप्ट इंजन है। प्रमुख विशेषताएं जाल पृष्ठों के ग... | null | null | null |
[CS Wikipedia] Vražda Jána Kuciaka a Martiny Kušnírové
Vražda Jána Kuciaka a Martiny Kušnírové byla spáchána 21. února 2018 v západoslovenské obci Veľká Mača nedaleko Trnavy. Slovenský investigativní novinář Ján Kuciak byl zastřelen ve věku 27 let i se svou partnerkou Martinou Kušnírovou. Byl usmrcen dvěma střelami do... | null | null | null |
[DE Wikipedia] Mącze
Mącze () ist ein Dorf in der polnischen Woiwodschaft Ermland-Masuren, der zur Gmina Ełk (Landgemeinde Lyck) im Powiat Ełcki (Kreis Lyck) gehört. Geographische Lage Mącze liegt südlich der beiden kleinen Seen Jezioro Mącze Duże und Jezioro Mącze Małe im südlichen Osten der Woiwodschaft Ermland-Masu... | null | null | null |
[CS Wikipedia] Rolls-Royce Derwent
Rolls-Royce RB.37 Derwent je britský proudový motor ze 40. let s odstředivým kompresorem a druhý proudový motor firmy Rolls-Royce Limited, který vstoupil do výroby. V podstatě jde o vylepšenou verzi motoru Rolls-Royce Welland, který byl přejmenovanou verzí motoru W.2B firmy Franka Wh... | null | null | null |
null | Create a web page with a form for user input of a modified text. | <html> <body> <form action = "processText.php" method = "post"> <textarea rows = "10" cols = "30" name = "modifiedText"></textarea><br> <input type = "submit" value = "Submit" /> </form> </body> </html> | |
null | Given a valid XML string, write an XPath query to retrieve all the elements | <?xml version="1.0"?> <root> <child name="child1" /> <child name="child2"> <subchild>subchild</subchild> </child> <child name="child3" /> </root> | // XPath query to retrieve all elements from the given XML string /root/child |
null | Generate a sentence using GPT-3. | GPT-3 is an AI language model developed by OpenAI. | GPT-3 is an advanced AI language model that can generate sentences and paragraphs of text that are relevant and coherent to a given context. |
null | Can you design a Python program that evaluates the following formula? | "2*x + 4*y - z = 10" | def evaluate_formula(x, y, z):
return 2*x + 4*y - z == 10 |
[EN Wikipedia] Pararrhaptica perkinsiana
Pararrhaptica perkinsiana is a moth of the family Tortricidae. It was first described by Lord Walsingham in 1907. It is endemic to the Hawaiian islands of Molokai and Maui. It is the type species of the genus Pararrhaptica. External links Archipini Endemic moths of Hawaii Biota... | null | null | null |
null | Write a code to fetch the contents of a website using Python | # Import the necessary packages
import requests
# Make an API call and store the response
url = 'https://example.com/'
r = requests.get(url)
# Extract the content of the response
html_content = r.content
# Print the response
print(html_content) | |
null | Develop a Python3 program to extract the words of length 3 from a given sentence. | "The quick brown fox jumped over the lazy dog" | def extract_words(s): words = s.split() length_3_words = [] for word in words: if len(word) == 3: length_3_words.append(word) return length_3_words s = "The quick brown fox jumped over the lazy dog" print(extract_words(s)) |
null | Write a code to print out an array of the first ten positive even numbers. | def printEvenNumbers(): my_list = [] for item in range(2,21,2): my_list.append(item) print(my_list) printEvenNumbers() # prints [2, 4, 6, 8, 10, 12, 14, 16, 18, 20] | |
null | Submit a valid Ruby program to remove special characters from a given string | Hello$#@World! | def remove_special_chars(str) str = str.gsub(/[^a-zA-Z0-9\s]/, '') return str end puts remove_special_chars("Hello$#@World!") |
null | Create a function in Python which takes a string and reverses it. | def reverse_string(my_string): return my_string[::-1] | |
null | Write a Python program to sort a list of dictionaries by a key in each dictionary. | my_list = [{'name': 'Tom', 'age': 25}, {'name': 'John', 'age': 21}, {'name': 'Adam', 'age': 26}] | def sort_list_of_dicts_by_key(my_list, key):
return sorted(my_list, key=lambda k: k[key]) |
[DE Wikipedia] Razorworks
Razorworks war ein Entwicklerstudio von Videospielen mit Sitz in Oxfordshire, Großbritannien. Es wurde im August 1996 gegründet und gehörte seit 2000 dem Videospiel-Hersteller Empire Interactive. Das Razorworks-Studio wurde im Juli 2008 aufgrund der schlechten finanziellen Situation von Empir... | null | null | null |
null | Build a Python program to find the maximum element in a list of numbers. | [4, 9, 10, 11, 12] | def maxNum(numsList):
maxNum = numsList[0]
for num in numsList:
if num > maxNum:
maxNum = num
return maxNum
numList = [4, 9, 10, 11, 12]
print("The maximum number in the list is:", maxNum(numList)) |
[CS Wikipedia] Åke Johansson
Åke „Bajdoff“ Johansson (19. března 1928, Norrköping, Švédsko – 21. prosince 2014) byl švédský fotbalista, který hrával na pozici záložníka. V roce 1957 získal ve Švédsku ocenění Guldbollen pro nejlepšího fotbalistu roku. Klubová kariéra Celou svou kariéru strávil v klubu IFK Norrköping, s... | null | null | null |
null | Find all substrings of a string that are palindromes in Python. | def get_all_palindromes(input_string): palindromes = [] for substring_length in range(len(input_string)): for i in range(len(input_string) - substring_length + 1): sub_string = input_string[i: i + substring_length] if sub_string == sub_string[::-1]: palindromes.append(sub_string) return palindromes # Usage palindromes ... | |
null | Create a SQL statement that updates a table called 'students' with a new entry. | name = "John Doe" age = 21 | INSERT INTO students (name, age) VALUES ("John Doe", 21); |
null | Generate all possible permutations of the characters in a given string | def permutations(string): """ Function to generate all possible permutations of a given string """ if len(string) == 0: return [''] prev_list = permutations(string[1:len(string)]) next_list = [] for i in range(0,len(prev_list)): for j in range(0,len(string)): new_string = prev_list[i][0:j]+string[0]+prev_list[i][j:len(... | |
null | Write a python function to compare two strings and return 1 if the strings are anagrams, 0 if not. | "bob", "bob" | def is_anagram(string1, string2):
string1 = sorted(string1.replace(" ", "").lower())
string2 = sorted(string2.replace(" ", "").lower())
if string1 == string2:
return 1
else:
return 0 |
[EN Wikipedia] Aristotle
Aristotle (; Aristotélēs, ; 384–322 BC) was an Ancient Greek philosopher and polymath. His writings cover a broad range of subjects spanning the natural sciences, philosophy, linguistics, economics, politics, psychology and the arts. As the founder of the Peripatetic school of philosophy in th... | null | null | null |
[DE Wikipedia] Samuele Sangalli
Samuele Sangalli (* 10. September 1967 in Lecco) ist ein italienischer römisch-katholischer Geistlicher und Kurienbeamter. Leben Samuele Sangalli empfing am 8. Juni 1996 das Sakrament der Priesterweihe für das Erzbistum Mailand. Er erlangte an der Universität Rom III einen Abschluss in ... | null | null | null |
null | Using the provided input, write a Python program to calculate the sum of the digits of a given number. | number = 123 | def sum_of_digits(number):
result = 0
while number > 0:
result += number % 10
number = number // 10
return result
if __name__ == '__main__':
number = 123
print(sum_of_digits(number)) |
null | Create an automated bot in Python Selenium to fill out a web form with the provided data. | Name: Joseph Smith
Address: 123 Main Street
City, State Zip : New York, NY 12345
Country : United States | from selenium import webdriver
# open web browser
driver = webdriver.Chrome()
driver.get("https://example.com/form")
# fill out form
name_field = driver.find_element_by_id("name")
name_field.send_keys("Joseph Smith")
address_field = driver.find_element_by_id("address")
address_field.send_keys("123 Main Street")
cit... |
null | Generate a sequence of instructions to debug a Python Program. | 1. Check your syntax − Check if there is any syntax error in your program.
2. Check for runtime errors − Check if the program can be compiled without errors.
3. Check the logic − Check if your program follows the intended logic and produces desired output.
4. Add logging and debugging statements − Use print statement... | |
null | What would be the resulting string after executing this code? | a = "Hello" b = "World" c = a + " " + b c = f"{c}!" | c = "Hello World!" |
[DE Wikipedia] Rakovo
Rakovo (ungarisch Nagyrákó) ist eine Gemeinde im Norden der Slowakei mit Einwohnern (Stand ), die zum Okres Martin, einem Teil des Žilinský kraj, gehört und zur traditionellen Landschaft Turz gezählt wird. Geographie Die Gemeinde befindet sich im Mittelteil des Turzbeckens (slowakisch Turčianska ... | null | null | null |
null | Classify the following text as valid or invalid python code | sum = 0
sum = sum + 2 | Valid |
[EN Wikipedia] Azariah S. Partridge
Azariah S. Partridge (December 19, 1834April 28, 1901) was a Michigan politician. Early life Partridge was born on December 19, 1834 in Saratoga County, New York. Around 1856, Partridge moved to Flushing Township, Michigan. Partridge worked as a teacher for several years. Political ... | null | null | null |
null | Create an API endpoint for handling user authentication. | Endpoint URL: www.example.com/auth | @app.route("/auth", methods=['POST']) def auth(): data = request.get_json() username = data.get("username") password = data.get("password") user = User.check_user_auth(username, password) if user: session['username'] = username return jsonify(success=True) else: return jsonify(success=False) |
null | Create a SQL query to insert sample data into an 'employees' table. | INSERT INTO employees (id, first_name, last_name, age, email) VALUES (1, 'John', 'Doe', 25, 'john.doe@example.com'), (2, 'Jane', 'Doe', 30, 'jane.doe@example.com'), (3, 'Jim', 'Smith', 32, 'jim.smith@example.com'); | |
null | Write an algorithm in C++ for linear search. | // C++ implementation of the linear search #include <iostream> using namespace std; // A iterative linear search function to search 'x' in arr[] // of size 'n' int search(int arr[], int n, int x) { int i; for (i = 0; i < n; i++) if (arr[i] == x) return i; return -1; } int main() { int arr[] = { 2, 3, 4, 10, 40 }; int x... | |
null | Write a function that accepts an integer value n and creates an n by n matrix, with all elements initialised to zero. | def create_matrix(n): matrix = [] for i in range(n): row = [] for j in range(n): row.append(0) matrix.append(row) return matrix | |
null | Create a method to build a dictionary that contains all even numbers from the given list. | [2, 3, 7, 8, 10, 11] | def build_even_dict(numbers): even_dict = {key: value for key, value in enumerate(numbers) if value % 2 == 0} return even_dict |
[EN Wikipedia] Cymopterus globosus
Cymopterus globosus is a species of flowering plant in the carrot family known by the common name globe springparsley. This plant is native to the sandy flats extending between eastern California and Utah in the western United States. It is a low, stemless plant with leaves parallel ... | null | null | null |
null | Python code: generate a function to convert a decimal number to a binary number. | def decToBin(n):
binString = ""
while n > 0:
binary = n % 2
binString = str(binary) + binString
n = n//2
return binString
# Driver Code
n = int(input("Enter a number: "))
result = decToBin(n)
print("The binary representation is ", result) | |
null | Write a generative program in Python to generate a sentence of text. | Noun and verb list:
Nouns: car, cat, dog, woman
Verbs: drove, meowed, barked, laughed | import random
nouns = ["car", "cat", "dog", "woman"]
verbs = ["drove", "meowed", "barked", "laughed"]
def generate_sentence():
random_int1 = random.randint(0, 3)
random_int2 = random.randint(0, 3)
sentence = f"The {nouns[random_int1]} {verbs[random_int2]}."
return sentence
generate_sentence() #retu... |
null | Write a script in Python which takes a two-dimensional array as input and finds the smallest number in the array. | array = [[2,3,4], [5,6,7], [-1,2,0]] | def find_smallest(array):
smallest_item = array[0][0]
for row in array:
for item in row:
if item < smallest_item:
smallest_item = item
return smallest_item |
null | Write a JavaScript function to check if a number is a whole number or has decimals. | const isWholeNumber = (num) => { if (num % 1 === 0) return true return false } | |
null | Write a function that takes two strings as parameters and returns whether they are an anagram of each other or not. | string1 = "abcde" string2 = "edcba" | def is_anagram(string1, string2): if sorted(string1) == sorted(string2): return True else: return False if __name__ == '__main__': string1 = "abcde" string2 = "edcba" result = is_anagram(string1, string2) print(result) |
null | What type of search algorithm is used to find the shortest path between two points? | The type of search algorithm used to find the shortest path from two points is called Dijkstra's Algorithm. | |
[CS Wikipedia] Berounka
Berounka () je významná česká řeka v západní části republiky (Plzeňský, Středočeský kraj a Praha) a největší levostranný přítok Vltavy. Vzniká v Plzni soutokem Mže a Radbuzy, je dlouhá 139,1 km, s nejdelší zdrojnicí (Radbuza-Úhlava) 252 km. Povodí má rozlohu 8 855,47 km², z čehož se 35,96 km² (... | null | null | null |
null | Given a list of numbers, create a function in JavaScript to return the sum of all its elements. | [1,2,3,4] | const sumArray = arr => arr.reduce((acc,cur) => acc + cur, 0); |
[EN Wikipedia] Atom
An atom is a particle that consists of a nucleus of protons and neutrons surrounded by an electromagnetically-bound cloud of electrons. The atom is the basic particle of the chemical elements, and the chemical elements are distinguished from each other by the number of protons that are in their ato... | null | null | null |
[CS Wikipedia] FROG
FROG (z angl. Free Rocket Over Ground) je v kódovém označení NATO pro sovětské rakety. Od nápadu že by mohla nést jadernou hlavici se upustilo kvůli malé šanci zásahu. Rakety FROG používaly armády země Varšavské smlouvy, Sovětského svazu, v současnosti řada arabských zemí. FROG-1 Střela 3R2 (3Р2) k... | null | null | null |
null | Explain the function of a variable in programming. | In programming, a variable is a named storage location that can hold a value. Variables are used to store values that can be manipulated or referenced in a program. Variables can be used to hold numbers, text, or other types of data. They can also be used to store values or objects that are accessed or changed by a pro... | |
null | Create a Python program to calculate the electric bill for a customer based on kilowatt hour of electricity used. | x = 500 | def calculate_electric_bill(kw_usage):
rate = 0.15
bill = kw_usage * rate
return bill
x = 500
bill = calculate_electric_bill(x)
print("Your bill is:", str(bill)) |
[EN Wikipedia] Arabic
Arabic (, ; , or ) is a Semitic language spoken primarily across the Arab world. Having emerged in the 1st century AD, it is named after the Arab people; the term "Arab" was initially used to describe those living in the Arabian Peninsula, as perceived by geographers from ancient Greece. Since th... | null | null | null |
null | Write a code to get the IP address of a system. | import socket hostname = socket.gethostname() IPAddr = socket.gethostbyname(hostname) print("The IP address of the system is:" + IPAddr) | |
[EN Wikipedia] Dibujando el cielo
Dibujando el cielo () is a 2018 Mexican romantic comedy film directed by Ana Laura Calderón. The film premiered on 31 August 2018, and is stars Maite Perroni, Iván Sánchez, and Christian Vázquez. Plot Throughout her life, Sofía (Maite Perroni) has tried to stay away from commitments a... | null | null | null |
null | Write a MySQL query to find the highest salary of each department. | SELECT d.name, MAX(e.salary) FROM Department d INNER JOIN Employee e ON d.department_id = e.department_id GROUP BY d.name; | |
[EN Wikipedia] Leadership Conference of Women Religious
The Leadership Conference of Women Religious (LCWR) is one of two associations of the leaders of congregations of Catholic women religious in the United States (the other being the Council of Major Superiors of Women Religious). LCWR includes over 1300 members, w... | null | null | null |
null | Create a method that parses the provided HTML and returns a list of all the <p> tags. | <html> <p>This is a test.</p> <a href="">link</a> <p>Another test.</p> </html> | #Create a method to parse the HTML def getPTags(html): #Create an empty list pTags = [] #Iterate over the HTML for line in html.split("\n"): #Check if the line is a <p> tag if "<p>" in line: #Add the tag to the list pTags.append(line) #Return the list return pTags #Print the list print(getPTags(html)) |
null | Write an SQL query that finds the total revenue for each month. | Table name: orders | SELECT MONTH(order_date) AS month, SUM(total_price) total_revenue FROM orders GROUP BY MONTH(order_date) |
null | Create a virtual environment in Python to manage project dependencies. | """
Create a virtual environment in Python to manage project dependencies
"""
# Create the virtual environment
python3 -m venv env
# Activate the virtual environment
source env/bin/activate
# Install project requirements
pip install -r requirements.txt | |
null | Write a JavaScript code snippet to check if a given string contains the substring 'hello'. | if (str.indexOf('hello') !== -1) { console.log('The string contains the substring hello'); } | |
null | Design and code an entry-level language interpreter in Python. | class Interpreter:
def __init__(self):
self.opeartors = {
'+': self.add,
'-': self.sub,
'/': self.div,
'*': self.mul,
}
def parse(self, text):
expressions = text.split(' ')
return expressions
def evaluate(self, exp... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.