text stringlengths 141 2.89k ⌀ | instruction stringlengths 19 1.5k ⌀ | input stringlengths 0 800 ⌀ | output stringlengths 1 2.5k ⌀ |
|---|---|---|---|
null | Write a JavaScript function that returns the first 50 prime numbers. | function getFirstFiftyPrimes(){ let primes = [2]; let num = 3; while(primes.length < 50){ let isPrime = true; for(let i = 0; i < primes.length; i++){ if(num % primes[i] === 0){ isPrime = false; } } if(isPrime) primes.push(num); num += 1; } return primes; } | |
null | Generate code to implement quick sort in Python. | Not applicable | def quicksort(arr):
if len(arr) <= 1:
return arr
pivot = arr[len(arr) // 2]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return quicksort(left) + middle + quicksort(right) |
null | Create a python script to pass command line arguments to a function. | # Pass command line arguments to a function
import sys
def command_line_args():
args = []
# Loop over the command line arguments
for arg in sys.argv[1:]:
args.append(arg)
return args
args = command_line_args()
print(args) | |
null | Write a Python program that takes an array containing n elements and generates the power set. | n = 3 | import itertools
def powerset(lst):
powerset = []
for n in range(len(lst) + 1):
for subset in itertools.combinations(lst, n):
powerset.append(subset)
return powerset
arr = [1, 2, 3]
print(powerset(arr)) |
null | Create a PDF document from a Word document using Python. | word file | import win32com.client
# word file to be converted
wordFile = r'filename.docx'
# Open the word file
word = win32com.client.Dispatch("Word.Application")
doc = word.Documents.Open(wordFile)
# Set the pdf parameters
pdf_format_id = 17
file_name = r'filename.pdf'
# Save the file as pdf
doc.SaveAs(file_name, FileFormat... |
null | Develop a function in Python to accept a positive integer as input and print its reverse. | def reverse_integer(number):
reversed_number = 0
while number > 0:
remainder = number % 10
reversed_number *= 10
reversed_number += remainder
number //= 10
return reversed_number
number = 12345
print("Reversed Number:", reverse_integer(number)) | |
[HI Wikipedia] कैयट
कैयट पतंजलि के व्याकरण भाष्य की 'प्रदीप' नामक टीका के रचयिता। देवीशतक के व्याख्याकार कैयट इनसे भिन्न है। उनके पिता का नाम जैयटोपाध्याय था (महामाष्यार्णवाऽवारपारीणंविवृतिप्लवम्। यथागमं विधास्येहं कैयटो जैयटात्मज)। अनुमान है कि वे कश्मीर निवासी थे। पीटर्सन ने कश्मीर की रिपोर्ट में कैयट (और उव्वट) को ... | null | null | null |
null | Write a python program to replace the character ‘e' with the character ‘E' for strings of length more than 5 | text = "Hello world!" | def replace_char(text): if len(text) > 5: return text.replace('e','E') else: return text |
null | Write a Lambda function to filter out the even numbers | [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | const evenNumbers = arr => arr.filter(num => num % 2 == 0); console.log(evenNumbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])); |
null | Create a function to calculate the binomial coefficient for two integers. | n = 5 r = 3 | def binomial_coefficient(n, r): fact = 1 if r > n - r: r = n - r for i in range(r): fact *= (n) - i fact /= (i+1) return int(fact) print(binomial_coefficient(n, r)) |
null | Develop a Python program to generate a random integer from a given range | import random
def random_int(low, high):
return random.randint(low, high) | |
null | Using regex, replace all occurrences of 'cat' with 'dog' in the following text. | text = "I saw a cat in the park." | import re text = "I saw a cat in the park." result = re.sub(r'cat', 'dog', text) print(result) # Output I saw a dog in the park. |
null | Modify the given Python code to improve its performance. | def find_sum(n):
total = 0
for i in range(n+1):
total += i
return total | def find_sum(n):
# base case
if n == 0:
return 0
# recursive case
else:
return n + find_sum(n-1) |
null | Write a Python program to process a dataset of words and count how many times each unique word appears. | words = ['apple', 'apple', 'banana', 'apple', 'orange', 'banana', 'pear', 'orange', 'orange'] | from collections import Counter
words = ['apple', 'apple', 'banana', 'apple', 'orange', 'banana', 'pear', 'orange', 'orange']
word_counts = Counter(words)
for word, count in word_counts.items():
print(f'{word}: {count}') |
null | Create a Java program to generate and print Fibonacci series of a given size. | Size: 8 | public class FibonacciSeries { public static void main(String[] args) { int n = 8; int f1 = 0, f2 = 1; System.out.print("The Fibonacci series of size "+n+" is : "); for (int i = 1; i <= n; i++) { System.out.print(f1 + " "); int next = f1 + f2; f1 = f2; f2 = next; } } } |
[DE Wikipedia] Kader der 3. Fußball-Liga 2023/24
Dieser Artikel ist eine Übersicht der Kader der 3. Fußball-Liga 2023/24. Es sind alle Spieler gelistet, die im Zeitraum des ersten Ligaspiels des jeweiligen Vereins bis zum Saisonfinale dem jeweiligen Profikader durchgehend oder zeitweise angehörten. Außerdem werden die... | null | null | null |
null | Why is algorithmic complexity important? | Algorithmic complexity is an important measure of how efficient a program is since it tells how much time and memory a program consumes in relation to its input size. A more efficient program can be built to solve a problem faster, use fewer resources, and be more scalable. | |
null | Write a Python function to find the number of pairs of integers in an array that sum up to a given number | def count_pairs(numbers, target_sum):
count = 0
for i in range(len(numbers)):
for j in range(i + 1, len(numbers)):
if numbers[i] + numbers[j] == target_sum:
count += 1
return count | |
null | Using an existing loop, create code to calculate the sum of all odd numbers up to a given number. | def sum_odd_numbers(num): result = 0 for i in range(1, num+1): if i % 2 != 0: result += i return result | |
[CS Wikipedia] Kostel svatého Jiří (Lubojaty)
Kostel svatého Jiří se nachází v Moravskoslezském kraji ve vsi Lubojaty, která je jednou z nejstarších historicky doložených vsí na Bílovecku. Původní kostel byl založen Budislavem z Lubojat pravděpodobně na konci 13. století. Presbytář farního kostela svatého Jiří je jedn... | null | null | null |
[CS Wikipedia] BNP Paribas Open 2018 – mužská čtyřhra
Mužská čtyřhra BNP Paribas Open 2018 probíhala v první polovině března 2018. Do deblové soutěže indianwellského tenisového turnaje nastoupilo šestnáct dvojic. Obhájcem titulu byl jihoafricko-americký pár Raven Klaasen a Rajeev Ram, jehož členové nestartovali společ... | null | null | null |
null | Reformat the following HTML code to make it better readable. | <div><ul><li>Item 1</li><li>Item 2</li></ul></div> | <div> <ul> <li>Item 1</li> <li>Item 2</li> </ul> </div> |
[DE Wikipedia] Moa Kikuchi
Moa Kikuchi (japanisch , Kikuchi Moa, auch als Moametal bekannt; geboren am 4. Juli 1999 in Nagoya) ist eine japanische Sängerin. Sie ist seit 2010 Sängerin und Musikerin der Kawaii-Metal-Band Babymetal. Parallel dazu gehörte sie von 2010 bis 2015 der Idol-Popgruppe Sakura Gakuin an. Außerde... | null | null | null |
null | Write code to parse a given IP address into its octets. | IP address: 10.23.6.17 | def parse_ip_address(ip): octets = ip.split(".") return octets |
null | Write a Python function to input a list of integers and a number and output the number of times that number appears in the list. | [1, 2, 3, 4, 5, 2, 6], 2 | def count_occurrences(numbers, n):
count = 0
for num in numbers:
if num == n:
count += 1
return count |
null | Develop a code to identify the most commonly used words in a given text. | The quick brown fox jumps over the lazy dog | from collections import Counter def most_common_words(text): words = text.split() counter = Counter(words) high_occur = counter.most_common(3) return high_occur if __name__ == "__main__": text = "The quick brown fox jumps over the lazy dog" most_common_words(text) |
null | Create a Python program to generate all combinations of 3 elements from an array. | array = [1, 2, 3, 4] | def comb3(arr):
result = []
for i in range(len(arr)):
for j in range(i+1, len(arr)):
for k in range(j+1, len(arr)):
t = [arr[i],arr[j],arr[k]]
result.append(t)
return result |
null | Write a Java program that displays the area of a triangle, given the three sides. | 3, 4, 5 | public class TriangleArea { public static void main(String[] args) { int a = 3; int b = 4; int c = 5; // calculate the semi-perimeter double s = (a + b + c) / 2; // calculate the area double area = Math.sqrt(s * (s - a) * (s - b) * (s - c)); // display the result System.out.println("The area of the triangle: " + area);... |
null | Create a Python program that takes a list of numbers as input and outputs the sum of all numbers in the list. | list_of_numbers = [1,2,3,4,5] | # Sum of a list of numbers
# Defining the function
def sum_list(input_list):
# initializing sum to 0
total = 0
# Iterating over the list
for num in input_list:
total += num
# Returning the total value
return total
# Driver code
list_of_numbers = [1,2,3,4,5]
result = ... |
[HI Wikipedia] यूरोपीय दक्षिणी वेधशाला
यूरोपीय दक्षिणी वेधशाला (European Southern Observatory (ESO)), खगोल विज्ञान के लिए एक पंद्रह देशों का एक अंतर सरकारी अनुसंधान संगठन है। सदस्य देश गैलेरी यह तस्वीरें ESO सूची की शीर्ष-100 से है। इतिहास सारे विडियो अंग्रेजी भाषा में है। खगोलशास्त्र वेधशाला यूरोपीय संघ चिली में खगोल... | null | null | null |
null | Create a function to count how many vowels are in a given string. | def count_vowels(string): vowels = "aeiou" count = 0 for char in string: if char in vowels: count += 1 return count | |
null | Optimize the following code snippet to reduce processing time as much as possible. | arr = [13, 18, 25, 1, 7, 23, 12]
time_start = time.time()
for i in range(0, len(arr)):
for j in range(i + 1, len(arr)):
if arr[i] > arr[j]:
temp = arr[i]
arr[i] = arr[j]
arr[j] = temp
time_end = time.time()
print(f'Time taken: {time_end - time_start} seconds') | #Python code
arr = [13, 18, 25, 1, 7, 23, 12]
time_start = time.time()
# Optimized code
arr.sort()
time_end = time.time()
print(f'Time taken: {time_end - time_start} seconds') |
null | Modify the following code to prevent SQL injection attacks. | query = "SELECT * FROM users WHERE username = '" + username + "'" | import MySQLdb query = "SELECT * FROM users WHERE username = %s" db = MySQLdb.connect(host="localhost", user="user", passwd="pass", db="mydb") cur = db.cursor() cur.execute(query, (username,)) |
null | How to create a loop in Python which will iterate over a list? | #Iterate over a list list = [1, 2, 3, 4, 5] for item in list: print(item) | |
null | Using HTML and CSS, create an input form with fields for name and address | <form> <label>Name:</label><br> <input type="text" name="name"><br> <label>Address:</label><br> <textarea name="address" rows="4" cols="50"></textarea><br> <input type="submit" value="Submit"> </form> | |
[CS Wikipedia] Klasická mechanika
Klasická mechanika je mechanika, zabývající se mechanickými jevy makroskopických těles, která se pohybují rychlostí zanedbatelnou vzhledem k rychlosti světla. S takovými jevy se člověk běžně kolem sebe setkává, proto byla většina mechanických jevů zkoumána již ve starověku (Archimédés... | null | null | null |
null | Generate a random 3-digit number without using any in-built methods | // Generate a random 3-digit number let num = Math.floor(Math.random() * (999 - 100 + 1) + 100); | |
null | Write a Python snippet to print the difference between the largest and smallest values in a given array. | [1,2,3,4,5] | def diff_max_min(numbers):
return max(numbers) - min(numbers)
if __name__ == '__main__':
nums = [1,2,3,4,5]
diff = diff_max_min(nums)
print(diff) |
null | Create a python program that determines the grade of a student based on the marks they received in their exams. | marks = {
'math': 90,
'history': 80,
'english': 75
} | def determine_grade(marks):
# Determine the average mark
avg = (marks['math'] + marks['history'] + marks['english'])/3
# If the average mark is greater than or equal to 90, the student's grade is A
if avg >= 90:
return 'A'
# If the average mark is greater than or equal to 80, the stude... |
[HI Wikipedia] धानी (धानीप्राणी)
धानी या पाउच (pouch) मादा धानीप्राणियों (मारसूपियलों) के शरीर पर खाल मोड़कर बनी हुई एक विशेष थैली होती है। धानिप्राणी गर्भ धारण करने के बाद अन्य स्तनधारियों की तुलना में बहुत कम समय के लिए गर्भावस्था में रहते हैं। उनका शिशु जल्द ही पैदा हो जाता है और बहुत ही अविकसित अवस्था में होता है।... | null | null | null |
[EN Wikipedia] Sugarloaf Point Light
Sugarloaf Point Light, also known as Seal Rocks Lighthouse, is an active lighthouse located on Sugarloaf Point, a point about southeast of Seal Rocks, Mid-Coast Council, New South Wales, Australia. It guards Seal Rocks, a treacherous rock formation to the south. It is the first lig... | null | null | null |
null | Compare and contrast the differences between sets and lists in Python. | A set is an unordered collection of items while a list is an ordered collection of items. Sets have no duplicate elements so all the elements in a set must be unique. The elements inside a list may or may not be unique. Sets are faster when compared to lists for retrieving elements since lookups of items don't require ... | |
null | Create an algorithmic trading program using Python that executes buy/sell orders when certain criteria are met. | Not applicable | import pandas as pd
import numpy as np
# Set up the trading parameters
buy_threshold = 0.1
sell_threshold = 0.1
# Load the dataset
df = pd.read_csv('stock_data.csv', index_col=0)
# Set up a "buy" flag and a "sell" flag
df['buy'] = np.where(df.Close > (df.Open * (1 + buy_threshold)), 1, 0)
df['sell'] = np.where(df.Cl... |
null | Suggest a MySQL query that retrieves all students from the "Idaho" state. | SELECT * FROM students WHERE state = 'Idaho'; | |
null | Select the appropriate language to implement a linked list data structure. | C++ is the best language to implement a linked list data structure as it provides features like dynamic memory allocation, pointers and templates which make it easier to create a linked list. | |
null | Write a python program to convert a time string "hh:mm:ss" into total number of seconds | time = "08:11:15" | time_in_secs = 8 * 3600 + 11 * 60 + 15 |
null | Write a Python script to generate a random 3 X 3 matrix of integers in the range [1, 9]. | Not applicable | import random
# Generate a random 3 X 3 matrix of integers in the range [1, 9].
matrix = [[random.randint(1, 9) for _ in range(3)] for _ in range(3)]
for row in matrix:
print(row) |
null | Find all prime numbers up to a given number. | def list_primes(n): primes = [] for num in range(2, n+1): prime=True for i in range(2, int(num/2)+1): if num%i == 0: prime=False if prime: primes.append(num) return primes | |
null | Implement a linear regression model in Python to predict the target value given features. | # import necessary libraries
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
# load the dataset
df = pd.read_csv('data.csv')
# separate the data into features (X) and target (y)
X = df.drop('target', axis=1).values
y = df['target'].values
# s... | |
null | Generate code for a decision tree with entropy metric to classify the species of mushrooms. | No Input | import numpy as np
from sklearn.tree import DecisionTreeClassifier
# Load the dataset
X = np.array([[...],[...], ....])
y = np.array(['A', 'B', 'C', ...])
# Create a decision tree model
model = DecisionTreeClassifier(criterion="entropy")
# Fit the model using the data
model.fit(X, y)
# Generate the prediction code
... |
null | Describe an algorithm for sorting an array of n integers in O(n log n) time. | A sorting algorithm applicable to an array of n integers in O(n log n) time is Merge Sort. Its procedure first divides the input array into two halves until there are no more divisions are possible. This is the "divide and conquer" step of the algorithm. Then, each pair of divided arrays is sorted and merged into a sin... | |
null | Write a function to remove all whitespace characters from a given string. | myString = "Hello World " | def remove_whitespaces(myString): return ''.join(myString.split()) myString = "Hello World " print(remove_whitespaces(myString)) |
null | Which data structure is most suitable for storing a large list of numbers? | Heap or binary tree. A heap or binary tree data structure are most suitable for storing a large list of numbers as it provides O(log n) time complexity for insertion, search and deletion. | |
[EN Wikipedia] Agreia
Agreia is a genus in the phylum Actinomycetota (Bacteria). Etymology The generic name Agreia honours Nina S. Agre, a Russian microbiologist. Species The genus contains two species: A. bicolorata Evtushenko et al. 2001, type species of the genus; Latin bis, twice; coloratus, coloured; to give bico... | null | null | null |
[HI Wikipedia] विद्युत-चुम्बकीय-दुर्बल अन्योन्य क्रिया
कण भौतिकी में विद्युत-चुम्बकीय-दुर्बल अन्योन्य क्रिया प्रकृति की चार मूलभूत अन्योन्य क्रियाओं में से दो विद्युत-चुम्बकीय अन्योन्य क्रिया और दुर्बल अन्योन्य क्रिया का एकीकृत रूप है। यद्यपि ये दोनों बल निम्न ऊर्जा क्षेत्र में बहुत अलग दिखाई देते हैं, सैद्धान्तिक रूप... | null | null | null |
null | Create a program in Python to print the following output. | string = "programming" | str = "programming"
print(str[::-1])
Output: gnimmargorp |
null | Write a code snippet to add two numbers provided in two lists. | list1 = [2, 4, 3] list2 = [5, 6, 4] | new_list = [] for i in range(len(list1)): new_list.append(list1[i] + list2[i]) print(new_list) # Output: [7, 10, 7] |
null | Write a Python program to generate 10 random numbers and put them in a list. | import random
random_list = []
for i in range(10):
number = random.randint(1, 100)
random_list.append(number) | |
null | Create a class in C++ representing a 2D vector which has components (x, y). | class Vector2D { private: int x; int y; public: Vector2D(int x, int y); int GetX() { return x; } int GetY() { return y; } void SetX(int newX) { x = newX; } void SetY(int newY) { y = newY; } }; Vector2D::Vector2D(int x, int y) { this->x = x; this->y = y; } | |
[DE Wikipedia] Staustufe Apach
Die Staustufe Apach (franz.: Écluse d'Apach oder auch Écluse d'Apach-Schengen) mit der Schleuse Apach, dem Wehr Schengen-Apach und dem Kraftwerk Schengen–Apach an der Mosel wurde bis 1964 fertig gestellt und liegt auf französischem, luxemburgischem und deutschem Hoheitsgebiet nahe der fr... | null | null | null |
[EN Wikipedia] 1954–55 Norwegian 1. Divisjon season
The 1954–55 Norwegian 1. Divisjon season was the 16th season of ice hockey in Norway. Seven teams participated in the league, and Gamlebyen won the championship. Regular season External links Season on eliteprospects.com Nor Eliteserien (ice hockey) seasons 1954 in N... | null | null | null |
null | Suggest a function to find the second highest element in a list. | [10, 20, 30, 40] | def second_highest(List): List.sort() return List[-2] List = [10, 20, 30, 40] print(second_highest(List)) |
[EN Wikipedia] Ada Lovelace
Augusta Ada King, Countess of Lovelace (née Byron; 10 December 1815 – 27 November 1852) was an English mathematician and writer, chiefly known for her work on Charles Babbage's proposed mechanical general-purpose computer, the Analytical Engine. She was the first to recognise that the machi... | null | null | null |
null | Write a Python code to generate Fibonacci sequence up to 'n' numbers, where 'n' is a given integer. | def generateFib(n): fib = [0, 1] while len(fib) < n : fib.append(fib[-1] + fib[-2]) return fib[:n] | |
null | Answer what is the longest palindrome in a given string. | "Run, spot, run. He ran up red hills" | def longestPalindrome(st): palindromes = [] for i in range(len(st)): for j in range(i, len(st)): curr = st[i:j+1] rev = curr[::-1] if (curr == rev): palindromes.append(curr) res = max(palindromes, key = len) return res print(longestPalindrome("Run, spot, run. He ran up red hills")) # output run |
null | Write a Java code snippet to set the 3rd element in an array of integers to the value 5. | int[] arr = {1, 2, 3, 4, 5}; | arr[2] = 5; |
[DE Wikipedia] Dennis Polonich
Dennis Daniel Polonich (* 4. Dezember 1953 in Foam Lake, Saskatchewan) ist ein ehemaliger kanadischer Eishockeyspieler, -trainer und -funktionär, der im Verlauf seiner aktiven Karriere zwischen 1971 und 1987 unter anderem 397 Spiele für die Detroit Red Wings in der National Hockey League... | null | null | null |
null | Using the list of strings, create a new list without any vowels. | strings = ['apple', 'ball', 'cat'] | def remove_vowels(strings): vowels = ['a', 'e', 'i', 'o', 'u'] new_strings = [] for string in strings: new_strings.append(''.join([char for char in string if char.lower() not in vowels])) return new_strings |
[HI Wikipedia] मिस्र के मुहाफ़ज़ात
मिस्र के २७ बड़े प्रशासनिक क्षेत्रीय विभाग हैं जिन्हें मुहाफ़ज़ाह (बहुवचन - मुहाफ़ज़ात) कहते हैं, यानि किसी राज्यपाल (मुहाफ़िज़) की हिफ़ाज़त या निगरानी में रखा गया क्षेत्र। इनका दर्जा लगभग भारत के प्रान्तों जैसा है। मिस्र के मुहाफ़ज़ात या तो शहरी होते हैं या फिर शहरी-देहाती का मिश्रण... | null | null | null |
null | How can you test a user-defined function with the name "sum" in JavaScript? | function sumTest(){ let expectedResult = 15; let actualResult = sum(5, 10); if(expectedResult === actualResult){ console.log("sum test passed"); } else{ console.log("sum test failed"); } } sumTest(); | |
null | This code is a Python script that checks disk usage recursively. To use it, you need to run the script with the following arguments:
-b/--base: the base directory to monitor. For example, if you want to monitor only volumes mounted under /host/ (Default: /).
-e/--excludes: a list of mount points to exclude recursive... | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Florian Lambert <flambert@redhat.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2... | |
null | What is a MongoDB document? | A MongoDB document is a record in a NoSQL database that is represented in the form of a JSON-like structure. It contains a set of key-value pairs where each key is associated with a specific value. Documents can also be nested and can contain arrays and other documents. | |
null | Create an array and assign four elements to it. | my_array = ["John", "Paul", "George", "Ringo"] | |
[EN Wikipedia] Taipa River
The Taipa River is a river of the northern Northland Region of New Zealand's North Island. It flows west then north, reaching the south of Doubtless Bay at the township of Taipa. See also List of rivers of New Zealand References Far North District Rivers of the Northland Region Rivers of New... | null | null | null |
null | Write a Python program to generate a random permutation of a given sequence. | sequence = [1, 2, 3] | from random import shuffle
sequence = [1, 2, 3]
shuffle(sequence)
print(sequence) |
null | Convert the following pseudo code into a Python Program. | INPUT n
OUTPUT "Even" OR "Odd"
IF n is divisible by 2
OUTPUT "Even"
ELSE
OUTPUT "Odd" | n = int(input("Enter a number: "))
if n%2 == 0:
print("Even")
else:
print("Odd") |
null | Design a program in Python which generates a random mathematical equation with two numbers. | import random
def generateRandomEquation():
num1 = random.randint(0,9)
num2 = random.randint(0,9)
op = random.choice(['+','-','*','/'])
equation = str(num1) + op + str(num2)
return equation
print(generateRandomEquation()) | |
[HI Wikipedia] भद्रक, ओड़िशा
भद्रक (Bhadrak) भारत के ओड़िशा राज्य के भद्रक ज़िले में स्थित एक नगर है। यह उस ज़िले का मुख्यालय भी है। इन्हें भी देखें भद्रक ज़िला सन्दर्भ भद्रक ज़िला ओड़िशा के शहर भद्रक ज़िले के नगर | null | null | null |
null | Generate a python program that prints the cube of a given number. | 3 | def print_cube(num):
print(num**3)
num = 3
print_cube(num) |
null | Generate a batch of X random numbers in Python using a for loop. | X = 10 | import random
numbers = []
for i in range(10):
number = random.randint(1, 100)
numbers.append(number)
print(numbers) |
null | Create an algorithm that prints the common elements of two arrays. | arr1 = [3, 10, 15, 7] arr2 = [7, 8, 5, 10] | def common_elements(arr1, arr2): result = [] for numbers in arr1: if numbers in arr2: result.append(numbers) return result print(common_elements(arr1, arr2)) # Output: [7, 10] |
null | Compile a program to check whether an array is a subset of another array | example1 = [4, 5, 6] example2 = [5, 6, 7] | def is_subset(a, b): for i in a: if i not in b: return False return True |
[CS Wikipedia] Druhá vláda Lubomíra Štrougala
Druhá vláda Lubomíra Štrougala existovala v období 9. prosince 1971 – 11. listopadu 1976. Šlo o první československou vládu ve které byli zastoupeni pouze ministři za KSČ. Seznam členů vlády předseda vlády: Lubomír Štrougal místopředseda vlády: Josef Korčák Peter Colotka J... | null | null | null |
[DE Wikipedia] Gromada Bzie Zameckie
Gromada Bzie Zameckie war eine Verwaltungseinheit in der Volksrepublik Polen von 1954 bis 1972. Verwaltet wurde die Gromada vom Gromadzka Rada Narodowa, dessen Sitz sich in Bzie Zameckie (heute Teil von Jastrzębie-Zdrój) befand und der aus 16 Mitgliedern bestand. Die Gromada Bystrz... | null | null | null |
null | Write a Python program to automate adding products to an e-commerce website's database. | Products:
Name: iPhone 11 Pro
Price: 949
Name: AirPods Pro
Price: 249 | import sqlite3
# Establish the connection
conn = sqlite3.connect("ecommerce_database.db")
c = conn.cursor()
# Create the table
c.execute('''CREATE TABLE IF NOT EXISTS products (
name TEXT,
price INTEGER
)''')
# Insert data into table
products = [
("iPhone 11 Pro", 949),
("AirPods Pro", 249)
]
c.exec... |
[CS Wikipedia] Dugo Selo
Dugo Selo je město v Chorvatsku, administrativně spadající pod Záhřebskou župu. Nachází se asi 21 km východně od centra Záhřebu. V roce 2011 žilo ve městě 10 453 obyvatel, v celé připadající opčině pak 17 466 obyvatel. Historie První písemná zmínka o sídle je z počátku 13. století. V roce 1853... | null | null | null |
[EN Wikipedia] Bradley Eros
Bradley Eros (born in 1952 in Fairfield, Illinois) is an experimental film director, actor, curator, poet, and performance artist who also makes Musique concrète sound collages, music videos, photographs, live projection performances, works on paper and art objects. His work has been presen... | null | null | null |
null | Explain the difference between a shallow copy and a deep copy. | A shallow copy of an object creates a new object with the same values as the original but with a different location in memory. A deep copy of an object copies not just the values of the original object but also creates copies of any objects that the original object is referencing. The result is two objects which are co... | |
null | Print all the permutations of a given list | [1, 2, 3] | def permute(lis): if len(lis) == 0: return [] if len(lis) == 1: return [lis] l = [] for i in range(len(lis)): m = lis[i] remLis = lis[:i] + lis[i+1:] for p in permute(remLis): l.append([m] + p) return l list1 = [1, 2, 3] result = permute(list1) for i in result: print(i) |
[HI Wikipedia] दिल्ली मेट्रो
दिल्ली मेट्रो भारत की राजधानी दिल्ली- एनसीआर की मेट्रो परिवहन व्यवस्था है जो दिल्ली मेट्रो रेल निगम लिमिटेड द्वारा संचालित है। इसका शुभारंभ २४ दिसंबर, २००२ को शहादरा तीस हजारी लाईन से हुई। इस परिवहन व्यवस्था की अधिकतम गति ८०किमी/घंटा (५०मील/घंटा) रखी गयी है और यह हर स्टेशन पर लगभग २० सेकें... | null | null | null |
null | Using the comment as a guide, edit the code to handle the error appropriately. | try: # TODO: Make API call except Exception: # TODO: Handle error | try: # Make API call except Exception as e: # Handle error print("An error occurred:", e) |
null | Design a function in Python to determine if a given number is prime. | 37 | def is_prime(n):
if n <= 1:
return False
if n == 2:
return True
if n > 2 and n % 2 == 0:
return False
sqrt_n = int(n**0.5)
for i in range(3, sqrt_n+1, 2):
if n % i == 0:
return False
return True
if is_prime(37):
print('37 is a prime number!') |
[DE Wikipedia] Ernst Rose
Heinrich Ernst Rose (* 12. Juni 1821 in Nöschenrode; † vor 1893) war ein deutscher Marmormeister und Fotograf. Leben Ernst Rose wurde als Sohn des im Dienst der Grafen zu Stolberg-Wernigerode stehenden Bergmanns Johann Heinrich Rose auf der Voigtstiegmühle, die in jener Zeit auch als Marmormü... | null | null | null |
null | Create a python program to compute the volume of a cube given its edge length as an input. | 3 | length = int(input("Enter the edge length of the cube: "))
volume = length * length * length
print("The volume of the cube is", volume) |
null | Create a Python script which inputs a sentence and performs POS tagging and letter count for the text using NLTK library. | This is an example sentence. | import nltk
sentence = 'This is an example sentence.'
words = nltk.word_tokenize(sentence)
tagged_words = nltk.pos_tag(words)
letter_count = 0
for word in words:
letter_count += len(word)
print('POS Tags: ', tagged_words)
print('Letter Count: ', letter_count) |
null | Name 3 methods for making a web page more responsive | Three methods for making a web page more responsive are: 1. Minimize the number and size of images used in the page. This reduces the page size and load time. 2. Implement lazy loading of images, i.e. delay loading images until they are needed. This helps avoid loading images that are far down the page and will not be ... | |
null | Use the given code to create a Pandas Dataframe. | data = {'Name': ['Jack', 'James', 'Joe'], 'Age': [21, 22, 23]} | import pandas as pd df = pd.DataFrame(data) |
null | Create a GPT-3 model that can generate code snippets for Python programs. | Not applicable | The GPT-3 model should take in code snippets with given instructions, and generate code snippets in Python based on those instructions. It should be able to generate code for various programming tasks, from simple to complex, such as data cleaning, data manipulation, custom functions, feature engineering, testing, and ... |
null | Create a Twitter bot using Python that automatically retweets posts based on the user's profile. | A user's profile consists of their interests, hobbies and topics they like to talk about. | import tweepy
import time
consumer_key = 'your consumer key'
consumer_secret = 'your consumer secret'
access_token = 'your access token'
access_token_secret = 'your access token secret'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.AP... |
[DE Wikipedia] Chadakori
Chadakori (auch: Chada Kori, Chadakory, Shadakori) ist eine Landgemeinde im Departement Guidan Roumdji in Niger. Geographie Chadakori liegt am Übergang der Großlandschaft Sudan zur Sahelzone. Die Nachbargemeinden sind Sabon-Machi und Maïyara im Norden, Saé Saboua im Südosten, Guidan Sori und T... | null | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.