text stringlengths 141 2.89k ⌀ | instruction stringlengths 19 1.5k ⌀ | input stringlengths 0 800 ⌀ | output stringlengths 1 2.5k ⌀ |
|---|---|---|---|
null | Compose a program to reverse a list of numbers | def reverse_nums(num_list): n = len(num_list) for i in range(n//2): num_list[i], num_list[n-i-1] = num_list[n-i-1], num_list[i] return num_list | |
[DE Wikipedia] Olympische Winterspiele 2022/Eisschnelllauf – 3000 m (Frauen)
Die 3000 m im Eisschnelllauf der Frauen bei den Olympischen Winterspielen 2022 wurden am 5. Februar in der Nationalen Eisschnelllaufhalle in Peking ausgetragen. Für Claudia Pechstein war es die achte Teilnahme an Olympischen Winterspielen. Si... | null | null | null |
null | Softmax a list of numbers and then sum the output. | [1, 2, 3] | def softmax(arr): a = np.exp(arr) return a / np.sum(a) def sum_softmax(arr): return np.sum(softmax(arr)) |
null | Write a Swift code to print out the signature of a function. | func addNumbers(a: Int, b: Int) -> Int { return a + b } | print(addNumbers.signature) // prints: func addNumbers(a: Int, b: Int) -> Int |
null | Modify the given Python program to optimize the memory allocation and improve the execution time of the program | import pandas as pd
data = pd.read_csv('dataset.csv') | import pandas as pd
# Load the dataset with memory optimization
data = pd.read_csv('dataset.csv', low_memory=True)
# Optimize the data to reduce the size
data = data.drop_duplicates(keep=False)
# Optimize the data to increase the performance
data = data.apply(pd.to_numeric, errors='coerce') |
null | Create a Python program to display the calendar of a given year. | import calendar
def show_calendar(year):
return calendar.calendar(year) | |
null | Configure a Python program to calculate the sum of all integers from 1 to 100. | def calculate_sum():
sum = 0
for i in range(1, 101):
sum += i
return sum | |
null | Create a Python code to check if a single integer is a prime number | int number = 11 | def is_prime(number):
if number <= 1:
return False
for i in range(2, number):
if number % i == 0:
return False
return True |
[CS Wikipedia] Stavová veličina
Stavová veličina neboli veličina kvality je veličina, která popisuje stav termodynamického systému. Stavové veličiny se dělí na vnější (extenzivní) a vnitřní (intenzivní). Vnější veličiny závisí na velikosti termodynamického systému, vnitřní veličiny jsou na velikosti termodynamického s... | null | null | null |
null | Create a Python program to perform Bubble Sort on an unsorted list. | [2, 4, 9, 5, 1] | # Bubble Sort Algorithm
def bubbleSort(lst):
n = len(lst)
# Traverse through all array elements
for i in range(n):
# Last i elements are already in place
for j in range(0, n-i-1):
# traverse the array from 0 to n-i-1
# Swap if the element found is greater
# than the next element
... |
null | Calculate the frequency of occurrence of each letter in a word. | word = "programming" | def frequency_count(word): # dictionary to store the frequency of occurrence frequency = {} # iterate through each character for char in word: # if the character is present in the frequency dictionary if char in frequency: # increase the count of the character frequency[char] += 1 else: # add the character to the dicti... |
null | Implement a recursive binary search on a given sorted list. | [-4, -2, 0, 6, 7, 8] | def binary_search(arr, num, start, end): if start >= end: return None mid = start + (end - start)//2 if arr[mid] == num: return mid if arr[mid] < num: return binary_search(arr, num, mid+1, end) else: return binary_search(arr, num, start, mid-1) |
[CS Wikipedia] Patrik Dressler
Patrik Dressler (* 30. října 1990 v Ostravě) je český fotbalový obránce, od ledna 2018 působící v FK Viktoria Žižkov. Klubová kariéra Svoji fotbalovou kariéru začal v Baníku Ostrava, kde prošel všemi mládežnickými kategoriemi. V roce 2010 se propracoval do prvního týmu. V červenci 2012 p... | null | null | null |
null | Create a function to find cube of any number | def cube(n): return n**3 | |
[DE Wikipedia] Stade Soussien
Stade Soussien () ist ein tunesischer Fußballverein aus der Küstenstadt Sousse. Der Verein spielt in der dritthöchsten Spielklasse Tunesiens. Die Heimspiele werden im Stade Mustapha Amara ausgetragen. Wichtige Spiele, zu denen hoher Zuschauerandrang erwartet wird, finden im Stade Olympiqu... | null | null | null |
null | Customize a WordPress theme to ensure its compatibility with the latest version of the WordPress software. | Update the functions.php file of your WordPress theme to use the latest functions, classes, constants, and APIs supplied by WordPress. Also, delete any deprecated code and features that are not supported in the latest version of WordPress. Using the WordPress Theme Check plugin is highly recommended to check the compat... | |
[EN Wikipedia] Linda Winstead Jones
Linda Winstead Jones is an American author who has written more than fifty romance books in several subgenres, including Paranormal Romance,Historical Romance, Fairy Tale Romance, and Romantic Suspense. Biography Jones has published many of her novels under various pseudonyms includ... | null | null | null |
null | Given the following array, remove all duplicates and return a new array with the remaining elements. | arr = [1, 2, 4, 3, 3, 2] | new_arr = list(set(arr)) # [1, 2, 3, 4] |
null | Write a Python script that mines data from Twitter and displays the latest tweets for a keyword. | Not applicable | import tweepy
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
public_tweets = api.search('python')
for tweet in public_tweets:
print(tweet.t... |
null | Generate a Python script to find the most frequently used word in a given text. | text.txt | # import Counter and open file
from collections import Counter
with open('text.txt','r') as file:
# split file into words
words = file.read().split()
# count and sort words
count_words = Counter(words)
sorted_count_words = count_words.most_common()
# get the most frequent word
most... |
[EN Wikipedia] Pairatahi River
The Pairatahi River is a river of the Northland Region of New Zealand's North Island. It flows generally north to reach Rangaunu Harbour to the northeast of Awanui. See also List of rivers of New Zealand References Rivers of the Northland Region Rivers of New Zealand | null | null | null |
null | Write a function in Python to detect duplicate elements in an array. | [3, 5, 6, 7, 3, 5] | def find_duplicates(arr):
seen = set()
duplicates = []
for x in arr:
if x in seen:
duplicates.append(x)
else:
seen.add(x)
return duplicates
print(find_duplicates([3, 5, 6, 7, 3, 5])) |
null | Modify the following JavaScript code to alert "Thanks for visiting!" when the page is loaded. | window.onload = function() { alert("Thanks for visiting!"); } | |
null | To set up the Mission Pinball Framework (mpf), create a setup.py file with the given code and run it. The setup.py file includes dependencies and entry points for console scripts. | """Mission Pinball Framework (mpf) setup.py."""
import re
from setuptools import setup
# http://stackoverflow.com/questions/458550/standard-way-to-embed-version-into-python-package
VERSIONFILE = "mpf/_version.py"
VERSION_STRING_LONG = open(VERSIONFILE, "rt").read()
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
_MO = r... | |
null | Write a Python program to turn a string into Pig Latin. | string = "Hello World" | def toPigLatin(s):
vowels = ('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U')
if s[0] in vowels:
return s + 'way'
else:
return s[1:] + s[0] + 'ay'
print(toPigLatin("Hello World")) |
[DE Wikipedia] Thiergarten (Beuron)
Thiergarten ist ein Ortsteil der Gemeinde Beuron im Landkreis Sigmaringen in Baden-Württemberg. Geographie Geographische Lage Thiergarten liegt im Tal der Oberen Donau, rund zehn Kilometer westlich von Sigmaringen. Geologie Westlich von Thiergarten befindet sich zwischen Falkenstein... | null | null | null |
null | Write a Python program to format a given string with a coefficient of over 66%. | s = "Hello World" | def format_string(s):
return s.upper() if (s.count(" ")+1) / len(s) > 0.66 else s
s = "Hello World"
print(format_string(s))
# Output: HELLO WORLD |
null | Using the provided Python code, optimize the code to be as efficient as possible. | x = 0
y = 0
def func():
global x
global y
x += 1
y += 2
for i in range(10000):
func() | x = 0
y = 0
def func():
global x, y
x, y = x+1, y+2
func()
x += 9999
y += 19998 |
null | Generate a Python code that flattens a two-dimensional array. | [[1, 2], [3, 4]] | def flatten_2d_array(arr): flat_arr = [] for subarr in arr: flat_arr += subarr return flat_arr # Driver code input_list = [[1, 2], [3, 4]] print(flatten_2d_array(input_list)) |
null | Create a Python program that counts how many times each word appears in a given sentence. | The quick brown fox jumps over the lazy dog | sentence = 'The quick brown fox jumps over the lazy dog'
# Split the sentence into individual words
words = sentence.split(' ')
# Create an empty dictionary
word_count = {}
# Count the number of times each word appears
for word in words:
if word in word_count:
word_count[word] += 1
else:
word... |
null | Write HTML code to create a webpage that has two paragraphs and a header. | <!DOCTYPE html> <html> <head> <title>Two Paragraphs & a Header</title> </head> <body> <h1>Header</h1> <p>Paragraph 1</p> <p>Paragraph 2</p> </body> </html> | |
null | Write Python code to print the most frequent characters in a given string. | String: I love apples | def most_frequent_char(s): count = [0] * 256 max_count = 0 max_id = 0 for i in range(len(s)): count[ord(s[i])] += 1 if count[ord(s[i])] > max_count: max_count = count[ord(s[i])] max_id = i return s[max_id] |
null | Develop a program in Python to compute the sum of integers in a given range? | def sum_range(start, end):
total = 0
for i in range(start,end + 1):
total += i
return total
# Test the function
print(sum_range(1, 10)) # Output: 55 | |
[CS Wikipedia] Seznam poslanců Českého zemského sněmu (1895–1901)
Toto je seznam poslanců Českého zemského sněmu ve volebním období 1895–1901. Zahrnuje všechny členy Českého zemského sněmu ve funkčním období od zemských voleb roku 1895 až do voleb roku 1901. Odkazy Reference Literatura Almanach zemského sněmu 1896 Sez... | null | null | null |
[CS Wikipedia] Listy (časopis)
Listy jsou kulturní a společenský dvouměsíčník vycházející v Olomouci. Jeho součástí jsou texty o domácí a zahraniční politice, fejetony, informace z kultury, v každém čísle publikuje autorské fejetony, fotografie a poezii. Časopis každoročně uděluje Cenu Pelikán „za zásluhy o politickou... | null | null | null |
[DE Wikipedia] Kebse
Kebse, Kebsfrau und Kebsweib sind veraltete, heute allenfalls noch dialektal verwendete Bezeichnungen für eine Nebenfrau oder eine Konkubine. Das Bürgertum des 19. Jahrhunderts, dem dieser Ausdruck zu derb erschien, sprach stattdessen lieber von Maitresse. In der Lutherschen Bibelübersetzung dageg... | null | null | null |
[HI Wikipedia] सुंग वंश
thumb|320 × 226px|शुंग वंश| शुंगवंश मौर्य वंश के अंतिम सम्राट् बृहद्रथ के प्रधान सेनापति पुष्यामित्र द्वारा प्रतिष्ठित एक प्राचीन राजवंश। ईसा से १८४ वर्ष पूर्व पुष्यमित्र शुंग ने बृहद्रथ को मारकर मौर्य साम्राज्य पर अपना अधिकार जमाया। यह राजा वैदिक या सनातनी धर्म का पक्का अनुयायी था, जिस समय पुष... | null | null | null |
[EN Wikipedia] Dendrosporobacter
Dendrosporobacter is a genus in the phylum Bacillota (Bacteria). Members of the class Negativicutes, stain gram negative, despite being firmicutes Etymology The name Dendrosporobacter derives from:Greek noun dendron, tree; Greek noun spora (σπορά), a seed, and in biology a spore; Neo-L... | null | null | null |
null | Fill in the missing code so that it prints the second element of each list. | my_list = [[1,2,3],[4,5,6],[7,8,9]] | for lst in my_list: print(lst[1]) |
null | Given an input string, write a function that will remove all non-alphanumeric characters. | Hello World! | def remove_non_alphanumeric_chars(input): output = "" for char in input: if char.isalnum(): output += char return output |
null | Reverse this array in-place using Python. | arr = [4, 2, 8, 6] | arr.reverse() # arr is now [6, 8, 2, 4] |
null | Write a piece of python code to multipy each element in a list by 10. | [1,2,3,4] | lst=[1,2,3,4]
for i in range(len(lst)):
lst[i] = lst[i]*10
print(lst) |
null | Write a JavaScript function to perform a binary search. | let array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; let x = 5; | let binarySearch = (array, x) => { let start = 0; let end = array.length - 1; while (start <= end) { let middle = Math.floor((start + end) / 2); if (array[middle] === x) { return middle; } else if (x < array[middle]) { end = middle - 1; } else { start = middle + 1; } } return -1; } |
null | Design an algorithm in Python to find all unique combinations of three numbers that sum to a given value. | Target Sum: 6 | def findUniqueCombos(targetSum):
result = []
for i in range(targetSum+1):
for j in range(i+1):
for k in range(j+1):
if i + j + k == targetSum:
uniqueCombo = [i, j, k]
result.append(uniqueCombo)
return result |
null | If a given string contains four consecutive identical characters, write a code to print the string and the count of the consecutive characters. | String: aaaagood | def four_consecutive_chars(input_string): count = 1 prev_char = "" result = "" for char in input_string: if prev_char == char: count += 1 if count == 4: result += char + " : " + str(count) else: result += char + " : " + str(count) count = 1 prev_char = char print(input_string) print(result) |
null | Define a function in R which takes two arguments and finds their average. | find_average <- function(x, y){ avg <- (x + y) / 2 return(avg) } | |
[CS Wikipedia] Kondenzace
Kondenzace (též kondensace) je termín z latiny používaný ve významu: zahuštění, zhuštění (např. kondenzované mléko) Kapalnění – změna skupenství z plynného na kapalné Kondenzace (chemie) – reakce organických sloučenin, jejímž produktem je větší molekula a nízkomolekulární sloučenina Reference... | null | null | null |
null | Writing a function to calculate the area of a triangle where the three sides are given. | side1 = 5, side2 = 6, side3 = 7 | function triangleArea(side_1, side_2, side_3) { var s = (side_1 + side_2 + side_3) / 2; var area = Math.sqrt(s * (s - side_1) * (s - side_2) * (s - side_3)); return area; } console.log(triangleArea(5,6,7)); // 14.697 |
null | Create a Python function which takes an integer as input and prints it in binary. | def int_to_binary(n):
if n == 0:
return '0'
bin_string = ""
while n > 0:
bin_string = str(n%2) + bin_string
n = n // 2
return bin_string | |
[DE Wikipedia] Anarchie
Anarchie ( „Herrschaftslosigkeit“, von „Herrschaft“ mit verneinendem Alpha privativum) bezeichnet einen Zustand der Abwesenheit von Herrschaft. Er findet hauptsächlich in der politischen Philosophie Verwendung, wo der Anarchismus für eine solche soziale Ordnung wirbt. Anarchisten wollen die Ges... | null | null | null |
null | Generate a sum of square numbers from 1 to 5. | Sum of squares of all numbers from 1 to 5 is 55 (1^2 + 2^2 + 3^2 + 4^2 +5^2). | |
null | Write an SQL query to find the average salary of all the employees with 10 years of experience. | SELECT AVG(salary) FROM employees WHERE experience = 10; | |
[DE Wikipedia] Quickborn-Bücher
Die Quickborn-Bücher sind eine von der 1904 gegründeten Sprachgesellschaft Quickborn. Vereinigung für Niederdeutsche Sprache und Literatur e.V. in Hamburg herausgegebene niederdeutsche Buchreihe, deren Ziel die Förderung und Pflege der niederdeutschen Sprache ist. Die Reihe erscheint se... | null | null | null |
null | Find the maximum and minimum number in the following array with JavaScript. | [20, 40, 10, 30, 50] | let numbers = [20, 40, 10, 30, 50]; let minNumber = Math.min(...numbers); let maxNumber = Math.max(...numbers); |
null | Output the output of this C++ program. | #include <iostream> using namespace std; int main() { int x, y; cin >> x >> y; cout << x + y; return 0; } | Input: 5 6 Output: 11 |
null | Calculate the volume of a cuboid given the edges. | Length = 4 Width = 5 Height = 2 | def volume_of_cuboid(length, width, height): volume = length * width * height return volume |
null | Create an implementation of Quick Sort in Python which does not repeat elements. | Not applicable | def quickSort(v, low, high):
if low < high:
# Get the partition index using partition()
pi = partition(v, low, high)
# Sort the elements before the partition
quickSort(v, low, pi - 1)
# Sort the elements after the partition
quickSort(v, pi + 1, high)
def pa... |
null | Create a Python script that will automatically detect the largest number in a given list. | [7, 2, -4, 5, 8, 1] | def find_largest_number(list):
largest = list[0]
for number in list:
if number > largest:
largest = number
return largest
list = [7, 2, -4, 5, 8, 1]
print(find_largest_number(list))
# Output: 8 |
null | Given the following 2D array. Create a function to find the sum of each row. | Array = [[2, 5, 6], [4, 1, 3], [5, 9, 0]] | def sum_row(arr): total = [] for row in arr: total.append(sum(row)) return total |
null | Write an HTML code snippet for a form to get two inputs: name and email. | <form> <label for="name">Name:</label> <input type="text" id="name" name="name"> <label for="email">Email:</label> <input type="email" id="email" name="email"> <input type="submit" value="Submit"> </form> | |
null | Retrieve data from an SQL database. | Table name: users | SELECT * FROM users; |
null | Read the code and determine all the variables that have been declared or used. | def func(x, y, z): a = x + y + z b = x * y * z c = a / b | The variables are x, y, z, a, b, and c. |
[DE Wikipedia] Meisenthal
Meisenthal () ist eine französische Gemeinde mit Einwohnern (Stand ) im Département Moselle in der Region Grand Est (bis 2015 Lothringen). Sie gehört zum Arrondissement Sarreguemines und zum Kanton Bitche. Geografie Meisenthal liegt etwa 15 Kilometer südlich von Bitsch an der Grenze zum Dépar... | null | null | null |
null | Write a Python function that takes a list of words as input and capitalizes the first character of each element in the list. | ["apple", "banana", "strawberry"] | def capitalize(words):
return [word.capitalize() for word in words]
input_words = ["apple", "banana", "strawberry"]
capitalized_words = capitalize(input_words)
print(capitalized_words) |
null | Write a function that takes a string and returns the letter which appears most frequently. | s = "apple" | def most_frequent_letter(s): # get the letter frequency letter_frequency = {} for ch in s: if ch in letter_frequency: letter_frequency[ch] += 1 else: letter_frequency[ch] = 1 # find the letter with the max frequency max_frequency = 0 max_frequency_letter = '' for letter, frequency in letter_frequency.items(): if freque... |
[EN Wikipedia] F. O. Alexander
Franklin Osborne Alexander (November 3, 1897 – January 17, 1993), known professionally as F. O. Alexander, was a comic strip artist and editorial cartoonist. He is credited for having designed the board game Monopoly, including the iconic mascots and characters. Biography A native of St.... | null | null | null |
null | We have a json object containing a list of words. Create a program in Python that returns all the words that are longer than 7 characters. | {
"words": [ "abide", "absolve", "catastrophe", "accelerate", "capable"]
} | import json
def findLongWords(words):
result = []
for word in words:
if len(word) > 7:
result.append(word)
return result
data = json.loads(input_data)
words = data["words"]
print(findLongWords(words)) // ["catastrophe", "accelerate"] |
[HI Wikipedia] गुरुत्वाकर्षण
गुरुत्वाकर्षण (gravitation) पदार्थो द्वारा एक दूसरे की ओर आकर्षित होने की प्रवृति है। गुरुत्वाकर्षण के बारे में पहली बार कोई गणितीय सूत्र देने की कोशिश आइजक न्यूटन द्वारा की गयी जो आश्चर्यजनक रूप से सही था। उन्होंने गुरुत्वाकर्षण सिद्धांत का प्रतिपादन किया। न्यूटन के सिद्धान्त को बाद में अ... | null | null | null |
null | Calculate the sum of the following numbers using JavaScript. | [1, 4, 8, 10] | let sum = 0; for(i = 0; i < arr.length; i++){ sum += arr[i]; } console.log(sum); // Output: 23 |
[CS Wikipedia] Square Gaston-Baty
Square Gaston-Baty je square v Paříži ve 14. obvodu. Jeho rozloha činí 1035 m2. Poloha Trojúhelníkovité square se nachází mezi ulicemi Rue Poinsot, Rue du Maine a Rue Jolivet. Historie Square bylo zřízeno v roce 1929 a bylo pojmenováno po francouzském divadelníkovi Gastonovi Batym (18... | null | null | null |
null | Design a stack using a dynamic array in Java. | class MyStack { int top; int capacity; int stack[]; // Creating stack MyStack(int capacity) { this.capacity = capacity; stack = new int[capacity]; top = -1; } // Adding an element on top of the stack public void push(int item) { if (top == capacity - 1){ System.out.println("Stack overflow"); } else{ stack[++top] = item... | |
null | Re-implement this Ruby code in Python | def fibonacci(n) return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2) end | def fibonacci(n): if n < 2: return n return fibonacci(n - 1) + fibonacci(n - 2) print(fibonacci(7)) # Outputs: 13 |
null | Create a class in Python that can generate a new instance of itself given a list of arguments | list = ["name", "age", "gender"] | class Student():
def __init__(self, name, age, gender):
self.name=name
self.age=age
self.gender=gender
def generate(self, args):
return Student(*args) |
[DE Wikipedia] Max Hobrecht
Maximilian „Max“ Hobrecht (* 13. Dezember 1827 in Königsberg, heute Kaliningrad; † 1. September 1899 in Rathenow) war ein deutscher Dichter und Politiker. Max Hobrecht war der Sohn von Ludolf Hobrecht, einem ostpreußischen Gutsbesitzer, königlichen Ökonom und Commissionsrat (gestorben 1866)... | null | null | null |
null | Make a function that accepts 2 numbers and return the largest one. | 2, 3 | def largest(x, y): if (x > y): return x else: return y |
[DE Wikipedia] Waldblick
Waldblick ist der Name folgender Orte: Waldblick (Blankenfelde-Mahlow), Siedlung in Blankenfelde-Mahlow, Landkreis Teltow-Fläming, Land Brandenburg Waldblick (Wachau), Siedlung in Wachau, Landkreis Bautzen, Sachsen Okna (Baruchowo), Teil der Gmina Baruchowo, Powiat Włocławski, Woiwodschaft Kuj... | null | null | null |
[DE Wikipedia] Museumsgesellschaft Tübingen
Die Museumsgesellschaft Tübingen e. V. entstand 1818/20 aus der Vereinigung mehrerer Lesegesellschaften in der Stadt Tübingen, die sich seit 1774 entwickelt hatten und von akademischen, studentischen und bürgerlichen Kreisen getragen wurden. Im Jahre 1821 ließ die Gesellscha... | null | null | null |
null | Create an algorithm that takes in two sorted arrays and merges them together. | arr1 = [1,3,5,7,9] arr2 = [2,4,6,8,10] | def merge_arrays(arr1, arr2): merged = [] i, j = 0, 0 while i < len(arr1) and j < len(arr2): if arr1[i] < arr2[j]: merged.append(arr1[i]) i += 1 else: merged.append(arr2[j]) j += 1 while i < len(arr1): merged.append(arr1[i]) i += 1 while j < len(arr2): merged.append(arr2[j]) j += 1 return merged |
null | Create a functional HTML form using the following attributes. | name, email, country | <form> <label for="name">Name</label> <input type="text" name="name"> <label for="email">Email</label> <input type="email" name="email"> <label for="country">Country</label> <select name="country"> <option>---------</option> <!-- To be populated dynamically --> </select> <input type="submit" value="Submit"> </form> |
null | Write a Python function that takes an integer as an argument and returns the square of that number | def square(n): return n ** 2 | |
null | edit the given Python program to delete an elements at a given position | def delete(list,N):
first_part = list[:N]
last_part = list[N+1:]
list = first_part + last_part
return list | def delete(list,N):
first_part = list[:N]
last_part = list[N+1:]
list = first_part + last_part
return list
list1 = [1,2,3,4,5]
N = int(input('Enter the index of the element to be deleted: '))
list1 = delete(list1,N)
print(list1) |
null | How to check if a list contains any None value in it? | any(x is None for x in my_list) | |
null | Write an algorithm to find the longest sub string without repeating characters. | string = 'abcabcbb' | def length_longest_substring(string): start = 0 max_length = 0 seen = {} for end in range(len(string)): # Check if the character has been previously seen. if string[end] in seen: # Move the starting point of the substring to the index after the last seen character of this character. start = max(start, seen[string[end]]... |
null | Generate a function in Python that finds the maximum element in an array of integers using a linear search. | [3, 17, 5, 19, 10] | # Function to find the maximum element in an array of integers
def findMax(arr):
maxEle = arr[0]
# Iterate through the array and find the maximum element
for i in range(1, len(arr)):
if arr[i] > maxEle:
maxEle = arr[i]
return maxEle
# Driver code
arr = [3, 17, 5, 1... |
null | Write a Python script that will take in a user's input in a textbox and return the most frequent words, in descending order. | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. | import re
import operator
user_input = input("Please enter a sentence: \n")
words = re.findall(r'\w+', user_input)
word_frequency = {}
for word in words:
if word in word_frequency:
word_frequency[word] += 1
else:
word_frequency[word] = 1
# Sort words by frequency in descending order
sorted_words = sorte... |
null | Create a game of rock-paper-scissors using functions and conditionals. | def play_game(): """ This function is a game of rock-paper-scissors. """ import random player_input = input("Choose rock(r), paper(p) or scissors(s): ") computer_choice = random.choice(["r", "p", "s"]) if player_input == computer_choice: return "It is a draw" elif player_input == "r": if computer_choice == "p": return ... | |
null | Build an HTML table with 3 columns and 5 rows using JavaScript. | var htmlTable = '<table border="1">'; // Create the table rows for (var i = 0; i < 5; i++){ htmlTable += '<tr>'; // Create the table columns for (var j = 0; j < 3; j++){ htmlTable += "<td></td>"; } htmlTable += "</tr>"; } htmlTable += "</table>"; | |
null | Develop a for loop in Javascript to output integers from 0 to 10 | for (let i = 0; i < 11; i++) { console.log(i); } | |
null | Create an object to store the variables that are necessary for the following code snippet. | x = 10 y = 20 z = 30 | class Coordinates: def __init__(self, x, y, z): self.x = x self.y = y self.z = z coordinates = Coordinates(x=10, y=20, z=30) |
null | Create a function which adds two strings together. | def add_strings(s1, s2): return s1 + s2 | |
[DE Wikipedia] Plan A
Plan A steht für: Plan A!, Studioalbum von Graham Candy Plan A (2021), Thrillerdrama von Yoav und Doron Paz Plan A (Lied), Lied von The Dandy Warhols Plan A Entertainment, ehemaliger Name eines südkoreanischen Medienkonzerns | null | null | null |
null | Edit the given code to add a new element to the list. | list = [1, 2, 3] | list = [1, 2, 3] list.append(4) # Adding new element |
null | Write a Python program that checks if a given number is prime. | 7 | def is_prime(n):
if n == 2 or n == 3:
return True
if n < 2 or n%2 == 0:
return False
if n < 9:
return True
if n%3 == 0:
return False
r = int(n**0.5)
f = 5
while f <= r:
if n%f == 0:
return False
if n % (f+2) == 0:
retur... |
null | Write a Python program to calculate the sum of the first 10 prime numbers. | Not applicable | # Calculate the sum of the first 10 prime numbers
# Variable to store the sum
sum = 0
# Iterate over the first 10 prime numbers and add them to the sum
for i in range(2,37):
# Check for Prime number
if all(i % j != 0 for j in range(2, i)):
sum += i
# Output the result
print("Sum of the first 10 prim... |
[CS Wikipedia] Fly-by-wire
Fly-by-wire (FBW) je systém, který umožnil nahradit konvenční systém ovládání řídicích ploch letounů pomocí táhel, lanek, hydromechanických převodů systémem elektrickým. Řídicí signály (například pohyb kniplu) jsou v tomto případě snímány a převáděny do elektronické podoby, které následně mů... | null | null | null |
null | Using conditional statements, print out whether a given number is odd or even. | number = 7 | if(number % 2 == 0){ console.log('`number` is even') } else { console.log('`number` is odd') } |
null | Write a Java method to check if a numerical value is within a specified range. | public static boolean isWithinRange(int val, int min, int max) { return (val >= min && val <= max); } | |
null | Suggest a name for a new string variable. | The name for the new string variable could be "nameString". | |
null | Given a string, concatenate the first and last character of the string together. | String: Grass | gs |
null | Generate a function to return the all the vowels from a string in Python. | Not applicable | def get_vowels(string):
vowels = 'aeiou'
return [char for char in string if char in vowels] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.