text
stringlengths
141
2.89k
⌀
instruction
stringlengths
19
1.5k
⌀
input
stringlengths
0
800
⌀
output
stringlengths
1
2.5k
⌀
[DE Wikipedia] Gregory Luo Wenzao Gregory Luo Wenzao OP (; * um 1610 in Fu’an, Fujian, Kaiserreich China; † 27. Februar 1691 in Nanjing, Jiangsu, Kaiserreich China) war der erste römisch-katholische Bischof chinesischer Herkunft und Mitglied des Ordens der Dominikaner. Lou wurde am 24. Dezember 1633 getauft. 1650 trat...
null
null
null
null
Create a Python function to calculate the sum of two numbers given as inputs.
5, 6
def calculateSum(a, b): return a + b sum = calculateSum(5, 6) print(sum)
null
Find the second largest number in the following array of integers.
[1, 6, 4, 8, 7]
7
null
Explain the principle of dynamic programming.
Dynamic programming is a technique for solving complex problems by breaking them down into smaller subproblems. The subproblems are solved and stored in a table, which is reused to solve future subproblems. This technique allows for efficient solutions regardless of the complexity of the problem, as it exploits the ove...
[EN Wikipedia] Tahekeroa River The Tahekeroa River is a river of the Auckland Region of New Zealand's North Island. It flows generally southwest to reach the Makarau River eight kilometres north of Kaukapakapa. See also List of rivers of New Zealand References Rivers of the Auckland Region Manukau Harbour catchment
null
null
null
null
Implement a solution in Python using loops, to determine the maximum number of consecutive 1's in a binary number.
1011101101
def max_consecutive_ones(n): max_ones = 0 count = 0 while n > 0: if n %2 == 1: count+=1 max_ones = max(max_ones, count) else: count = 0 n>>=1 return max_ones
null
Create a program that reads two numbers and prints out their greatest common divisor.
def gcd(a, b): if a == 0: return b return gcd(b % a, a)
null
Write a method that produces a random password with the specified number of characters.
import string import random def generate_password(characters): password = '' for _ in range(characters): password += random.choice(string.ascii_letters + string.digits) return password
[EN Wikipedia] Marinobacter nitratireducens Marinobacter nitratireducens is a Gram-negative, halophilic rod-shaped and motile bacterium from the genus of Marinobacter which has been isolated from coastal sea water from Visakhapatnam in India. References Alteromonadales Bacteria described in 2015 Halophiles
null
null
null
[DE Wikipedia] Land- und Forstwirtschaftsminister (Finnland) Der Land- und Forstwirtschaftsminister Finnlands (finnisch: Suomen maa- ja metsätalousministeri, schwedisch: jord- och skogsbruksminister) ist ein Teil der finnischen Regierung. Liste der Minister Folgend eine Liste der Land- und Forstwirtschaftsminister der...
null
null
null
[DE Wikipedia] Mauzenstein Der Mauzenstein ist ein als Naturdenkmal ausgewiesener Buntsandsteinfelsen auf der Grenze zwischen den baden-württembergischen Städten Gaggenau (Landkreis Rastatt) und Bad Herrenalb (Landkreis Calw) im Nordschwarzwald. Er liegt, unweit des Bernsteins, auf am Mauzenberg südlich der Einsattlun...
null
null
null
null
Create a Python class that provides an interface for a Stack data structure.
Not applicable
class Stack: def __init__(self): self.stack = [] def push(self, item): self.stack.append(item) def pop(self): if self.stack: return self.stack.pop() else: return None def is_empty(self): return len(self.stack) == 0
null
Rewrite the following code snippet to use the arcpy module.
import os file_paths = [os.path.join('data', f) for f in os.listdir('data') if f.endswith('.tif')]
import os import arcpy file_paths = [os.path.join('data', f) for f in arcpy.ListRasters('*.tif')]
null
Create a python program that given an input string and an array of strings, returns true if an anagram of the input string exists within the array.
input_string="listen" strings=["enlist","google","inlets","banana"]
def anagram_in_list(input_string, strings): result = False for string in strings: if is_anagram(input_string, string): result = True break return result input_string="listen" strings=["enlist","google","inlets","banana"] print(anagram_in_list(input_string, strings))
[HI Wikipedia] बेगम हज़रत महल बेगम हज़रत महल (नस्तालीक़: , 1820 - 7 अप्रैल 1879), जो अवध (अउध) की बेगम के नाम से भी प्रसिद्ध थीं, अवध के नवाब वाजिद अली शाह की दूसरी पत्नी थीं। अंग्रेज़ों द्वारा कलकत्ते में अपने शौहर के निर्वासन के बाद उन्होंने लखनऊ पर क़ब्ज़ा कर लिया और अपनी अवध रियासत की हुकूमत को बरक़रार रखा। अंग्रे...
null
null
null
null
Write a Python class to implement a linked list.
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def push(self, data): node = Node(data) node.next = self.head self.head = node def pop(self): data = self.head.data self.head = self.head.next return data
null
Write a function that takes an array of integers and returns an array of the same length with each element multiplied by 2.
[1, 2, 3]
def multiplyByTwo(arr): multipliedArr = [] for i in arr: multipliedArr.append(i*2) return multipliedArr
[EN Wikipedia] Arthur Schopenhauer Arthur Schopenhauer ( , ; 22 February 1788 – 21 September 1860) was a German philosopher. He is best known for his 1818 work The World as Will and Representation (expanded in 1844), which characterizes the phenomenal world as the manifestation of a blind and irrational noumenal will....
null
null
null
[CS Wikipedia] Slepé pleso Slepé pleso je zanikající jezero v Mlynické dolině ve Vysokých Tatrách na Slovensku. Zarůstající vodní plocha má rozlohu 0,9651 ha. Je 152 m dlouhé a 101 m široké. Leží v nadmořské výšce 1375 m. Okolí Nachází se ve vzdálenosti 100 m severozápadně od Štrbského plesa přibližně o 30 m výše za ú...
null
null
null
null
Design a for loop in Python which iterates over two given lists and prints their items in a orderly manner.
list1 = [1, 2, 3] list2 = ["Apple", "Banana", "Cherry"]
for item1, item2 in zip(list1, list2): print(f"{item1}: {item2}")
[EN Wikipedia] Arcesis anax Arcesis anax is a moth of the family Tortricidae. It is found in Vietnam, Thailand and Sumatra. References Moths described in 1983 Olethreutini Moths of Asia
null
null
null
[HI Wikipedia] शुग़नी भाषा शुग़नी भाषा एक पामीरी भाषा-परिवार की बोली है जो मध्य एशिया में ताजिकिस्तान के कूहिस्तोनी-बदख़्शान स्वशासित प्रान्त और अफ़ग़ानिस्तान के बदख़्शान प्रान्त में बोली जाती है। उपभाषाएँ रुशानी भाषा, जो अधिकतर ताजिकिस्तान में बोली जाती है, शुग़नी की ही एक उपभाषा है। बरतानगी, ख़ुलफ़ी और रोशोरवी भी अक...
null
null
null
null
Write a code to find the first 4 terms of the Fibonacci sequence in Java.
public class Fibonacci { public static int[] getFibonacciNumbers(int numTerms) { int[] sequence = new int[numTerms]; int firstTerm = 0, secondTerm = 1; sequence[0] = firstTerm; sequence[1] = secondTerm; for (int i = 2; i < numTerms; i++) { sequence[i] = firstTerm + secondTerm; int temp = secondTerm; secondTerm = firstT...
[DE Wikipedia] Albrecht I. Rindsmaul Albrecht I. Rindsmaul, auch Albrecht Rindsmaul von Grünsberg (Vorname auch: Albert; * vor 1175; † nach 1234), war ein Ministeriale und Truchsess im Dienst einiger Könige und Kaiser im Heiligen Römischen Reich. Leben Albrecht entstammte der altadeligen Familie Rindsmaul. Seine Mutte...
null
null
null
[CS Wikipedia] Leo TV Leo TV je česká placená soukromá erotická televizní stanice. Program Stanice uvádí, že její záměr je vysílat převážně live show, plánuje však také erotické reality show a podobně zaměřené pořady. Stanice též nabízí lidem podílet se na tvorbě pořadů. V roce 2009 udělila Rada pro rozhlasové a telev...
null
null
null
null
Generate a graphical representation of a function using Python.
f(x) = 2x + 3
import matplotlib.pyplot as plt x = range(-10, 11) y = [2 * x_coord + 3 for x_coord in x] plt.plot(x, y) plt.title('Graph of the function: f(x) = 2x + 3') plt.xlabel('x') plt.ylabel('2x + 3') plt.show()
null
Create a Python script that calculates the edit distance between two strings.
s1 = 'cat' s2 = 'cot'
# function to calculate edit distance def edit_distance(s1, s2): if len(s1) == 0: return len(s2) if len(s2) == 0: return len(s1) if s1[-1] == s2[-1]: cost = 0 else: cost = 1 res = min([edit_distance(s1[:-1], s2)+1, edit_distance(s1, s2[:-1])+1, edit_distance(s1[:-1], s2[:-1]) ...
null
Write a Python script that reads in a user-defined data set and prints the top-5 highest values contained in the data set.
[100.0, 74.0, 56.2, 45.5, 27.8, 21.0, 8.2, 4.1]
data = [100.0, 74.0, 56.2, 45.5, 27.8, 21.0, 8.2, 4.1] def get_top_five_values(data): sorted_data = sorted(data, reverse=True) top_five_values = sorted_data[:5] return top_five_values top_five_values = get_top_five_values(data) print(top_five_values)
null
Create a Python code to classify a given Iris flower as Iris setosa, Iris versicolor and Iris virginica.
[5.9, 3.0, 5.1, 1.8]
def classify_iris(flower): if flower[0] < 5 and flower[2] < 4: return 'Iris setosa' elif flower[2] >= 4.9 and flower[3] <= 1.8: return 'Iris virginica' else: return 'Iris versicolor'
null
Create a C++ algorithm to compute the Fibonacci sequence.
#include <iostream> int fibonacci(int n) { if (n <= 1) return n; return fibonacci(n - 1) + fibonacci(n - 2); } int main() { int n = 10; std::cout << "The Fibonacci number at position " << n << " is " << fibonacci(n); return 0; }
null
Write a JavaScript program that logs a message to the console.
"Hello!"
console.log("Hello!");
[EN Wikipedia] 1942 Egyptian parliamentary election Parliamentary elections were held in Egypt in March 1942. They were boycotted by the opposition, resulting in the ruling Wafd Party winning 240 of the 264 seats. Results References Egypt Parliamentary elections in Egypt Parliamentary Egypt Election and referendum art...
null
null
null
null
Write a Python program to detect if two strings are anagrams or not.
def is_anagram(word1, word2): word1 = word1.replace(' ', '').lower() word2 = word2.replace(' ', '').lower() if len(word1) != len(word2): return False count = {} for letter in word1: if letter in count: count[letter] += 1 else: count[letter] = 1 ...
[CS Wikipedia] Mechanika tekutin Mechanika tekutin (též mechanika kapalin a plynů) je část mechaniky, která se zabývá mechanickými vlastnostmi tekutin, tj. silami v kapalinách a plynech a pohybem kapalin a plynů (prouděním). Tekutiny (tedy kapaliny a plyny) se na rozdíl od pevných látek vyznačují tekutostí, tedy schop...
null
null
null
null
Write a Python script to traverse a directory and its subdirectories.
""" Write a Python script to traverse a directory and its subdirectories. """ import os def list_files(start_path): for root, dirs, files in os.walk(start_path): for name in files: print(os.path.join(root, name)) if __name__ == '__main__': start_path = '.' list_files(start_path)
null
Develop an algorithm to check if a string S is a palindrome in Python.
String S = "racecar"
def is_palindrome(s): # Convert strings to lowercase s = s.lower() # Iterate through middle of string with indices for i in range(len(s) // 2): if s[i] != s[len(s) - i - 1]: return False return True
null
Use the MySQL CREATE command to create a table of employees containing an employee ID, name, email address and phone number.
CREATE TABLE employees ( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, phone VARCHAR(20) NOT NULL, PRIMARY KEY (id) );
[CS Wikipedia] Vůz WRmee814 ČD {{DISPLAYTITLE:Vůz WRmee814 ČD}} Vozy WRmee814, číslované v intervalu 61 54 88-81, v 90. letech označené WRRm, jsou jídelní vozy z vozového parku Českých drah. Všechny tři vozy (016–018) vznikly v roce 1994 modernizací původních vozů WRRm v ŽOS České Velenice. Další modernizace vozů prob...
null
null
null
[CS Wikipedia] Burley Název Burley má více významů: Místa Burley (Hampshire) Burley (Leeds) Burley (Rutland) Burley (Shropshire) Burley (Idaho) Burley (Washington) Ostatní Burley (tabák) – jeden z typů zpracování tabáku Externí odkazy
null
null
null
null
Create a Python program that finds a given string in a sentence and capitalizes it.
Sentence: "I love the world" String to Find: "world"
def capitalize_string(text, string_to_find): index = text.find(string_to_find) if index != -1: capitalized_string = text[:index] + string_to_find.upper() + text[index+len(string_to_find):] return capitalized_string else: return text sentence = "I love the world" string_to_find = "wo...
[CS Wikipedia] Perzekuce kněží litoměřické diecéze Litoměřická diecéze patří k nejvíce sekularizovaným diecézím na světě. Už na začátku 20. století některé regiony patřily k nejvíce sekularizovaným, např. Mostecko. Dalším významnými faktory je odsun dvou třetin diecezanů německé národnosti a komunistická perzekuce. Od...
null
null
null
[EN Wikipedia] Mazahir Uloom Mazahir Uloom (also known as Mazahir Uloom Waqf) is an Islamic seminary located in Saharanpur, Uttar Pradesh. Started in November 1866 by Sa'ādat Ali Faqīh, and developed further by Mazhar Nanautawi and Ahmad Ali Saharanpuri; it is regarded as the second most influential and major Deobandi...
null
null
null
null
Create a function in Java for computing the factorial of a positive integer number.
public static long factorial(int n) { if (n == 0) { return 1; } long result = 1; for (int i = 1; i <= n; i++) { result *= i; } return result; }
null
Determine whether two given arrays are equal or not.
arr1 = [1, 2, 3] arr2 = [1, 2, 4]
The two arrays are not equal.
[DE Wikipedia] Bahnhofshalle Die Bahnhofshalle (auch Bahnhalle, Bahnsteighalle, Gleishalle oder Perronhalle) ist eine Halle, welche die Bahnsteige und Gleise eines Bahnhofs überdeckt und Eisenbahn-Nutzende und Besuchende sowie Reisende und Wartende vor allem gegen Witterungseinflüsse schützt, außerdem Begegnungen ermö...
null
null
null
[EN Wikipedia] Les Angles, Pyrénées-Orientales Les Angles (; , ) is a commune in the Pyrénées-Orientales department in southern France. Legend has it that at the beginning of the XIV century, the Black Death wiped out the entire population of the former village of Vallsera. Only two sisters survived, they are believed...
null
null
null
null
Show an example of a while loop in Python.
i = 0 while i < 10: print(i) i += 1
null
Write a Python function that takes a list of numbers as input, sorts them in ascending order, and returns a new list that includes the number of times each number occurred in the original list.
[2, 5, 2, 2, 1, 3, 5, 7, 2]
def sort_and_count(numbers): sorted_list = sorted(numbers) new_list = [] length = len(sorted_list) current_index = 0 while current_index < length: current_number = sorted_list[current_index] current_count = sorted_list.count(current_number) new_list.append((current_number, current_count)) for i in range(...
null
Output the sum of digits in a number.
n = 123
6
null
Write a Python function that creates a JSON response with fields for score and data. The data field should contain a message that varies depending on the score value. If the score is 0, the message should state "Try again". If the score is 1, the message should state "Well done".
score = 0
def create_response(score): if score == 0: message = "Try again" elif score == 1: message = "Well done" else: message = "" return {"score": score, "message": message}
[CS Wikipedia] Účinnost Účinnost může označovat: účinnost (fyzika) – fyzikální veličina světelná účinnost termodynamická účinnost účinnost (právo) – vlastnost právního předpisu Související články Účinek Efektivnost Externí odkazy
null
null
null
null
Create a Python script for encrypting and decrypting data using Advanced Encryption Standard (AES).
Not applicable
from Crypto.Cipher import AES def encrypt(plaintext, key): cipher = AES.new(key, AES.MODE_EAX) ciphertext = cipher.encrypt(plaintext) # Return a tuple containing the nonce and the cipher text return (cipher.nonce, ciphertext) def decrypt(nonce, ciphertext, key): cipher = AES.new(key, AES.MODE_EAX, nonce=nonce) ...
null
Convert the following list of URLs to strings without the protocol portions.
url_list = ['http://example.com/index', 'https://example.net/contact', 'http://example.org/about']
def convert_urls(url_list): return list(map(lambda x : x.split('://')[1] , url_list)) converted_urls = convert_urls(url_list) print(converted_urls) # Output: ['example.com/index', 'example.net/contact', 'example.org/about']
null
Modify the following code to display alter the existing function to accept an additional parameter.
def foo(a, b): return a + b
def foo(a, b, c): return a + b + c
null
Write a Python function to classify data points as low, medium and high according to the given threshold values.
threshold = [4, 6]
def classify(value, threshold): if value < threshold[0]: return 'low' elif threshold[0] <= value < threshold[1]: return 'medium' else: return 'high'
null
Create a function in Python which takes a string and an integer n as input and returns a string with the first n characters of the given string.
def get_first_n_chars(string, n): return string[:n]
[EN Wikipedia] Tinline River The Tinline River is a river of the Marlborough Region of New Zealand's South Island. It flows generally south from its sources at the northern end of the Bryant Range to reach the Pelorus River seven kilometres west of Pelorus Bridge. The river is named for John Tinline and commemorates t...
null
null
null
null
Create a simple mini-game using Python and Pygame. The game should allow the player to move an avatar around and score points by touching objects.
Not applicable
import pygame # Initialize the game engine pygame.init() # Define the colors black = ( 0, 0, 0) white = ( 255, 255, 255) # Set the height and width of the screen size = [700, 500] screen = pygame.display.set_mode(size) # Set the title of the window pygame.display.set_caption("My Game") # Create an empty array obje...
null
Generate a random 6-digit integer.
import random random_int = str(random.randint(100000, 999999))
null
Write a Python program to use a type hint to check if a variable is an instance of a particular class.
def check_type(variable, class_name): if isinstance(variable, class_name): print("It is an instance of the class") else: print("It is not an instance of the class")
null
Create a method that prints all elements of an array
[1,2,3]
def print_elements(arr): """ Print all elements of an array. """ for num in arr: print(num) arr = [1,2,3] print_elements(arr)
null
Rewrite the following function to use the modern function syntax in Javascript.
function greetUser(name) { console.log('Hello ' + name + '!'); }
const greetUser = (name) => console.log(`Hello ${name}!`);
null
Using HTML, render a link to an external site.
external_site = "https://www.example.com"
<a href="https://www.example.com" target="_blank">Visit External Site</a>
null
Generate a method in Python to sort a given list of dictionaries.
list_dict = [{'name': 'a', 'age': 23}, {'name': 'b', 'age': 19}, {'name': 'c','age': 36}]
def dict_sort(list_dict): sorted_dict = sorted(list_dict, key = lambda x: x['age']) return sorted_dict
[DE Wikipedia] Plaza de la Constitución Plaza de la Constitución ist der Name folgender Plätze: Plaza de la Constitución (Mexiko-Stadt), ein Platz in Mexiko-Stadt, Mexiko Plaza de la Constitución (Montevideo), ein Platz in Montevideo, Uruguay Plaza de la Constitución (Santiago de Chile), ein Platz in Santiago, Chile
null
null
null
null
Generate a function in Python to filter a given list and keep only the numeric items in the list.
input_list = [4, 2, 1, 15.6, 'p', 'y', 5.8]
def filter_numeric(input_list): num_list = [] for item in input_list: if type(item) == int or type(item) == float: num_list.append(item) return num_list input_list = [4, 2, 1, 15.6, 'p', 'y', 5.8] print(filter_numeric(input_list)) #Output: [4, 2, 1, 15.6, 5.8]
null
Convert a given list into a dictionary in Python
["apple", "banana", "cherry"]
dict = { "apple": 0, "banana": 1, "cherry": 2 }
[EN Wikipedia] WNKJ (FM) WNKJ is a Christian radio station licensed to Hopkinsville, Kentucky, broadcasting on 89.3 MHz FM. The station serves the areas of Hopkinsville, Kentucky, and Clarksville, Tennessee, and is owned by Pennyrile Christian Community, Inc. WNKJ's programming includes Christian talk and teaching sho...
null
null
null
null
Create a C program to read in a 3x3 matrix composed of integers, and print it.
Input Matrix: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
#include<stdio.h> int main() { int a[3][3], i, j; printf("Enter the elements of the 3x3 matrix : \n"); for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) scanf("%d", &a[i][j]); printf("The matrix is: \n"); for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) printf("%d ", a[i][j]); printf("\n"); } return 0; }
null
You need to find the area of a given circle with the formula: Area = pi * r * r
r = 5
const PI = 3.14; const r = 5; const area = PI * r * r; console.log(area);
null
Create an object-oriented Python program for a bank account with a balance, owner name, and methods for withdrawing, depositing and showing balance.
Not applicable
class BankAccount: def __init__(self, owner, balance=0.0): self.owner = owner self.balance = balance def deposit(self, amount): self.balance += amount return self.balance def withdraw(self, amount): if amount > self.balance: return 'Insufficient funds' self.balance -= amount return self.balance def sh...
null
Write a Java program to print out the first n prime numbers
public static void printPrimeNumbers(int n) { int num; int count=0; for (int i = 2; i <= n;) { num=0; for (int j = 2; j <= i / 2; j++) { if (i % j == 0) { num++; break; } } if (num == 0) { System.out.print(i+" "); count++; } i++; } }
[CS Wikipedia] Makati Makati , ) je město na Filipínách. Leží na ostrově Luzon, kde tvoří 1 z 16 měst národního centrálního regionu (NCR) - Metro Manila. Makati je spolu se sousedním městem Taguig finančním centrem Filipín, protože je zde velká koncentrace domácích i zahraničních firem. Má obyvatel. Sídlí zde muzeum h...
null
null
null
[HI Wikipedia] श्रीलंकाई रुपया रुपया (सिंहली: රුපියල්, तमिल: ரூபாய்), (प्रतीक: රු, Rs, SLRs / -; कोड: LKR), श्रीलंका की आधिकारिक मुद्रा है, जिसका विभाजन 100 सेंट में किया जाता है। श्रीलंकाई रुपये को श्रीलंका के केंद्रीय बैंक द्वारा जारी किया जाता है। इतिहास सन 1825 में सीलोन में सीलोनाई रिक्सडॉलर को हटाकर ब्रिटिश पाउं...
null
null
null
null
Write a Python function that takes in one argument and prints out the Fibonacci number for that argument.
def Fibonacci(x): if x == 0: return 0 elif x == 1: return 1 else: return Fibonacci(x-1)+Fibonacci(x-2) if __name__ == '__main__': print(Fibonacci(5)) # Output: 5
null
Write a code to display the current directory path in the terminal.
import os currdir = os.getcwd() print(currdir)
[DE Wikipedia] Hermann Bonitz Hermann Bonitz (* 29. Juli 1814 in Langensalza (Thüringen); † 25. Juli 1888 in Berlin) war ein Philologe, Philosoph und Schulreformer in Wien und Berlin. Leben Geboren als sechstes Kind des Pfarrers und Superintendenten Karl Friedrich Bonitz und seiner Mutter Maria Sophia Bonitz geb. Schm...
null
null
null
null
Write a Python program to display a list of all the prime numbers between a given range.
Not applicable
def prime_nums_in_range(start, end): prime_list = [] for num in range(start, end + 1): if num > 1: # check for cases greater than 1 for i in range(2, num): if (num % i) == 0: break else: prime_list.append(num) return prime_list start = 2 end = 20 print(prime_nums_in_range(start, end)) # Output: [...
null
Describe your approach to sorting a variety of data with a single sorting algorithm.
My approach to sorting a variety of data would involve using a single sorting algorithm. Depending on the type of data, I would select the most appropriate sorting algorithm which would involve understanding the complexity of the data and the type of sorting required. Generally, I would use quick sort or merge sort as ...
null
Create a for-loop in Python to loop through the items in a list and print their elements.
names = ['John', 'Kate', 'Mike', 'Alex']
for name in names: print(name)
null
Using the list as an example, remove all elements from the list that have a value of 0.
my_list = [0, 5, 7, 0, 9]
my_list = [5, 7, 9] my_list = [0, 5, 7, 0, 9] my_list = [x for x in my_list if x != 0] print(my_list)
[HI Wikipedia] कैण्टन स्विट्ज़रलैंड देश का कोई भी एक प्रान्त कैंटन कहलाता है। इसमें ज़्यादातर एक या दो बड़े शहरों के साथ कई कस्बे और गाँव शामिल होते हैं। हर कैण्टन की अपनी एक या दो राजभाषाएं होती हैं। कैण्टन कैण्टन
null
null
null
null
Write a SQL query to count the number of records with a field of "user_id" in the table called "users".
SELECT COUNT(*) as count_user_id FROM users;
null
Write a ruby program to merge two sorted arrays in to one sorted array.
arr1: [1, 4, 6] arr2: [2, 3, 7]
def mergeSortedArrays(arr1, arr2) arr3 = arr1 + arr2 arr3.sort! return arr3 end
null
Analyze and improve the following basic shell script.
#!/bin/bash # simple bash script echo "Hello World"
#!/bin/bash # Simple bash script # Store name in a variable name="World" # Print message echo "Hello $name"
[HI Wikipedia] रोमानिया रोमानिया (;प्राचीन: Rumania (रूमानिया), Roumania (रौमानिया) ;) काले सागर की सीमा पर, कर्पेथियन चाप के बाहर और इसके भीतर, निचले डेन्यूब पर, बाल्कन प्रायद्वीप के उत्तर में, दक्षिणपूर्वी और मध्य यूरोप में स्थित एक देश है. लगभग पूरा डेन्यूब डेल्टा इसी क्षेत्र के भीतर स्थित है। इसकी सीमा पश्चिम में ...
null
null
null
null
Write a Java program to print binary numbers from 0 to 15.
public class Binary { public static void main(String[] args) { for (int i = 0; i <= 15; i++) { System.out.println(Integer.toBinaryString(i)); } } }
[DE Wikipedia] Slieve Gullion Der Slieve Gullion (englisch) oder Sliabh gCuillinn (irisch), , ist ein erloschener Vulkan im „Ó Fiaich Country“ im Süden der Grafschaft Armagh in Nordirland. Das Landschaftsschutzgebiet „Slieve Gullion Forest Park“ (Area of Outstanding Natural Beauty – AONB) mit ausgedehnten Heideflächen...
null
null
null
null
Write a python script to sort the given array
[10, 15, 7, 8, 12]
arr = [10, 15, 7, 8, 12] arr.sort() print(arr)
null
Implement an algorithm in Python to sort a list of integers.
List: [3, 9, 8, 5, 6, 4, 2, 1, 10, 7]
def sort(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] list = [3, 9, 8, 5, 6, 4, 2, 1, 10, 7] sort(list) print(list) # [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[EN Wikipedia] 1969 Motor Trend 500 The 1969 Motor Trend 500 was a NASCAR Grand National Series event that was held on February 1, 1969, at Riverside International Raceway in Riverside, California. The transition to purpose-built racecars began in the early 1960s and occurred gradually over that decade. Changes made t...
null
null
null
null
Create a Python function to convert a temperature from Fahrenheit to Celsius.
def fahrenheit_to_celsius(fahrenheit): celsius = (fahrenheit - 32) * 5.0/9.0 return celsius
null
Convert the following equation into a Python program: y = x^2 - 3x + 2
def equation(x): return (x**2 - 3*x + 2)
null
You need to write a Python program to convert a decimal number into its binary equivalent.
num = 8
def get_binary(num): return bin(num)[2:] res = get_binary(num) print(res)
null
Create a JavaScript function to check if an integer n is a perfect square.
function isPerfectSquare(n) { for (int i = 0; i <= n; i++) { if (i * i == n) { return true; } } return false; }
null
Create a SQL query to retrieve the name, address and contact number of the customers with the highest spending record.
SELECT name, address, contact_number FROM customers ORDER BY spending DESC LIMIT 1;
null
You need to code a program that prints the absolute difference between two numbers.
15 and 10
def difference(num1, num2): return abs(num1 - num2)
[CS Wikipedia] Slovenská hokejbalová reprezentace Slovenská hokejbalová reprezentace je výběrem nejlepších slovenských hráčů v hokejbale. Od roku 1996 se účastní mistrovství světa a do roku 2000 hrálo i mistrovství Evropy. Tým je řízen Slovenskou hokejbalovou únií, která je členem ISBHF. Největším úspěchem slovenského...
null
null
null
null
Write a SQL query to update the value of column b in the table called a.
Table name: a Columns: a, b Current state of table a: a | b 1 | 10 2 | 11 3 | 12
UPDATE a SET b = 20 WHERE a = 3;
null
Edit the given HTML so that it renders as a centered, level-two heading.
<h1>Heading Text</h1>
<h2 style="text-align: center;">Heading Text</h2>