text stringlengths 141 2.89k ⌀ | instruction stringlengths 19 1.5k ⌀ | input stringlengths 0 800 ⌀ | output stringlengths 1 2.5k ⌀ |
|---|---|---|---|
null | Construct a Linked List class. | """ Construct a Linked List class """ class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def add_node(self, data): temp = Node(data) temp.next = self.head self.head = temp def print_list(self): current = self.head while current: print(current.d... | |
null | Delete the last element from the given list. | [4, 8, 15, 16, 23, 42] | my_list = [4, 8, 15, 16, 23, 42] del my_list[-1] print(my_list) # prints [4, 8, 15, 16, 23] |
[DE Wikipedia] Liste der Wappen im Kreis Steinburg
Diese Liste zeigt die Wappen des Kreises Steinburg (Schleswig-Holstein), seiner Städte, Gemeinden und Ämter. Kreiswappen Amtsfreie Städte und Gemeinden Ämter Amt Breitenburg Amt Horst-Herzhorn Amt Itzehoe-Land Amt Kellinghusen Amt Krempermarsch Amt Schenefeld Amt Wils... | null | null | null |
null | Generate a list of 10 random integers between 50 and 100. | import random rand_num_list = [random.randint(50, 100) for i in range(10)] print(rand_num_list) | |
null | Define a function in JavaScript that returns true if a given number is even. | function isEven(num) { return num % 2 === 0; } | |
[EN Wikipedia] Allan Dwan
Allan Dwan (born Joseph Aloysius Dwan; April 3, 1885 – December 28, 1981) was a pioneering Canadian-born American motion picture director, producer, and screenwriter. Early life Born Joseph Aloysius Dwan in Toronto, Ontario, Canada, Dwan was the younger son of commercial traveler of woolen cl... | null | null | null |
[HI Wikipedia] ब्रतान्य
ब्रतान्य (फ़्रान्सीसी: Bretagne), जिसे ब्रिटेनी (Brittany) और ब्रॅय्स (Breizh) भी कहा जाता है, पस्चिमोत्तरी फ़्रान्स में स्थित एक सांस्कृतिक क्षेत्र है। यहाँ पारम्परिक रूप से फ़्रान्सीसी भाषा की बजाय ब्रेतों नामक एक केल्टी भाषा बोली जाती थी जो आयरलैंड व स्कॉटलैंड में बोली जाने वाली पारम्परिक के... | null | null | null |
null | Implement a web scraper in Python that can extract the number of followers of a particular user. | import requests
from bs4 import BeautifulSoup
# Set the URL
url = 'https://www.instagram.com/{username}'
# Make a request
response = requests.get(url)
# Parse the response
soup = BeautifulSoup(response.text, 'lxml')
# Extract the followers
followers = soup.find('span', {'class': 'g47SY'}).next_sibling.text
# Print... | |
null | Given a 2D array of binary values and another 2D array, find the indices of the first array where the values of both arrays are equivalent. | array1 = [[1, 0, 0, 1],[1, 0, 1, 0],[0, 0, 0, 1],[1, 0, 1, 0]] array2 = [[1, 0, 1, 0], [1, 0, 0, 1], [0, 0, 0, 1], [1, 0, 0, 1]] | def find_empty_position(array1, array2): results = [] for i in range(len(array1)): for j in range(len(array1[0])): if array1[i][j] == array2[i][j] and array1[i][j] == 0: results.append((i, j)) return results |
null | Edit the following sentence to change its sentiment from negative to positive. | I can't stand programming anymore. | I'm starting to enjoy programming more. |
null | Generate a new voice sample using a given text and speech synthesis model. | text = "Hello, world!" | <nooutput> Since this task requires speech synthesis software and a model, it cannot be completed by the GPT model. |
[EN Wikipedia] Ripia River
The Ripia River is a river of the Hawke's Bay region of New Zealand's North Island. A major tributary of the Mohaka River, it flows generally southeast from its sources at the northern end of the Ahimanawa Range 25 kilometres east of Lake Taupō, reaching the Mohaka 40 kilometres northwest of... | null | null | null |
null | This code sets up an MQTT RPC server. To use it, you need to import the necessary libraries and create an instance of the TMQTTRPCServer class, passing in a Mosquitto client and a driver ID. Then, call the setup method on the server instance to subscribe to the appropriate MQTT topics. Finally, start the Mosquitto clie... | #!/usr/bin/python
import argparse
try:
import mosquitto
except ImportError:
import paho.mqtt.client as mosquitto
import time, random
import sys
from mqttrpc import MQTTRPCResponseManager, dispatcher
import logging
logging.getLogger().setLevel(logging.DEBUG)
@dispatcher.add_method
def foobar(**kwargs):
... | |
[HI Wikipedia] फ़िजी
फ़िजी जो कि आधिकारिक रूप से फ़िजी द्वीप समूह गणराज्य (फ़िजीयाई: Matanitu Tu-Vaka-i-koya ko Viti) के नाम से जाना जाता है, दक्षिण प्रशान्त महासागर के मेलानेशिया मे एक द्वीप देश है। यह न्यू ज़ीलैण्ड के नॉर्थ आईलैंड से करीब 2000 किमी उत्तर-पूर्व मे स्थित है। इसके समीपवर्ती पड़ोसी राष्ट्रों मे पश्चिम क... | null | null | null |
null | Write a Python program to generate documentation in HTML format for a given Python solution. | Solution:
def add_item(item_list, new_item):
item_list.append(new_item)
return | def generate_html_doc(solution):
html = "<html>\n<head>\n<title>Python Documentation</title>\n</head>\n<body>\n\n<h1>Solution</h1>\n\
<pre>\n"
html += solution + "\n</pre>\n\n</body>\n</html>"
return html |
[DE Wikipedia] Marschallstab
Der Marschallstab als Stab wird von einem Marschall als Insigne seiner Würde geführt und wurde nur bei zeremoniellen Anlässen getragen. Entstehung Der Marschall bezeichnet ein hohes Amt an fürstlichen Höfen und war der (militärische und politische) Führer der Ritterschaft des jeweiligen Fü... | null | null | null |
null | Modify the code to perform the mathematical expression “x to the power of y”. | # Calculate x to the power of y # TODO | # Calculate x to the power of y x_pow_y = x**y |
[CS Wikipedia] Estadio Olímpico Universitario
Estadio Olímpico Universitario je víceúčelový stadion v Ciudad de México, sloužící zejména pro fotbal a atletiku. Pojme 72 000 diváků. Otevřen byl v roce 1952 a byl hlavním dějištěm Letních olympijských her 1968. Stadion je součástí Univerzitního kampusu Mexické národní au... | null | null | null |
null | Design a function in Python to compute the factorial of a given number. | def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1) | |
[HI Wikipedia] पंजाब विश्वविद्यालय
पंजाब विश्वविद्यालय (, पंजाबी:ਪੰਜਾਬ ਯੂਨੀਵਰਸਿਟੀ) भारत के प्राचीन विश्वविद्यालयों में से एक है। यह चंडीगढ में स्थित हैं। इसकी स्थापना 1882 में लाहौर में हुई थी और विभाजन के बाद भारत में कुछ समय के लिए यह दिल्ली तथा शिमला से कार्यरत रही थी। 1958 ई. से यह वर्तमान में चण्डीगढ़ शहर के दो स... | null | null | null |
[HI Wikipedia] राजधानी
राजधानी वह नगरपालिका होती है, जिसे किसी देश, प्रदेश, प्रान्त या अन्य प्रशासनिक ईकाई अथवा क्षेत्र में सरकार की गद्दी होने का प्राथमिक दर्जा हासिल होता है। राजधानी मिसाली तौर पर एक शहर होता है, जहाँ संबंधित सरकार के दफ़्तर और सम्मेलन -ठिकाने स्थित होते हैं और आम तौर पर अपने क़ानून या संविधान द्वार... | null | null | null |
[CS Wikipedia] Římskokatolická farnost Dolní Bukovsko
Římskokatolická farnost Dolní Bukovsko je územním společenstvím římských katolíků v rámci vikariátu České Budějovice - venkov českobudějovické diecéze. O farnosti Historie V roce 1359 je v Dolním Bukovsku doložena plebánie. V kostele Narození Panny Marie se z této ... | null | null | null |
null | Create a Python program that takes a list of strings and filters out strings that do not contain the letter 'a'. | words = ["apple", "banana", "grape", "pear", "kiwi"] | # Filtering out strings without letter 'a'
filtered_words = [word for word in words if 'a' in word]
# Print the filtered list
print(filtered_words)
# Output: ['apple', 'banana', 'grape'] |
[DE Wikipedia] Liste der Monuments historiques in Marcilly-en-Bassigny
Die Liste der Monuments historiques in Marcilly-en-Bassigny führt die Monuments historiques in der französischen Gemeinde Marcilly-en-Bassigny auf. Liste der Immobilien |} Weblinks MarcillyenBassigny MarcillyenBassigny ! | null | null | null |
null | Write a SQL query to list all the customers whose age is over 18. | SELECT * FROM customers WHERE age > 18; | |
null | Extract all characters from the following text and store them in a new string. | Hello world! | characters = "Helloworld!" |
[DE Wikipedia] Richard Giesen
Richard Giesen ist der Name folgender Personen: * Richard Giesen (Diplomat) (* 1933), deutscher Diplomat Richard Giesen (Rechtswissenschaftler) (* 1964), deutscher Rechtswissenschaftler | null | null | null |
null | Count the number of vowels in a sentence. | "Hi there, how are you doing?" | int countVowels = 0; String sentence = "Hi there, how are you doing?"; for (int i = 0; i < sentence.length(); i++) { if (sentence.charAt(i) == 'a' || sentence.charAt(i) == 'e' || sentence.charAt(i) == 'i' || sentence.charAt(i) == 'o' || sentence.charAt(i) == 'u') { countVowels++; } } System.out.println("Number of vowel... |
[DE Wikipedia] Mitterdorf im Mürztal
Mitterdorf im Mürztal ist eine ehemalige Marktgemeinde mit Einwohnern () im Gerichtsbezirk Mürzzuschlag und im politischen Bezirk Bruck-Mürzzuschlag in der Steiermark. Bis Ende 2014 war Mitterdorf eine selbständige Marktgemeinde. Im Rahmen der Gemeindestrukturreform in der Steierma... | null | null | null |
null | Given an array with n numbers, write a function to find if there exists three elements in the array whose sum is equal to a given number. | array = [5, 3, 1, 8], number = 14 | def sum_three_elements(array, number): """Given an array with n numbers, find if there exists three elements in the array whose sum is equal to a given number.""" array.sort() for i in range(len(array) - 2): left = i + 1 right = len(array) - 1 while left < right: temp = array[i] + array[left] + array[right] if temp == ... |
null | Create a Python script for creating a GUI app with a login page. | Not applicable | from tkinter import *
root = Tk()
root.title("Login Page")
# Create window
window_width = 400
window_height = 350
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
x_cord = int((screen_width/2) - (window_width/2))
y_cord = int((screen_height/2) - (window_height/2))
# Set window geome... |
null | Perform a web scraping to retrieve the prices of a specific product. | Website: www.amazon.com Product: iPhone 12 | import requests from bs4 import BeautifulSoup website = requests.get('https://www.amazon.com/Apple-iPhone-12-Unlocked-128GB/dp/B08HeG719F/ref=sr_1_1') soup = BeautifulSoup(website.content, 'html.parser') price_divs = [] price_divs = soup.find_all('span', {'class': 'a-price-whole'}) for price_div in price_divs: print(pr... |
[DE Wikipedia] Bernhard Heusler
Bernhard Heusler (* 27. Dezember 1963 in Basel) ist ein Schweizer Rechtsanwalt und ehemaliger Präsident des Fussballclubs FC Basel. Leben Heusler studierte Rechtswissenschaften an der Universität Basel (lic. iur. 1988; summa cum laude). Er war wissenschaftlicher Assistent bei René Rhino... | null | null | null |
null | Edit the following Python code to calculate the average of three values given by the user. | a = int(input("Enter first value: ")
b = int(input("Enter second value: ")
c = int(input("Enter third value: ")
print("The average is: " + a) | a = int(input("Enter first value: "))
b = int(input("Enter second value: "))
c = int(input("Enter third value: "))
average = (a + b + c) / 3
print("The average is: " + str(average)) |
null | Write a code to extract data from a PDF document. | # install the required package pip install pdfminer.six # importing all the required modules from pdfminer.pdfparser import PDFParser from pdfminer.pdfdocument import PDFDocument # open the pdf file fp = open('sample_form.pdf', 'rb') # create parser object parser = PDFParser(fp) # create pdf document object doc = PDFDo... | |
[EN Wikipedia] Gmina Parysów
Gmina Parysów is a rural gmina (administrative district) in Garwolin County, Masovian Voivodeship, in east-central Poland. Its seat is the village of Parysów, which lies approximately north-east of Garwolin and south-east of Warsaw. The gmina covers an area of , and as of 2006 its total po... | null | null | null |
null | Assign a value to `name` by using the ternary operator | let name; | name = condition ? value1 : value2; |
[HI Wikipedia] वोटापूरी-कटारक़लाई भाषा
वोटापूरी-कटारक़लाई (Wotapuri-Katarqalai, ) कोहिस्तानी उपशाखा की एक दार्दी भाषा है जो अफ़ग़ानिस्तान के नूरिस्तान प्रान्त की वोटापूरी और कटारक़लाई नामक बस्तियों में बोली जाती थी। सन् १९३५ में कटारक़लाई में इसे ६० घरों में बोला जाता था लेकिन १९५५ में इसे बोलने वाला एक ही व्यक्ति मिल... | null | null | null |
[EN Wikipedia] Dinaritoidea
Dinaritoidea is an extinct superfamily of ammonoids in the order Ceratitida. References External links Ceratitida superfamilies | null | null | null |
null | Create a Python program to copy elements of one array into another array. | Array 1=[1,2,3,4] | array_1 = [1,2,3,4]
array_2 = []
# Copying all the elements
for i in range(0, len(array_1)):
array_2.append(array_1[i])
print ("Elements Copied from the Array1 to Array2 are : " + str(array_2)) |
null | Can you provide a Python program that resize an array of integers in place? | arr = [10, 20, 30, 40]
new_size = 6 | """
Providing a Python program that resizes an array of integers in place
"""
def resize_array(arr, new_size):
# base case
if len(arr) == new_size:
return
# add elements to increase the size
if len(arr) < new_size:
for _ in range(new_size - len(arr)):
arr.append(0)
# de... |
[HI Wikipedia] कौमार्य
कौमार्य एक ऐसी अवस्था होती है जिसमें व्यक्ति ने कभी भी संभोग नहीं किया होता है। सांस्कृतिक और धार्मिक परंपराओं में विशेष रूप से अविवाहित महिलाओं, निजी पवित्रता के विचार के साथ जुड़े मामलों और मूल्यों आदि को विशेष मूल्य और महत्व दिया गया है। सतीत्व अथवा शुद्धता की तरह ही, कौमार्य की अवधारणा में भ... | null | null | null |
null | Generate a Python code for replicating an output after switching the contents of two strings. | Given two strings, ‘str1’ and ‘str2’, swap the contents of the two strings.
For example, if the two strings are ‘Hello’ and ‘World’, the output after swtiching the contents should be ‘Worlh’ and ‘Hello’ | str1, str2 = 'Hello', 'World'
str1, str2 = str2, str1
print("After swapping: str1 =", str1, "and str2 =", str2) |
null | Design a program to remove punctuations from a given string. | def remove_punctuations(s): punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~''' s_without_punc = "" for char in s: if char not in punctuations: s_without_punc = s_without_punc + char return s_without_punc | |
[CS Wikipedia] Fondachelli-Fantina
Fondachelli-Fantina je italská obec, součást Metropolitního města Messina, nacházející se na severovýchodní Sicílii. V roce 2016 zde žilo 1021 obyvatel. Rozkládá se v nadmořské výšce nad 600 metrů nad mořem, v údolí řeky Patri v pohoří Peloritani. Okolí dominují vrcholy Montagna Gran... | null | null | null |
null | Using the code given below, add JavaScript code to make the hyperlinks open in a new tab. | <ul> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> </ul> | <ul> <li><a href="#" target="_blank">Home</a></li> <li><a href="#" target="_blank">About</a></li> <li><a href="#" target="_blank">Contact</a></li> </ul> |
null | How can you ensure that a button element with the ID of "submit-btn" is not clickable? | You can ensure that a button element with the ID of "submit-btn" is not clickable by adding this code to the CSS file: #submit-btn{ pointer-events: none; } | |
null | Generate a random list of 20 numbers between 1 and 100. | [86, 19, 2, 8, 12, 37, 43, 48, 63, 68, 21, 4, 39, 55, 87, 23, 69, 61, 44, 91] | |
null | Develop a Python script to print all the permutations of a given string. | def permutations(string):
perms = []
if len(string) == 1:
perms.append(string)
return perms
for i in range(len(string)):
substring = string[:i] + string[i+1:]
for permutation in permutations(substring):
perms.append(string[i] + permutation)
return perms
permutations('ABC') | |
[HI Wikipedia] बीने–कौशी तत्समक
The firstrfu सभी वास्तविक तथा सम्मिश्र संख्याओं के लिए (व्यापक रूप से क्रमविनिमय वलय के तत्व)। a<subf>i</sub> = cigI और bi = ''d<sub>i</fsub>'gf', रखने पर लाग्रांज तत्समक प्राप्त होता है जो यूक्लिडीय समष्टि frr के लिए कौशी–श्वार्ज असमिका का प्रबल संस्करण है। सन्दर्भ yf e{कौशी नामकरण}}... | null | null | null |
[HI Wikipedia] अगरतला
अगरतला (Agartala) भारत के त्रिपुरा राज्य की राजधानी है। यह पश्चिम त्रिपुरा ज़िले का मुख्यालय भी है। इसकी स्थापना 1850 में महाराज राधा कृष्ण किशोर माणिक्य बहादुर द्वारा की गई थी। बांग्लादेश से केवल दो किमी दूर स्थित यह नगर सांस्कृतिक रूप से समृद्ध है। अगरतला त्रिपुरा के पश्चिमी भाग में स्थित है और... | null | null | null |
null | Develop a program in Python to find the second largest element in a given array. | [10, 11, 8, 9, 20] | def second_largest(arr):
first = max(arr[0], arr[1])
second = min(arr[0], arr[1])
for i in range(2, len(arr)):
if arr[i] > first:
second = first
first = arr[i]
elif arr[i] > second and arr[i] != first:
second = arr[i]
return second |
null | Create a simple Python program that finds the number of even numbers in a given list. | list1 = [1, 4, 5, 6, 3, 2] | def count_even_numbers(list1):
count = 0
for item in list1:
if item % 2 == 0:
count += 1
return count
print(count_even_numbers(list1)) |
null | Generate a program in Python to solve a given linear equation | 3x + 5 = 10 | def solve_linear_eq(eq):
x, b = eq.split(' ')
a, op, constant_term = x.split('x')
a = int(a)
b = int(b)
constant_term = int(constant_term)
if op == '+':
x = (constant_term - b) / a
elif op == '-':
x = (b - constant_term) / a
return x
solution = solve_linear_eq... |
null | Generate input data for a convolutional neural network (CNN). | The CNN will classify objects in an image. | Input data should include an image dataset of the objects to be classified. Each image should contain its corresponding label. Image labels can be one-hot encoded. The dataset should be split into separate training, validation and test datasets. |
[HI Wikipedia] मल्ल (कुलनाम)
भारत के कई भागों के लोगों का कुलनाम मल्ल है। भारत के उत्तर प्रदेश के पूर्वी जिलों (कुशीनगर, देवरिया, गोरखपुर, महराज गंज, बस्ती, आजमगढ़ आदि) में बसने वाली एक क्षत्रिय जाति क कुलनाम, आंध्र प्रदेश के पूर्वी गोदावरी और विशाखापत्तनम जिलों में 'गवर' नाम की जाति के लोगों का प्रसिद्ध कुलनाम कश्मीर... | null | null | null |
null | Edit a Python program to modify a numpy array into a pandas Dataframe. | Numpy Array | import numpy as np
import pandas as pd
# Load the data
data = np.load('data.npy')
# Create the pandas DataFrame
df = pd.DataFrame(data) |
null | Write a Python program to sort a list of numbers from lowest to highest. | [7, 3, 5, 8, 4] | [3, 4, 5, 7, 8] |
null | Create a function in C that takes a string as input and returns an integer, which represents the number of occurences of a given character in the string. | "Hello, World!", 'o' | int count_occurrences(char *str, char c) { int count = 0; // Traverse the string and check // for occurrences of character. for (int i=0; str[i] != '\0'; i++) if (str[i] == c) count++; return count; } |
null | Find a Python solution for this leetcode problem. | Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. | def twoSum(nums, target): numDict = dict() for index, num in enumerate(nums): if num in numDict.keys(): return [numDict[num], index] else: numDict[target-num] = index |
[DE Wikipedia] Julia Ritter
Julia Ritter (* 13. Mai 1998 in Lünen, Nordrhein-Westfalen) ist eine deutsche Leichtathletin, die sich auf das Kugelstoßen und den Diskuswurf spezialisiert hat. Sie war U18-Weltmeisterin und U20-Europameisterin im Kugelstoßen. Berufsweg Ritter machte 2016 Abitur am Städtischen Gymnasium Ber... | null | null | null |
null | Create a Python script to calculate the mode of an integer list. | [1,1,2,2,2] | def get_mode(nums):
# create a dictionary to store count of each number
counts = {}
# loop through the list
for num in nums:
# add the number to the count if not present
if num not in counts:
counts[num] = 1
# else increment the count
else:
counts[... |
null | Create a password validator program in Python to check if a given password is valid or not. | def is_valid_password(pwd):
if len(pwd) < 6:
print("Password must be at least 6 characters long.")
return False
if not any(char.isdigit() for char in pwd):
print("Password must have at least one number.")
return False
if not any(char.isupper() for char in pwd):
prin... | |
null | Develop a program that alters and returns a given string. | string: "Python is fun!" | """
Develop a program that alters and returns a given string
"""
def alter_string(string):
# alter the original string
string_altered = string.replace("!", "?")
return string_altered
if __name__ == '__main__':
string = "Python is fun!"
print(alter_string(string)) |
[DE Wikipedia] Volyně
Volyně [] (deutsch Wolin) ist eine Stadt in Tschechien. Sie liegt 10 Kilometer südlich von Strakonice und bezeichnet sich als „Tor zum Böhmerwald“ (brána Šumavy). Geographie Geographische Lage Durch die Stadt an der Volyňka führt die Staatsstraße Silnice I/4 zwischen Strakonice und der bayerische... | null | null | null |
null | Construct a python dictionary from the following data. | fruit, apple
animal, cat
city, London | mydict = {
'fruit': 'apple',
'animal': 'cat',
'city': 'London'
} |
null | How would you check for syntax errors in a given Java code? | Syntax errors in Java code can be checked by using the Java compiler. The compiler will identify the location and reason for any syntax errors, which can then be corrected. Additionally, IDEs often have built-in syntax checkers that can highlight errors before compilation. | |
null | Write a Python program which prints the first n terms of the Fibonacci sequence. | n = 10 | def print_fibonacci(n):
a = 0
b = 1
if n < 0:
print("Incorrect input")
elif n == 0:
return a
elif n == 1:
return b
else:
print(a)
print(b)
for i in range(2,n):
c = a + b
a = b
b = c
print(c... |
null | Generate a python program to parse a string and extract the number of vowels. | Input string: “Hello World!" | def count_vowels(s):
vowels = ["a", "e", "i" , "o", "u"]
count = 0
for character in s.lower():
if character in vowels:
count += 1
print("Number of vowels :", count) |
null | Develop a Python script to print the prime factors of a given positive integer. | def primeFactors(n):
factors = []
while n % 2 == 0:
factors.append(2)
n = n / 2
for i in range(3, int(sqrt(n))+1, 2):
while n % i== 0:
factors.append(i)
n = n / i
if n > 2:
factors.append(n)
return fa... | |
null | Refactor a Python program that prints a sports leaderboard to improve speed and accuracy. | Example Python program:
scores = [12, 14, 16, 18, 20]
names = ["Ann", "Bob", "Carol", "Dave", "Ella"]
for i in range(len(scores)):
print(f"{i+1}. {names[i]} - {scores[i]} points") | scores = [12, 14, 16, 18, 20]
names = ["Ann", "Bob", "Carol", "Dave", "Ella"]
# create a dictionary with name-score pairs
leaderboard = {names[i]:scores[i] for i in range(len(scores))}
# sort the leaderboard by score
sorted_leaderboard = sorted(leaderboard.items(), key=lambda x: x[1], reverse=True)
# print the sorte... |
null | Write a Python program to implement an algorithm selection sort. | Not applicable | def selectionSort(array):
# loop over the array
for i in range(len(array)-1):
# find the minimum element
minimum = i
for j in range(i + 1, len(array)):
if array[minimum] > array[j]:
minimum = j
# Swap the found minimum element with
... |
null | Write a Python program that creates a new dictionary from two existing dictionaries. | dict1 = {'a':1, 'b':2, 'c':3}
dict2 = {'d':4, 'e':5, 'f':6} | dict3 = {key:dict1[key] if key in dict1 else dict2[key] for key in (dict1.keys() | dict2.keys())} |
null | Develop a Python function that takes two arrays of equal size as input and returns the sum of the two arrays. | [1,2,3], [4,5,6] | def sum_arrays(arr1, arr2):
result = []
for i in range(len(arr1)):
result.append(arr1[i] + arr2[i])
return result
summed = sum_arrays([1,2,3], [4,5,6])
print(summed) |
null | Write a python program to print out the sum of numbers up to an inputted number. | def sum_up(n):
sum = 0
for i in range(n + 1):
sum += i
return sum
num = int(input("Enter a number: "))
print("Sum of numbers up to", num, "is", sum_up(num)) | |
null | Construct a Python class named “Car” that has 3 fields: top_speed, make, and color. | class Car:
def __init__(self, top_speed, make, color):
self.top_speed = top_speed
self.make = make
self.color = color | |
null | Develop a Python program that encrypts a given string using 'Caeser Cipher' | string = 'Hello World' | def caesarCipherEncryptor(string, key):
newLetters = []
newKey = key % 26
for letter in string:
newLetters.append(getNewLetter(letter, newKey))
return ''.join(newLetters)
def getNewLetter(letter, key):
newLetterCode = ord(letter) + key
return chr(newLetterCode) if newLetterCode <= 122 else chr(96 + n... |
[EN Wikipedia] Gavril Blajek
Gavril Blajek (born 23 July 1939) is a Romanian water polo player. He competed in the men's tournament at the 1960 Summer Olympics. References 1939 births Living people Romanian male water polo players Olympic water polo players for Romania Water polo players at the 1960 Summer Olympics Pe... | null | null | null |
[CS Wikipedia] Římskokatolická farnost Mladošovice
Římskokatolická farnost Mladošovice je územním společenstvím římských katolíků v rámci vikariátu České Budějovice - venkov českobudějovické diecéze. O farnosti Historie V roce 1367 je v Mladošovicích doložena plebánie. Ta později zanikla a do roku 1631 zde duchovní sp... | null | null | null |
null | Write a SQL query to find all teachers with more than 10 years of experience. | SELECT * FROM teachers WHERE years_of_experience > 10; | |
null | Create a function that finds the highest peak in an array of elevation data. | [9, 10, 12, 15, 7, 8, 11] | def find_peak(arr): max_h = arr[0] max_i = 0 # traverse the array for i in range(len(arr)): if arr[i] > max_h: max_h = arr[i] max_i = i return max_h, max_i |
[CS Wikipedia] Zdeněk Král
Zdeněk Král, Ph.D. (* 22. února 1971 Česká Lípa) je český pianista, hudební skladatel a autor dětských knih. Je držitelem několika cen, např. Classic Prague Awards za nejlepší skladbu vážné hudby za rok 2019, Generace (1. a 3. místo), cen Osa za nejúspěšnějšího skladatele vážné hudby 2019 a ... | null | null | null |
null | Implement a function that takes two numbers as parameters and returns their difference. | 17, 10 | int difference(int a, int b) { return a - b; } |
null | Create a python program to return a new list with each item multiplied by 2 in an existing list. | [1, 2, 3, 4, 5] | def mult_by_two(nums): """ Returns a new list with each item multiplied by 2 in an existing list :param nums: a list of numbers :return: a list of numbers with each item multiplied by 2 """ new_list = [] for num in nums: new_list.append(num * 2) return new_list if __name__ == '__main__': nums = [1, 2, 3, 4, 5] print(mu... |
[CS Wikipedia] Lukáš Dvořák
Lukáš Dvořák (* 1982, Praha) je český fotograf a malíř. Jeho výtvarná díla byla publikována v řadě módních časopisů, včetně Vogue, Harper's Bazaar, Marie Claire, Vanity Fair, Cosmopolitan, Woman, nebo pánských magazínech Playboy a GQ. Život a dílo Narodil se v roce 1982 v Praze. Na počátku ... | null | null | null |
null | Generate a list comprehension in Python that prints the cubes of the first 5 numbers. | [x**3 for x in range(1, 6)] | |
null | Write a Python program to sort a given array of numbers. | def sort_numbers(arr):
for i in range(len(arr)):
min_idx = i
for j in range(i+1, len(arr)):
if arr[min_idx] > arr[j]:
min_idx = j
arr[i], arr[min_idx] = arr[min_idx], arr[i]
arr = [2, 5, 1, 3, 8, 4]
sort_numbers(arr) | |
null | Set environment variables for the web application, including debug level, user privileges, limits for mapping and correlation, daily download limit, temporary data lifespan, and various URLs. Also set file paths for various directories and define constants for the website name and port address. | #########################################'
# Environment Variables - public
#########################################
#Debug Level
#1 for debug, mod python will reload import each time
DEBUG = 1
#USER privilege
USERDICT = {'guest':1,'user':2, 'admin':3, 'root':4}
#minimum number of informative strains
KMININFOR... | |
null | Create a class to represent a two-dimensional vector. | class Vector2D(object): '''Class to represent a two-dimensional vector''' def __init__(self, x, y): self.x = x self.y = y def __add__(self, other): return Vector2D(self.x + other.x, self.y + other.y) def __sub__(self, other): return Vector2D(self.x - other.x, self.y - other.y) def __mul__(self, scalar): return Vector2D... | |
null | Construct a parser in Python to read a table from HTML. | <table>
<tr>
<th>Name</th>
<th>Age</th>
<th>City</th>
</tr>
<tr>
<td>John</td>
<td>25</td>
<td>New York</td>
</tr>
<tr>
<td>Mary</td>
<td>22</td>
<td>Chicago</td>
</tr>
</table> | import lxml.html
def parse_table(html_str):
root = lxml.html.fromstring(html_str)
# locate the table
table = root.xpath('//table')[0]
# collect header names
header_names = [th.text_content() for th in table.xpath('//th')]
# collect data rows
data_rows = table.xpath('//tr')[1:]
data_r... |
null | Write a Python program to group the values of a given list of elements based on the size of the elements. | """ Write a Python program to group the values of a given list of elements based on the size of the elements. """ def group_values(values): result = {} for value in values: size = len(value) if size not in result: result[size] = [] result[size].append(value) return result if __name__ == "__main__": values = ['cat', 'do... | |
[HI Wikipedia] उड़न साँप
उड़न साँप क्रिसोपिली (Chrysopelea) जीनस के साँप हैं जो बहुत कम विषैले होते हैं और मनुष्यों के लिए हानिरहित है। ये दक्षिण-पूर्वी एशिया, दक्षिणी चीन, भारत और श्रीलंका में पाए जाते हैं। भारत में ये मध्य भारत, बिहार, उड़ीसा और बंगाल में अधिक पाए जाते हैं। यह बहुत तीव्र गति से चलने की क्षमता रखता ह... | null | null | null |
null | Write a JavaScript program that takes an array as input and prints its contents. | ['Hello','World','!'] | let inputArray = ['Hello', 'World', '!']; for (let i = 0; i < inputArray.length; i++) { console.log(inputArray[i]) } |
null | Write an SQL query that calculates the total order value for each delivery zone in the ‘zones’ table. | SELECT zone, SUM(price*quantity) AS 'Total Order Value' FROM orders JOIN zones ON orders.zone_id = zones.zone_id GROUP BY zone; | |
null | Generate a matrix of random numbers using Python. | Matrix Size: 20 x 30 | matrix = [[random.random() for j in range(30)] for i in range(20)] |
null | Calculate the shortest path from source to destination using Dijkstra's Algorithm. | graph = {
'a': {'b':10, 'c':3},
'b': {'c':1, 'd':2},
'c': {'b':4, 'd':8, 'e':2},
'd': {'e':7},
'e': {'d':9}
}
source = a
dest = d | """
Calculate the shortest path from source to destination using Dijkstra's Algorithm.
"""
# Python program for Dijkstra's single
# source shortest path algorithm. The program is
# for adjacency matrix representation of the graph
# Library for INT_MAX
import sys
class Graph():
def __init__(self, ver... |
null | What is the purpose of a join operation in a relational database? | A join operation in a relational database is used to combine data from two or more tables based on a common field. This is done to match and retrieve related data from one or multiple tables and then use it as a single result. The most common type of join is an inner join, which combines only the matching records from ... | |
null | Write a function in SQL to get the average salary of all engineers whose designation is "Senior Software Engineer". | SELECT AVG(salary) FROM engineers WHERE designation = 'Senior Software Engineer'; | |
null | Create a web scraper in Python to extract information from a webpage. | "https://www.example.com" | import requests
from bs4 import BeautifulSoup
URL = "https://www.example.com"
page = requests.get(URL)
soup = BeautifulSoup(page.content, 'html.parser')
# extract information by tags
title = soup.find("title")
headings = soup.find_all("h1")
links = soup.find_all("a")
# print the extracted data
print("Title: "... |
null | The given code is a Python class named "DepsGraphBuilder" that is responsible for computing the dependencies graph DepsGraph. To use it, create an instance of the class and call the "load_graph" method with a root node, check_updates, update, remotes, and processed_profile as parameters to load the dependencies graph. ... | import time
from collections import OrderedDict
from conans.client.graph.graph import DepsGraph, Node, RECIPE_EDITABLE
from conans.errors import (ConanException, ConanExceptionInUserConanfileMethod,
conanfile_exception_formatter)
from conans.model.conan_file import get_env_context_manager
fr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.