text stringlengths 141 2.89k ⌀ | instruction stringlengths 19 1.5k ⌀ | input stringlengths 0 800 ⌀ | output stringlengths 1 2.5k ⌀ |
|---|---|---|---|
null | Edit the following code to check for even numbers in the array. | arr = [1, 2, 3, 4, 5] | arr = [1, 2, 3, 4, 5] for i in arr: if i % 2 == 0 : print(i) |
null | What is the best way to test for memory leaks in a C++ program? | The best way to test for memory leaks in a C++ program is to use a memory profiler. Memory profilers can help identify memory leaks by monitoring how much memory is allocated, how often it is allocated, and whether or not the same or similar memory is being allocated multiple times. They can also track how memory is be... | |
null | Parse a JSON string and print all the key-value pairs in alphabetical order. | { "orange": 4, "apple": 1, "banana": 2 } | import json def parse_json(json_str): data = json.loads(json_str) for key, values in sorted(data.items()): print(key, "=", values) parse_json('{"orange": 4, "apple": 1, "banana": 2 }') |
null | Suggest a completion for the following python code to count the number of a given character in a string. | def count_characters(s, c): | def count_characters(s, c):
count = 0
for ch in s:
if ch == c:
count += 1
return count |
null | Translate the following description into a Python code to find the maximum and minimum of a given list of numbers. | [1, 5 ,10, 3, 9, 4] | def find_max_min(list_of_numbers):
max_number = list_of_numbers[0]
min_number = list_of_numbers[0]
for number in list_of_numbers:
if number > max_number:
max_number = number
if number < min_number:
min_number = number
return max_number, min_number
list_of_numbers... |
null | What should be the appropriate PHP code for displaying the details of a MySQL database? | <?php // Establish database connection $host = 'localhost'; $user = 'root'; $pass = ''; $dbname = 'mydb'; $connection = mysqli_connect($host, $user, $pass, $dbname); // Retrieve data from database $sql = "SELECT * FROM customers"; $result = mysqli_query($connection, $sql); // Display data while($row = mysqli_fetch_asso... | |
null | Write a CSS code that changes the font-family of all the text elements of an HTML document to 'Segoe UI'. | * { font-family: 'Segoe UI'; } | |
null | Create a Ruby method to print a triangle of stars with a given height. | def print_triangle_of_stars(height) (1..height).each do |row| (1..row).each do print "*" end print "\n" end end | |
null | Implement a function that takes a character and returns true if the character is an uppercase letter. | function isUpperCase(ch) { if (ch.charCodeAt(0) >= 65 && ch.charCodeAt(0) <= 90) { return true; } return false; } | |
[EN Wikipedia] Vytautas Janulionis
Vytautas Janulionis (28 February 1958 – 1 May 2010) was a Lithuanian glass artist. He was born in Klaipėda. In 1969–1976, he studied at M. K. Čiurlionis secondary art school. He graduated from the Art Institute in Tallinn, in 1981. Since 1981, he taught at Vilnius Academy of Art, Kau... | null | null | null |
null | Suggest a way to optimize a given code segment. | x = 0 for i in range(100): for j in range(100): x = x + 1 | To optimize this code segment, you can use the NumPy library to take advantage of vectorized operations and reduce the number of iterations. Additionally, you can use MultiProcessing to run the code in parallel, taking advantage of multiple cores on the machine: import numpy as np x = np.zeros((100, 100)) for i in rang... |
null | Generate a Python program to convert a list of strings to a list of integers. | ['1', '3', '2', '6'] | def str_to_int(lst):
int_lst = []
for i in lst:
int_lst.append(int(i))
return int_lst |
[DE Wikipedia] Rowan Coultas
Rowan Arkas Coultas (* 21. Juni 1997 in Bedford) ist ein ehemaliger britischer Snowboarder. Er startete in den Freestyledisziplinen. Werdegang Coultas nahm von 2009 bis 2019 an Wettbewerben der World Snowboard Tour und der FIS teil. Dabei holte er bei den Juniorenweltmeisterschaften 2014 i... | null | null | null |
null | Create a function in Python to find the most common elements in a list. | [2, 4, 1, 4, 5, 6, 4, 8] | def most_common_element(lst):
max_count = 0
most_common = None
for num in lst:
count = lst.count(num)
if count > max_count:
most_common = num
max_count = count
return most_common
most_common_element([2, 4, 1, 4, 5, 6, 4, 8]) |
null | Given a list of integers, write a Python function to find the largest consecutive sum of elements in the list. | nums = [1, 2, -5, 9, 0, 10] | def largest_consecutive_sum(nums):
max_sum = 0
total_sum = 0
for num in nums:
total_sum += num
if total_sum > max_sum:
max_sum = total_sum
return max_sum |
null | Construct a loop that prints out the first 10 elements in a given list. | my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] | for i in range(10): print(my_list[i]) |
null | Design a Python class for creating a student record system. | class StudentRecord:
def __init__(self, student_id, name, age, course):
self.student_id = student_id
self.name = name
self.age = age
self.course = course
def get_student_records(self):
return {
'student_id': self.student_id,
'name': self.name,
... | |
null | Rewrite the following code as a MySQL query. | SELECT team, count(*) FROM athletes GROUP BY team | SELECT team, COUNT(*) FROM athletes GROUP BY team; |
null | Create a Python program to generate a 2D array of a defined size and fill it with random numbers. | Size of the array: 10x10 | import random
# define the size of the array
x, y = 10, 10
# create an empty array of the given size
arr = [[0 for j in range(x)] for i in range(y)]
# fill the array with random numbers
for i in range(x):
for j in range(y):
arr[i][j] = random.randint(0, 9)
# print the array
for i in range(x):
print(arr[i]) |
null | Calculate the sum of all the multiples of 3 and 5 between 0 and n | n = 10 | def sum_multiples(n): result = 0 for i in range(1, n): if i % 3 == 0 or i % 5 == 0: result += i return result if __name__ == '__main__': print(sum_multiples(n)) |
null | Rewrite the following PHP code to add a new item to the array. | $my_array = array('apple', 'orange'); | $my_array = array('apple', 'orange', 'banana'); |
[DE Wikipedia] Matai (Maucatar)
Matai ist ein osttimoresischer Ort, Aldeia und Suco im Verwaltungsamt Maucatar (Gemeinde Cova Lima). Der gleichnamige Berg, der Foho Matai liegt fünf Kilometer vom Ort Matai entfernt im Suco Ogues (). Der Ort Matai befindet sich etwa 87 km südlich von der Landeshauptstadt Dili auf einer... | null | null | null |
null | Develop a Python program to perform this operation. | Find the sum of the digits of an integer.
Input: 323 | def sum_digits(n):
sum = 0
while n > 0:
sum += n % 10
n = n // 10
return sum
result = sum_digits(323)
print(result) |
null | Generate a REST API using Python, Flask, and Marshmallow. | Not applicable | from flask import Flask, request
from flask_sqlalchemy import SQLAlchemy
from flask_marshmallow import Marshmallow
app = Flask(name)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db = SQLAlchemy(app)
ma = Marshmallow(app)
class Books(db.Model):
id = db.Column(db.Integer, primary_key=True)
title =... |
null | Implement a linked list structure with an insert method using Java. | class Node { int data; Node next; Node (int data) { this.data = data; this.next = null; } } class LinkedList { Node head; public void insert(int data) { Node newNode = new Node(data); if (head == null) { head = newNode; } else { Node current = head; while (current.next != null) { current = current.next; } current.next ... | |
[EN Wikipedia] Indiana Magazine of History
The Indiana Magazine of History is a peer-reviewed academic journal published quarterly by the Indiana University Bloomington Department of History. Established primarily as a venue for historical documents of interest, particularly on Indiana's territorial period and early s... | null | null | null |
[CS Wikipedia] Matematika
Matematika (z řeckého (mathématikos) = milující poznání; (mathéma) = věda, vědění, poznání) je věda zabývající se z formálního hlediska kvantitou, strukturou, prostorem a změnou. Matematika je též popisována jako disciplína, jež se zabývá vytvářením abstraktních entit a vyhledáváním zákonitýc... | null | null | null |
null | Construct a Python program to take a list of numbers as input and print out the largest number in the list. | [5, 10, 2, 9, 6] | def largestNumber(list):
max = list[0]
for num in list:
if num > max:
max = num
return max
list = [5, 10, 2, 9, 6]
print(largestNumber(list)) # Output: 10 |
[CS Wikipedia] Otevřená ekonomika
Otevřená ekonomika je taková ekonomika, která se volně stýká s ostatními světovými ekonomikami. S tím je spojena řada výhod: obchodování umožňuje lidem zaměřovat se na výrobu toho, co dokáží nejlépe (v čem mají komparativní výhodu) obchodováním mohou lidé dosáhnout větší rozmanitosti ... | null | null | null |
null | Define a class "Car" with two data attributes "top speed" and "model year". | class Car: def __init__(self, top_speed, model_year): self.top_speed = top_speed self.model_year = model_year | |
null | Construct an SQL query to get the name of the oldest user from the "Users" table. | // Table Name Users | SELECT name FROM Users ORDER BY date_of_birth DESC LIMIT 1; |
null | Create an array in Python that contains five different values. | arr = [1, 2, 3, 4, 5] | |
null | Create a basic web scraper in Python to collect data from an e-commerce website. | www.example.com | import requests
import bs4
def get_data(url):
response = requests.get(url)
soup = bs4.BeautifulSoup(response.text, 'html.parser')
products = soup.find_all('div', {'class': 'product'})
for product in products:
name = product.find('h3', {'class': 'name'}).text
price = product.find('spa... |
null | Perform linear regression on a set of data points using only basic Python syntax and libraries. | X=[1,3,4,5]
Y=[0,3,2,5] | # import the necessary libraries
import numpy as np
from sklearn.linear_model import LinearRegression
# create the arrays
x = np.array(X).reshape(-1,1)
y = np.array(Y).reshape(-1,1)
# create and fit the model
model = LinearRegression()
model.fit(x, y)
# print the model coefficients
print('Intercept: ', model.interce... |
null | Write a function that takes an input string and finds the number of non-printable characters. | def count_non_printable_characters(string): non_printable = ''.join(chr(i) for i in range(0, 32)) counter = 0 for char in string: if char in non_printable: counter+= 1 return counter | |
null | Generate a python program to apply bubble sort to an array | def bubble_sort(arr):
n = len(arr)
for i in range(n):
for j in range(0, n-i-1):
if arr[j] > arr[j+1] :
arr[j], arr[j+1] = arr[j+1], arr[j] | |
[HI Wikipedia] ज्ञानपीठ पुरस्कार
ज्ञानपीठ पुरस्कार भारतीय ज्ञानपीठ न्यास द्वारा भारतीय साहित्य के लिए दिया जाने वाला सर्वोच्च पुरस्कार है। भारत का कोई भी नागरिक जो आठवीं अनुसूची में बताई गई २२ भाषाओं में से किसी भाषा में लिखता हो इस पुरस्कार के योग्य है। पुरस्कार में ग्यारह लाख रुपये की धनराशि, प्रशस्तिपत्र और वाग्देव... | null | null | null |
null | Write a PHP code for sending an email to the current logged in user. | user email: 'xyz@example.com' | $to = 'xyz@example.com'; $subject = 'Subject of email'; $message = 'Message body of email'; $headers = 'From: sender@example.com' . "\r\n" . 'Reply-To: sender@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); |
null | Sort the list using Quick Sort | [2, 3, 5, 6, 1, 4] | def quick_sort(arr): if len(arr) <= 1: return arr pivot = arr[len(arr) // 2] left = [x for x in arr if x < pivot] right = [x for x in arr if x > pivot] return quick_sort(left) + [pivot] + quick_sort(right) |
null | Create a Python function to encode a given sentence into base64. | import base64
def encodeInBase64(msg):
msg_bytes = msg.encode('ascii')
base64_bytes = base64.b64encode(msg_bytes)
base64_message = base64_bytes.decode('ascii')
return base64_message | |
[EN Wikipedia] Pakoka River
The Pakoka River is a river of the Waikato Region of New Zealand's North Island. It flows southwest from its source southeast of Raglan to reach the northeastern end of the Aotea Harbour. The catchment is made up of just over of waterways. Geology The most notable features of the Pakoka val... | null | null | null |
null | Develop an algorithm to find the greatest common factor (GCF) of two numbers in Python. | def gcf(a,b): if a == 0 : return b return gcf(b % a, a) | |
null | Compose a query in SQL to delete all records from a table named "students". | DELETE FROM students; | |
null | Using the data provided, create a SQL command to get the total number of orders from customers in the USA. | Table name: "Orders" Columns: "Cust_ID", "Cust_Country", "Order_ID" | SELECT COUNT(Order_ID) AS Total_Orders FROM Orders WHERE Cust_Country="USA" |
null | Merge the elements of two given arrays into one. | [1, 2, 3] and [4, 5, 6] | [1, 2, 3, 4, 5, 6] |
null | Develop a JavaScript object for storing the name and occupation of an employee. | name = 'John Doe', occupation = 'Programmer' | const employee = { name: 'John Doe', occupation: 'Programmer' } |
null | Create a script in Python that takes a list of strings and prints the string with the longest length. | ['hello', 'world', 'abracadabra'] | def longest_string(str_list):
longest = str_list[0]
for s in str_list:
if len(s) > len(longest):
longest = s
print(longest)
longest_string(['hello', 'world', 'abracadabra']) |
null | Write a small program in Python to print the total sum of first n even numbers. | n = int(input("Enter a number: "))
total = 0
for i in range(2, (2*n)+1, 2):
total += i
print("The sum of first", n, "even numbers is", total) | |
null | Implement an algorithm in Python to find the longest palindromic substring from a given string. | def longest_palindromic_substring(s):
longest = ''
for i in range(len(s)):
for j in range(i, len(s)):
substr = s[i:j+1]
if is_palindrome(substr) and len(substr) > len(longest):
longest = substr
return longest
def is_palindrome(s):
return s == s[::-1]
# F... | |
[HI Wikipedia] हावड़ा
हावड़ा (अंग्रेज़ी: Howrah, बांग्ला: হাওড়া) , भारत के पश्चिम बंगाल राज्य का एक औद्योगिक शहर, पश्चिम बंगाल का दूसरा सबसे बड़ा शहर एवं हावड़ा जिला एवं हावड़ सदर का मुख्यालय है। हुगली नदी के दाहिने तट पर स्थित, यह शहर कलकत्ता, के जुड़वा के रूप में जाना जाता है, जो किसी ज़माने में भारत की अंग्रेज़ी स... | null | null | null |
null | Edit the code such that it prints the same output. | str1 = "python " str2 = "programming" print(str1 + str2) | str1 = "python" str2 = " programming" print(str1 + str2) |
[CS Wikipedia] Vladimír Blucha
Vladimír Blucha (* 6. července 1931 Mokré Lazce u Opavy – 20. listopadu 2020) byl český regionální historik, geograf, kronikář, vlastivědný pracovník a pedagog, který napsal řadu článků a několik knih o historii Krnova. Život Německé úřady ve vládním obvodě Opava v Sudetech ho v roce 193... | null | null | null |
null | Create a function in Python that will take a list as an argument and return the average of the first 3 elements in the list. | [1, 2, 3, 4, 5] | def getAverageOfFirstThree(data):
sum = 0
for i in range(3):
sum += data[i]
return sum / 3 |
null | Write a SQL query to find the average age of people living in the UK. | SELECT AVG(TIMESTAMPDIFF(YEAR, date_of_birth, CURRENT_DATE)) as average_age FROM people WHERE country = 'UK'; | |
null | Design a neural network model to detect the sentiment of a given sentence. | The designed neural network model can be implemented with an embedding layer followed by a convolutional layer and then a global max-pooling layer. The output of the pooling layer can be passed through a fully connected layer with a sigmoid activation function to achieve the final output of the model. We can feed the m... | |
null | Create a Java program to delete an element for a given position in an array. | [1, 3, 5, 6, 8], position=2 | public static int[] deleteElement(int[] arr, int pos) { int n = arr.length; int i; // Removing the element at a given position for (i = pos; i < n - 1; i++) arr[i] = arr[i+1]; // Returning the resulting array return arr; } public static void main(String[] args) { int[] arr = {1, 3, 5, 6, 8}; int pos = 2; int[] new_arr ... |
[DE Wikipedia] Everett McGill
Everett Charles McGill III (* 21. Oktober 1945 in Miami Beach, Florida) ist ein US-amerikanischer Schauspieler. Leben Everett McGill wurde als Schauspieler an der Royal Academy of Dramatic Arts in London ausgebildet. Danach spielte er zunächst in mehreren preisgekrönten Stücken am Broadwa... | null | null | null |
null | Create a machine learning model in Python to classify spam emails. The model should be able to classify an email as either spam or not spam. | Not applicable | import pandas as pd
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB
# Read in the csv dataset
df = pd.read_csv(‘spam_data.csv')
# Create the CountVectorizer
cv = CountVectorizer()
# Fit the CountVectorizer to the text
words_cv = cv.fit_transform(df['text'])
... |
null | Write a python program to detect the occurrence of a given string in another large string. | String 1: "This is a test."
String 2: "test" | def str_find(str1, str2):
return str1.find(str2) != -1
str_find("This is a test.", "test") |
null | Design a function that takes a sentence and returns an array with each word in the sentence as an element. | def sentence_to_array(sentence): return sentence.split(' ') | |
[HI Wikipedia] हुर्रियत काँफ़्रेंस
ऑल पार्टी हुर्रियत कॉन्फ्रेंसजम्मू और कश्मीर के विभिन्नराजनीतिक, सामाजिक और धार्मिक संगठनों का गठबंधन ह कॉन्फ्रेंस ने एलान किया है कि वह जम्मू और कश्मीर राज्य में होने वाले विधानसभा चुनावों में हिस्सा नहीं लेगी। हालांकि कई प्रमुख मुद्दों पर इस गठबंधन के सदस्यों के भीतर आम राय नहीं है... | null | null | null |
null | Construct a web page with three columns and a header. | <html> <head> <title>Three Column Page</title> </head> <body> <h1> Three Column Page </h1> <div> <div style="float:left;width:33%;"> Content for Column 1 </div> <div style="float:left;width:33%;"> Content for Column 2 </div> <div style="float:left;width:33%;"> Content for Column 3 </div> </div> </body> </html> | |
null | Design a class to convert a given string to Morse code and store it as a list. | class MorseCodeConverter: def __init__(self, string): self.string = string self.alphabet = { 'a': '.-', 'b': '-...', 'c': '-.-.', 'd': '-..', 'e': '.', 'f': '..-.', 'g': '--.', 'h': '....', 'i': '..', 'j': '.---', 'k': '-.-', 'l': '.-..', 'm': '--', 'n': '-.', 'o': '---', 'p': '.--.', 'q': '--.-', 'r': '.-.', 's': '...... | |
null | Create a RESTful API endpoint in Python that returns all the users in a database. | Not applicable | import flask
from flask import Flask, request
from flask_sqlalchemy import SQLAlchemy
app = flask.Flask(name)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db = SQLAlchemy(app)
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(120))
@app.route('/users'... |
[CS Wikipedia] Obyvatelstvo Švédska
Počet obyvatel Švédska činil v k 31. srpnu 2015 odhadem 9 816 666 lidí. K 30. červnu 2009 to pro srovnání bylo 9 292 359 obyvatel.. K 31. prosinci 2013 dosahoval počet obyvatel čísla 9,64 milionu. Švédsko je jednou z nejřidčeji zalidněných zemí Evropy - hodnota dosahuje počtu 21,5 l... | null | null | null |
null | What kind of data structure is most suitable for storing a dictionary? | In most cases, a hash table is the most suitable data structure for storing a dictionary. It is a data structure that maps key/value pairs, allowing for fast access to the data. | |
null | Given two lists, create a function that finds the common elements between the two lists. | list1 = [1, 2, 3, 4, 5] list2 = [2, 3, 4, 6, 7] | def find_common(list1, list2): common_elems = [] for elem in list1: if elem in list2: common_elems.append(elem) return common_elems |
null | Design an algorithm in Python for linear search. | [3, 1, 5, 8], 8 | def linear_search(arr, target):
for i in range(len(arr)):
if arr[i] == target:
return i
return -1 |
null | Convert the following basic Python code into its equivalent JavaScript code. | for i in range(1, 5):
print(i) | for(let i = 1; i < 5; i++){
console.log(i);
} |
null | Write an SQL query to find customers who live in a given city and have purchased a given product. | SELECT customers.name FROM customers INNER JOIN orders ON customers.ID = orders.customer_id INNER JOIN products ON orders.product_id = products.ID WHERE customers.city = 'City Name' AND products.name = 'Product Name'; | |
null | Translate the following code written in Python to Java. | x = "Hello World" | String x = "Hello World"; |
null | Design a CSS class that will set the font family of an HTML element to ‘Arial’, font size to 12 pts and font weight to bold. | .arial-12-pt { font-family: Arial; font-size: 12pt; font-weight: bold; } | |
null | Write a Python function to print prime numbers between two given numbers. | low = 5, high = 10 | def print_prime_numbers_between_two_numbers(low, high):
for numb in range(low,high + 1):
if numb > 1:
for i in range(2,numb):
if (numb % i) == 0:
break
else:
print(numb)
#calling the function
print_prime_numbers_between_two_... |
null | Create a Python program that takes a list as input and sorts it using bubble-sort algorithm. | [3,2,5,6,1,4] | def bubble_sort(lst):
for i in range(len(lst)):
for j in range(0, len(lst)-i-1):
if lst[j] > lst[j+1] :
lst[j], lst[j+1] = lst[j+1], lst[j]
list = [3,2,5,6,1,4]
bubble_sort(list)
print('Sorted list is: ', list) |
null | In Python, write code to identify whether a given string contains only numeric values. | # To identify whether a given string contains only numeric values in Python: # 1. Use the isdigit method of the str object # 2. Pass the given string as an argument to the isdigit method # 3. The method will return True if the given string contains only numeric values, # and False otherwise # Example given_string = "12... | |
null | Create a basic Python script that computes the sum of two variables and stores the result in a third variable. | x = 5
y = 8 | # compute the sum of x and y
result = x + y
# store the result in a third variable
z = result
#print the result
print(z) # Output: 13 |
[EN Wikipedia] Rea River
The Rea River is a river in Fiordland, New Zealand. It rises west of Teardrop Lake and flows into Misty River before it enters Kaikiekie / Bradshaw Sound. See also List of rivers of New Zealand References Rivers of Fiordland | null | null | null |
null | Create a class to represent a door in a Python program. | class Door:
#Initializing a door with default values
def __init__(self, is_open=False, color="brown", material="wood"):
self.is_open = is_open
self.color = color
self.material = material
#Function to open door
def open_door(self):
self.is_open = True
#Function to c... | |
null | Offer a solution to the following programming problem | Given a list of strings, return the longest string | def longest_string(string_list): longest_string = "" for s in string_list: if len(s) > len(longest_string): longest_string = s return longest_string |
null | Implement a solution in Python to convert the given number to its binary representation. | 155 | def convertToBinary(x):
return bin(x).replace("0b", "")
x = 155
print(convertToBinary(x)) |
null | Purge all rows from the following dataframe that have a negative value in the Age column. | import pandas as pd data = {'Name': ['Jerry', 'Peter', 'Paul', 'John'], 'Age': [20, 22, -18, 24]} df = pd.DataFrame(data) | import pandas as pd data = {'Name': ['Jerry', 'Peter', 'Paul', 'John'], 'Age': [20, 22, -18, 24]} df = pd.DataFrame(data) df = df[df['Age'] >= 0] |
[DE Wikipedia] AIDAbella
Die AIDAbella ist ein Kreuzfahrtschiff von Carnival Corporation & plc. Sie wird für Fahrten unter der speziell auf den deutschen Markt ausgerichteten Konzernmarke AIDA Cruises eingesetzt. Betrieben wird sie unter italienischer Flagge durch Costa Crociere in Genua. Die AIDAbella war zum Zeitpun... | null | null | null |
null | Write a Ruby method to check if a given list contains an integer. | list = [1, 2.5, "Hello"] | def list_contains_integer?(list) list.each do |item| return true if item.is_a? Integer end false end list_contains_integer?(list) |
null | Given a list of colors ["red", "green", "blue"], create a Python program to find the longest color name. | ["red", "green", "blue"] | def longest_color_name(colors):
longest_name = 0
longest_color = None
for color in colors:
if len(color) > longest_name:
longest_name = len(color)
longest_color = color
return longest_color |
null | Find the output of the following array after sorting it in ascending order. | array = [6, 2, 9, 4, 1] | [1, 2, 4, 6, 9] |
null | Use the following code to print each letter of the string "Hello World" on a separate line. | string = "Hello World" | string = "Hello World" for letter in string: print(letter) |
[HI Wikipedia] कार्टून नेटवर्क
कार्टून नेटवर्क (Cartoon Network) वार्नर ब्रदर्स डिस्कवरी के स्वामित्व वाला एक अमेरिकी केबल टेलीविजन चैनल है। इसकी स्थापना 1 अक्टूबर 1992 को बेट्टी कोहेन द्वारा की गई थी। यह सभी देखें कार्टून नेटवर्क (भारत) सन्दर्भ जन संचार माध्यम टीवी चैनल अमेरिकी कम्पनियाँ | null | null | null |
null | Generate a random number between 0 and 1 in Python. | import random
randomNumber = random.random()
print(randomNumber) | |
[DE Wikipedia] Els Beerten
Els Beerten (* 27. März 1959 in Hasselt) ist eine flämische Kinder- und Jugendbuchautorin. Leben und Werk Els Beerten wuchs in Koersel auf. Sie studierte 1977–1981 Niederlandistik und Anglistik an der KUL in Löwen. Danach besuchte sie eine Schauspielschule in Maastricht. Seit 1985 unterricht... | null | null | null |
null | Design a Python script to automatically fetch and store new tweets from a given Twitter handle. | import tweepy
# Authentication
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
# Initializing the API
api = tweepy.API(auth)
#Fetching tweets from the given Twitter handle
tweets = api.user_timeline(screen_name='<Twitter handle>', count=200, include... | |
null | Create a Machine Learning model in Python that takes data points from a spreadsheet and classifies them as either a positive or a negative result. | The spreadsheet contains the following columns: City, Temperature, Hours of Sunlight, Amount of Rain.
The data points are for the cities of New York, Tokyo, and London. | # Import necessary libraries
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.svm import SVC
# Read data
data = pd.read_csv("data.csv")
# Split data into features and labels
X = data.loc[:, data.columns != 'Result']
y = data['Result... |
null | Write a function to move all zeros in an array to the end. | [1, 2, 0, 3, 4, 0, 5] | def moveZeroes(nums): zeros = 0 for i in range(len(nums)): if nums[i] == 0: zeros += 1 else: nums[i-zeros] = nums[i] nums[len(nums)-zeros:] = [0] * zeros |
[DE Wikipedia] Francisco Carreño (Komponist)
Francisco Carreño (* 9. März 1910 in Porlamar; † 25. Juli 1965 in Caracas) war ein venezolanischer Musiker, Komponist, Musikpädagoge und Folklorist. Leben Francisco Carreño war der älteste von fünf Geschwistern. Zwei Brüder seiner Mutter, die beide Musiker waren, gaben ihm ... | null | null | null |
null | Write a Python program to find the longest increasing subsequence of a given array of integers | arr = [10, 22, 9, 33, 21, 50, 41, 60, 80] | def longest_increasing_subsequence(arr):
n = len(arr)
# An array to store increasing subsequences
dp = [1]*n
# Compute optimal values in bottom up manner
for i in range (1 , n):
for j in range(0 , i):
if arr[i] > arr[j] and dp[i]< dp[j] + 1 :
dp[i] = dp[j]+1
... |
null | Edit this C++ code to remove all comments. | // This is a comment // This is another comment int main() { /* This is a multiline comment */ std::cout << "Hello World"; return 0; } | int main() { std::cout << "Hello World"; return 0; } |
null | Generate a python program to substitute $username with an input's username. | The user named "$username" will receive a special price. | def substitute_username(input):
output = input.replace("$username", input.username)
return output |
[HI Wikipedia] राफ्टिंग
कैंपिंग एवं ट्रेकिंग की तरह राफ्टिंग भी एक रोमांचकारी गतिविधि है। ऊँची-नीची लहरो से एक छोटी सी नाव में जूझना भी एक अलग तरह का अनुभव है। मनोरंजन के साथ-साथ यह हमें साहसी, एवं जूझारु भी बनाती है। इसके अलावा एक साथ काम करने के कारण आपस में सहयोग की भावना भी बढ़ती है। बड़ी-ड़ी लहरे जब वेग के साथ व्... | null | null | null |
null | Write a Python program to calculate the probability of two dice rolling the same number. | def two_dice_same(n_dice):
total_prob = 0
for i in range(1, n_dice + 1):
probability = (1/6)**i * (5/6)**(n_dice - i)
total_prob += probability
return total_prob
result = two_dice_same(2)
print(result) | |
[HI Wikipedia] विक्षनरी
विक्षनरी एक वेब आधारित बहुभाषी शब्दकोश है, जिसमें कोई भी शब्द जोड़ सकता है या लिख सकता है। यह विकिमीडिया संस्थान द्वारा संचालित किया जाता है। यह भी विकिपीडिया की तरह मीडियाविकि सॉफ्टवेयर का उपयोग करता है, इस कारण आप भी इसमें कोई भी सम्पादन कर सकते हैं और अनुपलब्ध शब्दों को जोड़ कर इसे बड़ा कर स... | null | null | null |
[CS Wikipedia] Everything but the Girl
Everything but the Girl (nebo také EBTG) je britské elektronické duo, které vytvořil v roce 1982 Ben Watt s Tracey Thornovou. Debutovali písní "Night and Day", kterou napsal Cole Porter a později ji předělali i autoři jako Frank Sinatra & Tommy Dorsey, a jiní. Píseň je z roku 198... | null | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.