text
stringlengths
141
2.89k
⌀
instruction
stringlengths
19
1.5k
⌀
input
stringlengths
0
800
⌀
output
stringlengths
1
2.5k
⌀
[DE Wikipedia] Paul Pigorsch Paul Pigorsch (* 11. September 1991 in Torgau) ist ein deutscher Sportschütze im Wurfscheibenschießen in der Disziplin Trap. Leben und Karriere Pigorsch kam durch seinem Vater zum Schießsport und schoss zunächst Laufende Scheibe, wechselte aber dann zum Flintenschießen. Mit 15 Jahren start...
null
null
null
null
Create a python script that sorts a list of tuples based on the second element.
tuples = [('a',3), ('d', 1), ('c', 2)]
sortedTuples = sorted(tuples, key = lambda x: x[1])
null
Generate a Python function that takes a number less than 1000 and returns it written in words.
213
def num2words(number): ones = ["", "one ","two ", "three ", "four ", "five ", "six ", "seven ", "eight ", "nine ", "ten ", "eleven ", "twelve ", "thirteen ", "fourteen ", "fifteen ", "sixteen ", "seventeen ", "eighteen ", "nineteen "] tens = [""...
[DE Wikipedia] Wladimir Kudrjawzew Wladimir Kudrjawzew (auch Vladimir Kudryavtsev, , * um 1965) ist ein russischer Rock-, Jazz- und Improvisationsmusiker (Kontrabass, Komposition). Leben und Wirken Kudryavtsev spielte in Russland in den späten 1980er-Jahren in der Jazzband Ars Nova (Forgotten Gifts, u. a. mit Mikhail ...
null
null
null
null
Write a function in Python that takes a string and determines the longest palindrome in it.
itsracecarthatmadethetoot
def longestPalindrome(s): n = len(s) table = [[0 for x in range(n)] for y in range(n)] # All substrings of length 1 are palindromes maxLength = 1 i = 0 while (i < n): table[i][i] = True i = i + 1 # check for substring of length 2. start = 0 i = 0 while ...
[CS Wikipedia] Škoda 633 Škoda 633 byl osobní automobil vyráběný automobilkou Škoda. Výroba začala v roce 1931 a ukončena byla roku 1934. Vyrobilo se 504 kusů. Motor byl vodou chlazený vpředu uložený řadový šestiválec SV o objemu 1792 cm³. Měl výkon 24 kW (33 koní) a vůz s ním dosahoval rychlosti okolo 100 km/h. Exter...
null
null
null
null
Form an if-else condition that prints “This is an even number” if a number is even and “This is an odd number” if the number is odd
number = 5
if (number % 2 == 0): print("This is an even number") else: print("This is an odd number")
null
Find the latitude and longitude of an input address.
address = "1600 Amphitheatre Parkway, Mountain View, CA"
import geocoder g = geocoder.google(address) print("Latitude: " + str(g.latlng[0])) print("Longitude: " + str(g.latlng[1]))
null
Write a function in Python to find the power of a given number n using an iterative approach.
def power_iterative(n, exponent): # First, set an initial product value product = 1 # Iterate up to the desired power for _ in range(exponent): product *= n # Return the product return product power = power_iterative(3, 4) print(power)
null
Write an if-else statement in Java that checks if a given number is divisible by 3 and prints "Divisible by 3" if true, otherwise "Not divisible".
if (num % 3 == 0) { System.out.println("Divisible by 3"); } else { System.out.println("Not divisible"); }
null
Given a list of numbers, sort them from smallest to largest.
lst = [3, 5, 2, 6, 8, 1]
lst.sort()
null
Write a Python program that web-scrapes data from a website and stores it in a structured format (e.g. JSON, CSV).
Example Website: https://example.com
import requests import json # Make a get request to get the data response = requests.get('https://example.com') # Store the data in a structured format data = json.loads(response.text) # Save the data to a json file with open('example.json', 'w') as f: json.dump(data, f)
null
Write a code to implement Selection Sort in Java
public class SelectionSort { public static void sort(int[] arr) { int n = arr.length; // One by one move boundary of unsorted subarray for (int i = 0; i < n-1; i++) { // Find the minimum element in unsorted array int min_idx = i; for (int j = i+1; j < n; j++) if (arr[j] < arr[min_idx]) min_idx = j; // Swap the found mi...
null
Develop a lightweight AI model to classify and categorize text.
A lightweight AI model can be developed using programming languages such as Python, JavaScript, etc. It will contain code to process text data, extract features, apply a suitable machine learning algorithm and train a model to classify and categorize text.
null
Create a method in Java to return the largest of three numbers.
public static int max(int num1, int num2, int num3) { int max = num1; if (num2 > max) { max = num2; } if (num3 > max) { max = num3; } return max; }
null
Suggest a solution for validating a password which should contain at least 1 uppercase character, 1 lowercase character and 1 digit.
We can use a regular expression to validate a password. A regular expression to validate a password with at least 1 uppercase character, 1 lowercase character and 1 digit should be: ^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+$ If the password matches the regular expression, the password is valid. Otherwise, the password is inval...
null
Use a recursive algorithm in Python to calculate the sum of a given array.
array1 = [1, 2, 3, 4, 5]
def array_sum(arr): if len(arr) == 1: return arr[0] else: return arr[0] + array_sum(arr[1:]) #Driver code print(array_sum(array1)) #prints 15
null
Replace the "TODO" with the appropriate code for implementing a binary search algorithm in Python.
# TODO
def binarySearch(arr, target): low = 0 high = len(arr) - 1 while low <= high: mid = (low + high) // 2 if arr[mid] == target: return mid elif arr[mid] < target: low = mid + 1 else: high = mid - 1 return -1
null
Optimize a Flask application for efficient performance.
Not applicable
from flask import Flask, request, jsonify app = Flask(__name__) @app.route('/api/<endpoint>', methods=['GET', 'POST']) def process_request(endpoint): # Performance optimization # Use Redis for caching session and query performance # Use uWSGI for Python applications # Use gunicorn as WSGI server #...
null
Write a Python program to randomly select an item from a list.
list_of_names = ["John", "Anna", "Bill", "Kim", "Claire"]
import random list_of_names = ["John", "Anna", "Bill", "Kim", "Claire"] random_name = random.choice(list_of_names) print(f'Randomly selected name from the list: {random_name}')
[EN Wikipedia] Ştefan Kroner Ştefan Kroner (born 30 May 1939) is a Romanian water polo player. He competed at the 1960 Summer Olympics and the 1964 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 Olympic...
null
null
null
null
What is the main idea behind Naive Bayes Model?
The main idea behind Naive Bayes Model is to use the probability of each data point to make a prediction by calculating the probability of a certain outcome given some prior knowledge. It assumes all the features are independent of each other and uses the Bayes theorem to calculate the probability of a given class base...
null
Define a class named "Day" in Python to represent a day of the week.
class Day: def __init__(self): self.day = "" def set_day(self, day): self.day = day def get_day(self): return self.day
null
Construct a program to find the result of the following equation
(x-1)^2
def equation(x): return (x-1)**2
[HI Wikipedia] जिब्राल्टर लिबरल पार्टी जिब्राल्टर लिबरल पार्टी (), जिसका संक्षिप्तकरण अंग्रेज़ी वर्णमाला के तीन अक्षरों जीएलपी के साथ किया जाता है, ब्रिटिश प्रवासी शासित प्रदेश जिब्राल्टर का एक मुख्य राजनीतिक दल है। पार्टी की मुख्य विचारधारा उदारतावाद है। 2011 के आम चुनाव में पार्टी ने जिब्राल्टर संसद की तीन सीटें जीत...
null
null
null
[EN Wikipedia] Nonnie & Alex Nonnie & Alex is a 1995 short film that Todd Field directed while a fellow at the AFI Conservatory. It was filmed in Ferndale, California. This short film is a dramatic piece about two eight-year-old children, a girl (Nonnie) and boy (her friend, Alex) who are left to their own devices in ...
null
null
null
[CS Wikipedia] Alžběta Trojanová Alžběta Trojanová (* 16. ledna 1987 Praha) je česká publicistka a moderátorka zaměřující se na problematiku počítačových her. Bývá označována za Královnu české herní žurnalistiky (toto označení vzniklo náhodou při interview pro online magazín, kde Trojanová sama sebe v nadsázce označil...
null
null
null
null
Develop an HTML/CSS layout with 2 columns and a 2-row header.
<div class="container"> <div class="header"> <div class="row1">Row1</div> <div class="row2">Row2</div> </div> <div class="main"> <div class="column1">Column1</div> <div class="column2">Column2</div> </div> </div>
null
Develop a Python script that connects to a MySQL database to retrieve certain data information.
""" Develop a Python script that connects to a MySQL database to retrieve certain data information """ import pymysql # Establish a connection to a MySQL database conn = pymysql.connect( host='localhost', user='username', password='password', db='dbname', charset='utf8mb4', cursorclass=pym...
null
How can you access elements in a multi-dimensional array in JavaScript?
Accesing elements of the array can be done by using the index of the array. For example, for a two-dimensional array, the elements can be accessed using the following syntax: array[i][j], where i is the index of the outer array, and j is the index of the inner array. For a three-dimensional array, the syntax would be a...
null
Suggest a way to generate a random series of characters with a given length in Python.
import random import string def generate_random_string(target_length): chars = string.ascii_letters + string.digits return ''.join(random.choice(chars) for _ in range(target_length))
null
Write some HTML code to create a list of items.
<ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> <li>Item 4</li> <li>Item 5</li> </ul>
null
Calculate the mean, median and mode for the given set of numbers.
130, 160, 140, 160, 160
The mean is: 149.4 The median is: 160 The mode is: 160
[DE Wikipedia] Arthur Guinness Arthur Guinness (* 24. September 1725 in Celbridge, Irland; † 23. Januar 1803 in Dublin) war ein irischer Bierbrauer und Begründer der Biermarke Guinness. Arthurs Vater war Landverwalter für Arthur Price, den anglikanischen Erzbischof von Cashel, und braute in dieser Eigenschaft Bier für...
null
null
null
null
Can you provide a Python program to generate a random integer within the range of 1 to 100?
import random def random_int_between_1_and_100(): return random.randint(1, 100)
null
Create a function that takes an integer n as an argument and returns the sum of all numbers from 1 to n.
n = 10
def sum_to_n(n): total = 0 for i in range(1, n + 1): total += i return total
null
Generate an HTML content in Python which contains a text input field, submit button and a paragraph to display the results.
<!DOCTYPE html> <html> <head> <title>Input Form</title> <script> function handleFormResult() { let inputField = document.getElementById('input_field'); let resultField = document.getElementById('result_field'); resultField.innerText = inputField.value; } <...
null
Write a code to calculate the age in years and months given the date of birth.
Date of Birth: 4 June 1998
def age_calc(date_of_birth): """ This function takes in a date of birth and calculates the age in years and months. """ today = datetime.date.today() age_years = today.year - date_of_birth.year age_months = today.month - date_of_birth.month if age_months < 0: age_years -= 1 age_months += 12 return age_years, age_months...
null
Create a Pie Chart in Python with the following data
Item Frequency Pen 4 Pencil 9 Eraser 3
import matplotlib.pyplot as plt items = ['Pen', 'Pencil', 'Eraser'] frequencies = [4, 9, 3] plt.pie(frequencies, labels=items, autopct='%1.1f%%', shadow=True, startangle=90) plt.axis('equal') plt.show()
null
Write Python code to implement the Quick Sort algorithm.
[10, 7, 8, 9, 1, 5]
def partition(arr,p,r): x = arr[r] i = p - 1 for j in range(p, r): if arr[j] <= x: i = i + 1 arr[i], arr[j] = arr[j], arr[i] arr[i + 1], arr[r] = arr[r], arr[i+1] return i + 1 def quick_sort(arr,p,r): if p < r: q = partition(arr,p,r) quick_sort(a...
null
How would you solve the following problem: Given a list of numbers, find the two numbers that add up to a given sum?
[3, 6, 2, 8, 4], sum = 10
def find_sum(arr, num): found = False arr_set = set(arr) for i in arr_set: x = num - i if x in arr_set and x != i: # make sure the numbers aren't the same found = True return i, x if not found: return False
[EN Wikipedia] Phra Khanong Phra Khanong may refer to: Phra Khanong area, the neighbourhood in Bangkok usually referred to by the name Phra Khanong Phra Khanong Subdistrict in Khlong Toei District, Bangkok, which covers part of the area Phra Khanong Nuea Subdistrict in Watthana District, Bangkok, which covers part of ...
null
null
null
null
Write a code to check if two rectangles overlap with each other.
rect1 = (0,0,10,10) rect2 = (8,8,12,12)
def check_overlap(rect1, rect2): x1, y1, w1, h1 = rect1 x2, y2, w2, h2 = rect2 x_overlap = max(0, min(x1 + w1, x2 + w2) - max(x1, x2)) y_overlap = max(0, min(y1 + h1, y2 + h2) - max(y1, y2)) overlap_area = x_overlap * y_overlap return (overlap_area > 0)
null
Implement a sorting algorithm in Python that sorts a given array of numbers in descending order.
[2, 5, 7, 3, 1, 8]
def sort_descending(list): sorted_list = sorted(list, reverse=True) return sorted_list
null
Write a Python program that takes a string and a number as input, and returns the string repeated the given number of times.
String: xyz Number: 3
def repeatString(string, num): return string * num result = repeatString("xyz", 3) print(result)
[CS Wikipedia] Basin Basin je francouzský středověký hrdinský epos ze 13. století, jeden z tzv. chansons de geste. Vypráví o mládí Karla Velikého, a proto patří do Karolínského (královského) cyklu. Epos se nedochoval, jeho děj je znám z norského prozaického zpracování Karlamagnús saga. Obsah písně Píseň úzce souvisí s...
null
null
null
null
Edit the existing Python program to append a new record with data programmatically.
people = [ {"name": "Alice", "age": 8}, {"name": "Bob", "age": 11}, {"name": "Charlie", "age": 13}, ]
people = [ {"name": "Alice", "age": 8}, {"name": "Bob", "age": 11}, {"name": "Charlie", "age": 13}, {"name": "John", "age": 15}, ] # Append a new record with data programmatically: record = {"name": "John", "age": 15} people.append(record)
[HI Wikipedia] फूलन देवी फूलन देवी (10 अगस्त 1963 - 25 जुलाई 2001) बागी से सांसद बनी एक भारत की एक राजनेता थीं। एक निम्न वर्ग में उनका जन्म उत्तर प्रदेश के एक छोटे से गाँव गोरहा का पूर्वा में एक मल्लाह के घर हुआ था। 1994 में, समाजवादी पार्टी के मुलायम सिंह यादव के नेतृत्व वाली राज्य सरकार ने उनके खिलाफ सभी आरोपों को स...
null
null
null
null
Create a Python program to find the total number of vowels and consonants in a given set of words.
"Hello World"
def count_letters(sentence): """ Count the number of vowels and consonants in the given sentence. @param sentence: str @return: tuple """ vowels = 0 consonants = 0 for char in sentence: if char.lower() in "aeiou": vowels += 1 elif char.isalpha(): ...
[HI Wikipedia] गजानन दिगंबर माडगूलकर गजानन दिगंबर माडगूळकर (1 अक्टूबर 1919 – 14 दिसम्बर 1977) मराठी के प्रमुख कवि, गीतकार, लेखक तथा अभिनेता थे। महाराष्ट्र में वे अपने नाम के आद्यक्षरों 'गदिमा' से ही अधिक जाने जाते हैं। मराठी संस्कृति के लिए उनका योगदान मात्रा और गुणवत्ता दोनो दृष्टियों से बहुत अधिक है। इन्हें भी देखें...
null
null
null
null
Generate a SQL query that selects all the fruit names from a table.
SELECT fruit_name FROM fruits_table;
null
Write a code to find out if a given number is prime in JavaScript.
number = 29
function isPrime(number) { for (i=2; i <= Math.sqrt(number); i++) { if (number % i == 0) { return false; } } return true; } let number = 29 console.log(isPrime(number))
null
Create a new array in JavaScript containing only even numbers from the given input array.
Array: [3,7,10,6,23]
let evenArray = [3,7,10,6,23].filter(num => num % 2 == 0); //evenArray: [10,6]
[HI Wikipedia] तिलका माँझी तिलका माँझी, (संथाल:ᱵᱟᱵᱟ ᱛᱤᱞᱠᱟᱹ ᱢᱟᱡᱷᱤ) (11 फ़रवरी 1750 - 13 जनवरी 1785) तिलका मांझी उर्फ जबरा पहाड़िया जिन्होंने राजमहल, झारखंड की पहाड़ियों पर ब्रिटिश हुकूमत से लोहा लिया। इनमें सबसे लोकप्रिय तिलका मांझी हैं। परिचय जबरा पहाड़िया (तिलका मांझी) भारत में ब्रिटिश सत्ता को चुनौती देने वाले पहाड़...
null
null
null
[DE Wikipedia] Sportpalastrede Als Sportpalastrede wird die Rede bezeichnet, die der nationalsozialistische deutsche Reichspropagandaminister Joseph Goebbels am 18. Februar 1943 im Berliner Sportpalast hielt und in der er zur Intensivierung des „totalen Krieges“ aufrief. Die knapp 108 Minuten dauernde Rede gilt als ei...
null
null
null
null
Write a PHP script to display the system environment variables.
<?php $env_vars = array_keys($_ENV); foreach ($env_vars as $variable) { echo $variable . " = " . $_ENV[$variable] . "<br>"; } ?>
null
Write a loop in C++ to print out a list of numbers from 1 to 100.
#include <iostream> int main() { for(int i = 1; i <= 100; i++) { std::cout << i << ' '; } return 0; }
null
Write a macro in C++ that prints half of the cube of a number
#include <iostream> #define CUBE(x) ((x)*(x)*(x)) #define HALF_CUBE(x) ( (CUBE(x) )/2 ) int main() { int x = 3; std::cout << HALF_CUBE(x) << std::endl; return 0; }
[EN Wikipedia] Astronomer An astronomer is a scientist in the field of astronomy who focuses their studies on a specific question or field outside the scope of Earth. They observe astronomical objects such as stars, planets, moons, comets and galaxies – in either observational (by analyzing the data) or theoretical as...
null
null
null
[EN Wikipedia] Rose Fitzpatrick Rose Mary Fitzpatrick (born c. 1960) is a retired British police officer. Fitzpatrick was born in London and began her career in the City. In 1987, at the age of 27, she joined the City of London Police as a constable and rose through the uniformed ranks to the rank of chief inspector. ...
null
null
null
null
You need to write a Python program for computing the factorial of a number.
5
def factorial(num): if num == 0: return 1 else: return num * factorial(num - 1) print(factorial(5))
null
Create an algorithm to check if a sentence is a palindrome in Python.
Sentence: "Rise to vote, Sir"
def is_sentence_palindrome(sentence): sentence = sentence.lower().replace(" ", "") return sentence == sentence[::-1] is_sentence_palindrome("Rise to vote, Sir") # False
null
Construct a simple web page with two fields, a login input and a password input.
<html> <body> <form> <div> <label>Login:</label> <input type="text" id="login" name="login"> </div> <div> <label>Password:</label> <input type="password" id="password" name="password"> </div> </form> </body> </html>
null
Develop a python program which can generate a random array of integers
import random def get_random_array(max_size): arr = [] for _ in range(random.randint(0, max_size)): arr.append(random.randint(0, max_size)) return arr
[CS Wikipedia] První vláda Lubomíra Štrougala První vláda Lubomíra Štrougala existovala v období 28. ledna 1970 do 9. prosince 1971, de facto se však jednalo o pokračování vlády, jmenované 29. září 1969, původně v čele s Oldřichem Černíkem. Seznam členů vlády Předseda vlády: Lubomír Štrougal Místopředseda vlády: Josef...
null
null
null
null
Generate random numbers 0 to 1000.
import random for i in range(10): print(random.randint(0, 1000))
null
Create a Python script to print out the multiplication table for the given number.
4
def printMultTable(n): for i in range(1, 11): print(n, 'x', i, '=', n*i) printMultTable(4)
null
Construct a JavaScript program to find all the prime numbers within a range of numbers
range = [2,10]
function findPrimes(range) { let primes = []; for (let i=range[0]; i< range[1]; i++) { if (checkPrime(i)) { primes.push(i); } } return primes; } function checkPrime(num) { for (let i=2; i<=Math.sqrt(num); i++) { if (num % i == 0) { return false; } } return true; }
null
Develop a Python program to print the digits of a given integer in reverse order.
123
""" Python script to print the digits of a given integer in reverse order """ num = int(input('Enter an integer: ')) # Initializing the variable to hold the reversed digits reverse = 0 while (num > 0): # Extracting the last digit remainder = num % 10 # Multiplying the reverse variable by 10 and adding ...
null
Design a program to find the occurrence of a given character in a given string.
Given string: "Hello World!" Character to find: o
def occurance_count(str, char): count = 0 for c in str: if c == char: count += 1 return count
[HI Wikipedia] बिड़ोदी छोटी बिड़ोदी छोटी या बिड़ोदी छोट्टी, भारतीय राज्य राजस्थान के सीकर जिले की लक्ष्मणगढ़ तहसील का एक गाँव है। जिसे स्वामी की बिड़ोदी के नाम से जाना जाता है, गाँव २५० वर्ष पुराना है और लक्ष्मणगढ़ से १८ किलोमीटर (११ मील) पूर्व में और नवलगढ से २.५ किलोमीटर (१.९ मील) पश्चिम में स्थित है। बिड़ोदी छोटी क...
null
null
null
null
Generate a code in Python for validating a given password
Minimum length of 8 characters and must contain at least 1 uppercase letter, 1 lowercase letter, 1 special character and 1 number
import re def validate_password(passwd): Rule = re.compile(r"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!#%*?&]{8,}$") return Rule.search(passwd)
null
Write a Python program to add two numbers in base-10.
num1 = 6, num2 = 8
def add_base10(num1, num2): return num1 + num2
[CS Wikipedia] Římskokatolická farnost Trhové Sviny Římskokatolická farnost Trhové Sviny 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 Trhové Sviny jsou prvně písemně doloženy v roce 1260, kdy zde zřejmě již byla duchovní správa. Mí...
null
null
null
[HI Wikipedia] जेफ बेनेट जेफरी ग्लेन "जेफ" बेनेट (अंग्रेजी: Jeffrey Glenn "Jeff" Bennett) या जेफ बेनेट (अंग्रेजी: Jeff Bennett) (जन्म २ अक्टूबर, १९६२) है एक अमेरिकी आवाज अभिनेता और गायक। वह सबसे अच्छा के रूप में जाना जाता है: की आवाज जॉनी ब्रेवो एक ही नाम का उपयोग करते हुए एक आवाज है कि एल्विस प्रेस्ली की तरह लग रहा थ...
null
null
null
null
Generate a script in python to split a given string into words and store them in a list.
str = "This is a great day"
def split_str(str): words = str.split(" ") return words
null
Generate a Python script to produce a 2D visualization of a given data set.
The data set contains 3 attributes: age, sex and income.
import matplotlib.pyplot as plt # define data age = [15, 17, 20, 22, 25, 28, 33, 35, 37, 45, 50] sex = ["female","male","male","female","female","male","female","male","male","female","female"] income = [20000, 24000, 25000, 27000, 28000, 26000, 29000, 33000, 31000, 50000, 52000] # create figure for pl...
null
How would you go about sorting a million numbers in memory?
A common approach would be to use an efficient sorting algorithm, such as Quicksort, Merge Sort, or Heapsort. These algorithms typically take time proportional to n log n, where n is the number of elements being sorted.
[EN Wikipedia] CY Cergy Paris University CY Cergy Paris University (French: CY Cergy Paris Université) is a public university located in Cergy-Pontoise, France. It was officially announced in October 2019 by the décret that the university would be founded by combining other institutions on 1 January 2020. The official...
null
null
null
[DE Wikipedia] Bešeňová Bešeňová () ist eine Gemeinde in der Nordslowakei. Sie liegt im Liptauer Kessel an der Waag, etwa zwölf Kilometer von Ružomberok entfernt. Der Ort wurde 1279 erstmals schriftlich erwähnt. Die westlich gelegene Ansiedlung Mitošiny wurde nach 1863 eingemeindet. Kultur Weblinks Ort in der Slowakei...
null
null
null
null
Create a Python program to filter out words containing five characters or less from a list of words.
["Hello", "Good", "Where", "Been", "World", "House"]
# Function to filter out words containing five characters or less def filterWords(arr): result = [word for word in arr if len(word) > 5] return result # Get the input arr = ["Hello", "Good", "Where", "Been", "World", "House"] # Call the function result = filterWords(arr) # Print the result print("Filtered li...
null
Generate a 5-dimensional array using the numpy library
import numpy as np arr = np.zeros((5,5,5,5,5))
[DE Wikipedia] Rajapalayam (Stadt) Rajapalayam ist eine Stadt im indischen Bundesstaat Tamil Nadu. Die Stadt ist der Hauptort des Distrikt Virudhunagar. Rajapalayam hat den Status einer Municipality. Die Stadt ist in 42 Wards gegliedert. Die Hunderasse Rajapalayam stammt aus der Stadt. Geschichte Rajapalayams Einwohne...
null
null
null
null
Create a Python program to convert a string to its equivalent unicode value.
"hello"
import unicodedata #example string s = "hello" #printing string to unicode print("The unicode value of '" + s + "' is: " + str(ord(unicodedata.normalize('NFKD', s)[0]))) #output #The unicode value of 'hello' is: 104
null
Create a Java class named "MyClass" with three methods - getName(), setName(), and displayName().
public class MyClass { private String name; // constructor public MyClass(String name) { this.name = name; } // getName public String getName() { return this.name; } // setName public void setName(String name) { this.name = name; } // displayName public void displayName() { System.out.println("Name is: " + this.name); ...
null
Sort the list in Ascending order of the second element of each element in the list.
list = [(-5, 2), (1, 0), (1, 3), (3, 4), (-3, -9), (-10, -2)]
sorted_list = sorted(list, key=lambda x: x[1]) print(sorted_list) # Output: [(-3, -9), (1, 0), (-10, -2), (-5, 2), (1, 3), (3, 4)]
null
Code a for loop in Java to find the maximum value in an array
int[] arr = {2,5,3,7,1};
int max = arr[0]; for (int i = 0; i < arr.length; i++) { if (arr[i] > max) { max = arr[i]; } }
null
Make a program in Python to find the most frequently visited page in a given dataset
logs = ['/index.php', '/home.php', '/about.php', '/contact.php', '/index.php']
def most_visited_page(logs): # Initiliaze a dictionary to store counts pages = {} # Iterate through the logs and count the number of visits for page in logs: if page in pages: pages[page] += 1 else: pages[page] = 1 # Find the page with the highest nu...
null
Write an SQL query to return the top three highest-scoring players from a table 'scores'.
SELECT player_name FROM scores ORDER BY score DESC LIMIT 3;
null
Develop an algorithm to find the value of n where n is the index of the Fibonacci sequence.
def nth_fibonacci_number(n): """Find the value of n where n is the index of the Fibonacci Sequence.""" if n < 2: return n elif n == 2: return 1 else: return nth_fibonacci_number(n-1) + nth_fibonacci_number(n-2)
null
Write a line of code to display a text message in the console saying "Hello world!".
console.log("Hello world!");
null
Explain the difference between unidirectional and bidirectional recurrent neural networks.
A unidirectional recurrent neural network (RNN) accepts a single input and produces a single output. The input sequence is processed one step at a time and the output of each step depends only on the current input and the weights of the network. This type of network is often used in language models and other sequence-b...
null
Suggest a completion for achieving the following without using a `for` loop.
my_list = [1, 2, 3] # Do something
my_list = [1, 2, 3] result = list(map(lambda x: x ** 2, my_list))
null
Write a Python script to generate a basic HTML page with a title, header, body, and footer sections.
The page title: Sample Page
<html> <head> <title>Sample Page</title> </head> <body> <h1>Sample Page</h1> <p>This page has a header, a body, and a footer.</p> <footer> <p>This is the footer.</p> </footer> </body> </html>
null
Create a Java program that calculates the probability of rolling a pair of dice and getting the number 8.
public static double calculateProbability(int target) { int numFavorableOutcomes = 0; int numTotalOutcomes = 36; for (int i = 1; i <=6; i++) { for (int j = 1; j <= 6; j++) { if (i + j == target) { numFavorableOutcomes++; } } } return (double) numFavorableOutcomes/numTotalOutcomes; }
[EN Wikipedia] Blue-moustached bee-eater The blue-moustached bee-eater (Merops mentalis) is a species of bird in the family Meropidae. It is found in submontane and upland habitats in Cameroon, Ivory Coast, Equatorial Guinea, Ghana, Guinea, Liberia, Nigeria, and Sierra Leone. The blue-moustached bee-eater is a rainfor...
null
null
null
[HI Wikipedia] अहुरा मज़्दा अहुर मज़्दा या असुर महत अवस्ताई भाषा में प्राचीन ईरानी पंथ के एक देवता का नाम है जिन्हें पारसी पंथ के संस्थापक ज़रथुश्त्र ने अजन्मा और सर्वज्ञ परमेश्वर बताया था। इसके अलावा इनके लिए ओह्रमज़्द, होउरमज़्द, हुरमुज़, अरमज़्द और अज़्ज़न्दारा नाम भी प्रयोग किये जाते हैं। वे पारसी पंथ के सर्वोच्च ...
null
null
null
null
Check if an element is present in a list.
lst = [1, 2, 3, 4] element = 5
def is_element_in_list(lst, element): return element in lst if __name__ == '__main__': lst = [1, 2, 3, 4] element = 5 print(is_element_in_list(lst, element))
[DE Wikipedia] Shackleton-Schelfeis Das Shackleton-Schelfeis () ist ein großes Schelfeis an der Queen-Mary-Küste und der Knoxküste des Antarktischen Kontinents mit einer Länge von 384 km und einer Fläche von 33.820 km². Im Shackleton-Schelfeis liegen einige Inseln, von denen die Mill-Insel und die Masson-Insel die grö...
null
null
null
[EN Wikipedia] 1997 British National Track Championships The 1997 British National Track Championships were a series of track cycling competitions held from 18 to 26 July 1997 at the Manchester Velodrome. The Championships were organised by the British Cycling Federation. Medal summary Men's Events Women's Events Refe...
null
null
null