text
stringlengths
141
2.89k
⌀
instruction
stringlengths
19
1.5k
⌀
input
stringlengths
0
800
⌀
output
stringlengths
1
2.5k
⌀
null
Generate a Python program to edit a given list of strings and remove the duplicates in-place.
["AB", "AC", "AB", "CD", "AC"]
list = ["AB", "AC", "AB", "CD", "AC"] seen = set() res = [] for item in list: if item in seen: continue seen.add(item) res.append(item) list[:] = res print(list)
null
Write a Python program to remove duplicates from a list of strings. The program should maintain the order of the strings in the list.
['abc', 'def', 'abc', 'ghi', 'ghi', 'ghi', 'xyz']
def remove_duplicates(list_strings): # Create an empty list to store unique strings unique_strings = [] # Iterate over the list for string in list_strings: # Append string to unique_strings if it is not already present if string not in unique_strings: unique_strings.append(string) return unique...
null
Write an SQL query to select distinguish the records with 'Yes' and 'No' for the field 'full_time' from 'employees' table.
SELECT full_time FROM employees WHERE full_time IN ('Yes','No');
null
Construct a class in Python that will represent a shopping cart. The class should contain methods for making a purchase, adding products to the cart, and calculating the total price.
products = [ { 'name': 'Chocolate', 'price': 6.00 }, { 'name': 'Milk', 'price': 3.00 }, { 'name': 'Cheese', 'price': 12.00 }, ]
class ShoppingCart: def __init__(self, products): self.products = products self.total_price = 0 def add_product(self, product): self.products.append(product) def calculate_total_price(self): self.total_price = 0 for product in self.products: self.total_price += product['price'] return self.total_price def...
null
The given code is a Python script that translates a Wikivoyage article from one language to another. The script takes the title of the article and the source and destination languages as input and generates a new article in the destination
#!/usr/bin/python # -*- coding: utf-8 -*- # transvoyage.py # Version 0.3 # # Copyright 2014 Guénaël Muller <contact@inkey-art.net> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; eit...
null
Convert a given string into Pig Latin.
string = "Hello"
def pig_latin(string): vowels = "aeiou" if string[0].lower() in vowels: return string+"way" else: return string[1:]+string[0]+"ay"
[HI Wikipedia] भरतपुर भरतपुर (Bharatpur) भारत के राजस्थान राज्य के भरतपुर ज़िले में स्थित एक नगर है। यह उस ज़िले का मुख्यालय भी है। विवरण भरतपुर राजस्थान का एक प्रमुख शहर होने के साथ-साथ देश का सबसे प्रसिद्ध पक्षी उद्यान भी है। 29 वर्ग कि॰मी॰ में फैला यह उद्यान पक्षी प्रेमियों के लिए किसी स्वर्ग से कम नहीं है। विश्‍व ...
null
null
null
[HI Wikipedia] मूलक मूलक (radical) तत्वों के ऐसे समूह को कहते हैं, जो यौगिकों में एक रासायनिक तत्व सा व्यवहार करता है। यौगिकों में यह किसी तत्व का स्थान ले सकता है अथवा उसे विस्थापित कर सकता है। मूलक में असंयुक्त बंधुता होती है, जिससे यह असंयुक्त दशा में साधारणतया स्थायी नहीं होता, यद्यपि कुछ मूलक, जैसे कार्बोनिल (CO)...
null
null
null
null
Create a class in Python to represent books.
class Book: def __init__(self, title, author, year, isbn): self.title = title self.author = author self.year = year self.isbn = isbn def __str__(self): return '{} by {} published in {}. ISBN: {}'.format(self.title, self.author, self.year, self.isbn)
[CS Wikipedia] Skládání rychlostí Skládáním rychlostí se ve fyzice zpravidla označuje důsledek speciální teorie relativity, přesněji Lorentzovy transformace. Pohybují-li se dva objekty vůči vztažné soustavě S rovnoběžnými rychlostmi , , pak ve vztažné soustavě S' spojené s prvním z nich se bude druhý pohybovat rychlos...
null
null
null
null
Given a string consisting of alphanumeric characters, separate it into left and right parts so that the left part contains only digits and the right part contains only letters.
String: Ab243rG
left, right = '', '' for char in string: if char.isdigit(): left += char else: right += char
null
Convert the following C++ program to Python.
#include <iostream> int main() { int i = 0; int x = 0; while(i<5){ x=x+i; i++; } std::cout << x; return 0;
i = 0 x = 0 while i < 5: x += i i += 1 print(x)
[HI Wikipedia] पारा जिला पारा सूरीनाम का जिला है, यह देश के उत्तर में स्थित है। इसकी उत्तरी सीमा अटलांटिक महासागर के साथ लगती है। 2004 की जनगणना के अनुसार जिले की आबादी 18,958 है। इसका क्षेत्रफल 5,393 वर्ग किलोमीटर तथा घनत्व 3.5 प्रति वर्ग किलोमीटर है। जिले में पाँच रिसॉर्ट हैं। जिला सूरीनाम में होने वाले खनिकर्म और व...
null
null
null
[CS Wikipedia] Farní sbor Českobratrské církve evangelické v Opatově Farní sbor Českobratrské církve evangelické v Opatově je sborem Českobratrské církve evangelické v Opatově. Sbor spadá pod Horácký seniorát. V Opatově se nachází evangelický kostel. Farářkou sboru je Pavla Jandečková a kurátorem Libor Zajíček. Histor...
null
null
null
null
Implement find_difference() to calculate the absolute difference between two integers.
input_int1 = 5 input_int2 = 9
def find_difference(input_int1, input_int2): '''This function calculates the absolute difference between two integers.''' return abs(input_int1 - input_int2) # returns 4
null
Create a function in Python which takes a name as an argument and returns a message “Hello, <name>”
def hello(name): return "Hello, "+ name
null
Develop a python program to convert the given text into a list
Text: Apples, oranges, and bananas
text = "Apples, oranges, and bananas" list_from_text = text.split(", ") print("List:", list_from_text)
null
Write a Python program to check whether two strings are anagrams or not.
s1 = "listen" s2 = "silent"
def is_anagram(s1, s2): s1 = s1.replace(" ", "") s2 = s2.replace(" ", "") if len(s1) != len(s2): return False s1_count = Counter(s1) s2_count = Counter(s2) for i in s1_count: if s1_count[i] != s2_count[i]: return False return True s1 = "listen" s2 = "silent" print(is_anagram(s1, s2)) # Output: True.
[DE Wikipedia] Mexikanische Sonnenblume Die Mexikanische Sonnenblume (Tithonia diversifolia) ist eine Pflanzenart aus der Gattung Tithonia innerhalb der Familie der Korbblütler (Asteraceae). Die Mexikanische Sonnenblume gehört nicht zur Gattung der Sonnenblumen (Helianthus). Aber sie zählt genau so wie die Gewöhnliche...
null
null
null
null
Find the most frequent character in an inputted string.
input_string = "Hello, world"
def find_most_frequent_character(input_string): char_count_dict = {} for char in input_string: if char in char_count_dict.keys(): char_count_dict[char] += 1 else: char_count_dict[char] = 1 max_count = 0 max_char = '' for char in char_count_dict.keys(): if char_count_dict[char] > max_count: max_count = char_count_dict[c...
null
Modify the following Java code snippet to include an "else if" statement.
int val=20; if (val > 15) System.out.println("val is greater than 15");
int val=20; if (val > 15) System.out.println("val is greater than 15"); else if (val == 15) System.out.println("val is equal to 15");
null
Generate a Python program that finds the most frequent element in a list and returns a dictionary containing the element and the number of occurrences.
Example list: [1, 1, 2, 3, 3, 3, 4, 4, 4, 4]
def find_frequent(list): dictionary = {} for element in list: if element not in dictionary: dictionary[element] = 1 else: dictionary[element] += 1 frequency = max(dictionary.values()) most_frequent = [key for key in dictionary if dictionary[key] == frequency] return { most_frequent[0] :...
[HI Wikipedia] सोन्घाई साम्राज्य सोन्घाई साम्राज्य (Songhai Empire) पश्चिम अफ्रीका में स्थित एक राज्य था, जो आरंभिक पंद्रह सदी से सोलहवीं सदी के अंत तक स्थापित रही। सोन्घाई इतिहास में सबसे बड़ी इस्लामी सलतंनतो में से एक थी। सोंघाई का आरंभ गाव के नदी शहर से हुआ था। शहर के अभिजात वर्ग ने 9 वीं शताब्दी ce के दौरान नाइजर ...
null
null
null
null
Is the following statement valid in C++?
a = (b + c)
Yes, the statement is valid in C++.
null
Write a Python script to find the common elements in two given lists.
list1 = [1, 2, 3, 5, 7] list2 = [2, 3, 4, 5, 6]
def common_elements(list1, list2): common_ele = [] for i in list1: for j in list2: if i==j: common_ele.append(i) return common_ele
null
Write a code to find elements in an array that is divisible by a given number.
arr = [5, 15, 20, 25, 30]
# Function to find elements in an array that is # divisible by a given number def isDivisible(arr, num): # Stores result res = [] # Iterate over all elements for i in range(0,len(arr)): # If remainder is 0 then add elements # to result if (arr[i] % num == 0): res.append(arr[i]) return res # Driver code arr = [5, 15, 20...
null
Ensure the string is formatted correctly according to JSON standard.
{"name": shivam"
{"name": "shivam"}
null
Re-write the following Java program in Python.
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } }
def main(): print("Hello World") if __name__ == "__main__": main()
null
Create a function to lexicographically compare two strings in Python.
def stringCompare(str1, str2): if str1 < str2: return -1 elif str1 > str2: return 1 else: return 0 str1 = "Hello" str2 = "World" result = stringCompare(str1, str2) if result == -1: print ("str1 is less than str2") elif result == 1: print ("str2 is less than str1") else: ...
[HI Wikipedia] क्रोएशिया क्रोएशिया दक्षिण पूर्व यूरोप यानि बाल्कन में पानोनियन प्लेन, और भूमध्य सागर के बीच बसा एक देश है। देश का दक्षिण और पश्चिमी किनारा एड्रियाटिक सागर से मिलता है। देश की राजधानी और सबसे बड़ा शहर जगरेब है, जो तट से भीतर स्थित है। एड्रियाटिक सागर के किनारे कई हज़ार द्वीप हैं, इस समुद्र के किनारे पर्...
null
null
null
null
Put the following JavaScript snippet into Standard Form.
onMouseOver="this.style.cursor='pointer'"
this.addEventListener("mouseover", function() { this.style.cursor = "pointer"; });
null
Implement a Neural Network written in Python using TensorFlow for predicting the local weather.
Not applicable.
import tensorflow as tf # Build the neural network model model = tf.keras.Sequential([ tf.keras.layers.Input(shape=(24,)), # 8 neurons on the first hidden layer tf.keras.layers.Dense(8, activation='relu'), # 4 neurons on the second hidden layer tf.keras.layers.Dense(4, activation='relu'), # Output layer, w...
null
Write a Python program for predicting the score of a tennis match given the probabilities of various outcomes.
An array of 8 floats representing the probabilities for a player to win a point on their serve, break the opponent's serve, win a game on their serve and break the opponent's serve.
import numpy as np def predict_match_score(probabilities): p_serve_win = probabilities[0] p_opp_serve_win = probabilities[1] p_serve_game_win = probabilities[2] p_opp_serve_game_win = probabilities[3] expected_score_serve = p_serve_game_win * (4*p_serve_win + 3*p_opp_serve_win) expected_score_...
null
Make a Python program to create a rolling average over a list. Rolling average means return the average of the last 3 items of the list.
mylist = [10, 20, 30, 40, 50]
def rolling_average(arr): last_three = arr[-3:] return sum(last_three) / len(last_three) mylist = [10, 20, 30, 40, 50] rolling_avg = rolling_average(mylist) print("Rolling average:", rolling_avg) # Output: # Rolling average: 33.333333333333336
[EN Wikipedia] Cis festivus Cis rotundulus is a species of minute tree-fungus beetle in the family Ciidae. It is found in western Europe. References Ciidae Beetles described in 1793
null
null
null
null
Write a JavaScript function that takes two numbers and returns the sum of all numbers in between the two.
function sumNumbers(x, y) { let sum = 0 for(let i = x; i <= y; i++) { sum += i } return sum }
null
Which type of loops can be used in Python?
Python supports for loops, while loops, and nested loops. Additionally, the loop statement can be used to construct an infinite loop.
null
Given the following nested loop structure, write code to print all elements in the array.
arr = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
for row in arr: for elem in row: print(elem, end=' ') print() # Output # 1 2 3 # 4 5 6 # 7 8 9
null
Determine the code complexity for the following codse sample.
def get_sum(list): sum = 0 for num in list: sum += num return sum
The code complexity of the given function is O(n), where n is the length of the list.
null
Create a function that takes in two integers and returns the greatest common divisor (g.c.d).
def gcd(a, b): if a == 0: return b return gcd(b % a, a)
null
Generate a python program to find and print the count of each vowel present in the given string.
vowels = "aeiou" input_string = input("Input string: ") vowel_count = {} for char in input_string: if char in vowels: if char in vowel_count: vowel_count[char] += 1 else: vowel_count[char] = 1 print (vowel_count)
[HI Wikipedia] चाईबासा चाईबासा (Chaibasa) भारत के झारखंड राज्य के पश्चिमी सिंहभूम ज़िले में स्थित एक नगर है। यह ज़िले का मुख्यालय भी है। यह ऐतिहासिक स्वतंत्रता सेनानी, बिरसा मुंडा, की जन्मभूमि भी है। उद्योग चाईबासा में अधिकांश रोजगार सरकारी संस्थाओं के कर्मचारियों के रूप में है। एसीसी (ACC) नामक सीमेन्ट बनाने वाली कम्...
null
null
null
null
Using the given input, sort a list containing both numerical and strings data types in Python.
[1, 'c', 3, 'a', 2, 'b']
# define list lst = [1, 'c', 3, 'a', 2, 'b'] # sort list sorted_lst = sorted(lst, key=lambda x:str(x)) # print sorted list print(sorted_lst)
null
Create a Python program to generate a random password of 8 characters with 1 upper case, 1 lower case, 1 number, and 1 special character.
Not applicable
import string import random chars = string.ascii_uppercase + string.ascii_lowercase + string.digits + string.punctuation def generate_password(size=8, chars=chars): return ''.join(random.choice(chars) for _ in range(size)) print(generate_password())
null
Create a Bitcoin wallet application using Python. This application should have endpoints for creating a wallet, sending coins to another wallet, and retrieving the balance of a wallet.
Wallet address: 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
import hashlib import base58 class BitcoinWallet: def __init__(self): self.address = None self.public_key = None self.private_key = None self.balance = 0 def generate_keys(self): priv_key = hashlib.sha256(os.urandom(64)).hexdigest() public_key = hashlib.sha256(priv_key.encode('utf-8')).hexdigest() sel...
null
Analyse the sentiment of the given sentence using python.
Sentence: I am so excited that I was chosen for the job.
from textblob import TextBlob # Get the sentiment of the sentence sentence = 'I am so excited that I was chosen for the job.' blob = TextBlob(sentence) sentiment = blob.sentiment print('Polarity:', sentiment.polarity) # Output: Polarity: 0.8
null
Create a SQL query that returns 10 rows of the table 'exampleTable'.
SELECT * FROM exampleTable LIMIT 10;
null
Convert the given SQL query into an equivalent MongoDB query.
SELECT * FROM users WHERE age BETWEEN 18 AND 24
db.users.find( { age: { $gte: 18, $lte: 24 } } )
[CS Wikipedia] Kino Kino neboli biograf je místo (obvykle budova), které je určeno k hromadnému sledování filmových představení. Filmový projektor, který je umístěn vzadu v projekční kabině, promítá film na plátno, které je umístěno vpředu před hledištěm. Do hlediště se běžný divák dostane teprve po zaplacení vstupnéh...
null
null
null
null
Create a Python script to convert JSON data to CSV format.
{ “name”: “John”, “age”: 30, “city”: “New York” }
import csv import json data = { “name”: “John”, “age”: 30, “city”: “New York” } with open('data.csv', 'w') as csvfile: writer = csv.writer(csvfile) writer.writerow(["Name", "Age", "City"]) writer.writerow([data["name"], data["age"], data["city"]])
null
Write a function in Python that takes in a string and returns true if it is a palindrome, and false otherwise.
text = "racecar"
def is_palindrome(text): return text == text[::-1]
null
Construct a HTML page that displays a form with a text field and a submit button.
<!DOCTYPE html> <html> <head> <title>Sample Form</title> </head> <body> <form action="" method="post"> <input type="text" placeholder="Input..."/> <input type="submit" value="Submit" /> </form> </body> </html>
[CS Wikipedia] Botzaris (stanice metra v Paříži) Botzaris je nepřestupní stanice pařížského metra na lince 7bis v 19. obvodu v Paříži. Nachází se na Rue de Botzaris u východního cípu rozsáhlého veřejného Parku des Buttes-Chaumont. Historie Stanice byla otevřena 18. ledna 1911 jako součást boční větve linky 7. Dne 3. p...
null
null
null
[EN Wikipedia] Lagodon Lagodon is a genus of saltwater fish in the family Sparidae, the breams and porgies. It is monotypic, being represented by the single species Lagodon rhomboides, commonly known as pinfish. Other common names include pin perch, sand perch, choffer, and butterfish. It inhabits mostly subtropical s...
null
null
null
null
Use Python to create a dictionary whose keys are strings and whose values are lists containing numbers.
keys = ["cat", "dog", "mouse"] values = [1, 2, 3]
my_dict = {"cat": [1], "dog": [2], "mouse": [3]}
null
Develop an API in Python to convert between different units of measurement.
Not applicable
# Dictionary with conversion factors FACTORS = { 'in': 2.54, 'cm': 0.39, 'ft': 30.48, 'm': 1 } def convert(from_unit, to_unit, value): """ Convert between measurement units. """ factor = FACTORS[from_unit]/FACTORS[to_unit] return factor * value # Test the function print(convert('in', 'cm', 10)) # Output: ...
null
Create a Python script to parse a JSON string and return the value of the given field.
{"name": "John", "age": 30}
def get_value(json_string, field): json_dict = json.loads(json_string) return json_dict[field]
null
Create an AI-friendly program in Python to remove duplicates from a list of numbers.
list1 = [1, 2, 3, 2, 4, 5, 1];
def remove_duplicates(list1): new_list = [] for num in list1: if num not in new_list: new_list.append(num) return new_list remove_duplicates(list1)
[DE Wikipedia] Stanley-Cup-Playoffs 1952 Die Playoffs um den Stanley Cup des Jahres 1952 begannen am 25. März 1952 und endeten am 15. April 1952 mit dem 4:0-Erfolg der Detroit Red Wings über die Canadiens de Montréal. Die Red Wings gewannen damit ihren zweiten Titel in den letzten drei Jahren sowie den insgesamt fünft...
null
null
null
[HI Wikipedia] समारा ओब्लास्त समारा ओब्लास्त (रूसी: Сама́рская о́бласть, अंग्रेज़ी: Samara Oblast) रूस का एक ओब्लास्त (области या प्रांत) है। सोवियत संघ के ज़माने में, १९३६ से १९९० तक, इसका नाम कुय्बिशेव ओब्लास्त (Ку́йбышевская о́бласть, Kuybyshev Oblast) था। इस ओब्लास्त की राजधानी भी 'समारा' नामक शहर ही है। लोग २०१० ...
null
null
null
null
Create a program in Python that takes a list as input and returns a new list with every element doubled.
[1, 2, 3, 4]
def double_list(numbers): doubled_list = [] for num in numbers: doubled_list.append(num*2) return doubled_list
null
Write a Python code to generate a random number between 10 and 50.
import random random_number = random.randint(10, 50) print("Random number between 10 and 50 is", random_number)
null
Identify the data structure most suitable for storing 100 unique integers.
Hash Table
null
Design a recursanve function in Python that prints a given string in reverse.
hello
def print_string_reverse(str): if not str: return else: print_string_reverse(str[1:]) print(str[0], end='')
null
Find the mean of the elements in this array.
Array: [2, 3, 5, 4, 9]
The mean of the elements in this array is 4.8.
null
Construct a HTML table with four columns.
<table> <tr> <th>Column 1</th> <th>Column 2</th> <th>Column 3</th> <th>Column 4</th> </tr> </table>
null
Produce a 3D array from a given list of numbers.
[1, 2, 3, 4, 5, 6]
[[[1], [2], [3]], [[4], [5], [6]]]
null
Can you develop a Python script that takes in a URL and prints out the source code?
url = 'http://www.example.org/'
import urllib.request url = 'http://www.example.org/' response = urllib.request.urlopen(url) print(response.read())
null
Given a list of numbers, extend the list such that it contains the square of the elements present in the list.
numbers = [1,2,3]
numbers = [1,2,3,1,4,9]
null
Write a function in Python to convert a year from Roman Numerals to Arabic numbers.
Provide the year in Roman Numerals `MCMXCVIII`
# define a dictionary of Roman Numerals to Arabic numbers roman = { 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000 } def roman_to_arabic(roman_string): total = 0 #Split the Roman number into characters chars = [char for char in roman_string] #If the length ...
null
Generate a C code snippet to print a given string with a width of 20 characters.
Hello
#include <stdio.h> #include <string.h> int main(){ char str[20] = "Hello"; printf("%-20s\n", str); return 0; }
[CS Wikipedia] Amennacht Amennacht (v překladu z egyptštiny „Amon je silný“) je staroegyptské jméno, které může označovat: Amennachta – místokrále Núbie v době panovnice Hatšepsuty Amennachta – písaře a kresliče v Dér el-Medíně v době Ramesse III. a Ramesse IV. Amennachta – hrdinu stejnojmenné povídky, kterou napsal n...
null
null
null
[HI Wikipedia] पर्सनल डिजिटल एसिस्टेंट पीडीए या पर्सनल डिजिटल असिस्टंट एक ऐसा छोटा कंप्यूटर है जिसे आप डिजिटल डायरी की तरह जेब में कहीं भी ले जा सकते हैं। यह एक साधारण कंप्यूटर की तरह ही काम करता है लेकिन आप इसे मोबाइल फ़ोन की तरह या फिर इंटरनेट पर जाने के भी इस्तेमाल कर सकते हैं। पीडीए में लिखने के लिए एक विशेष पेन्स...
null
null
null
[CS Wikipedia] Šroub Šroub (z něm. Schraube) je typ spojovacího materiálu, součástka tvořená hlavou umožňující otáčení pomocí šroubováku nebo klíče a dříkem opatřeným vnějším závitem. Společně s maticí a případně podložkou umožňuje vytvořit rozebíratelný šroubový spoj. Šroub lze zašroubovat i do jiného otvoru opatřené...
null
null
null
null
Write a recursive function to calculate the Fibonacci sequence.
def fibo(n): if n <= 1: return n else: return(fibo(n-1) + fibo(n-2)) # take input from the user nterms = 10 # check if the number of terms is valid if nterms <= 0: print("Please enter a positive integer") else: print("Fibonacci sequence:") for i in range(nterms): print(fibo(i))
null
Create an SQL query that sums all the numbers from the 'number' column in the table 'test_data'?
Table Name: test_data Columns: number
SELECT SUM(number) FROM test_data;
[DE Wikipedia] Xanthinurie Die hereditäre Xanthinurie ist eine autosomal-rezessiv vererbte Stoffwechselkrankheit. Dabei handelt es sich um eine Störung im Purinstoffwechsel. Es liegt eine Schwäche des Enzyms Xanthin-Oxidase (XO) vor. Epidemiologie Die Xanthinurie ist eine sehr seltene Erkrankung. Aber noch wesentlich ...
null
null
null
null
Parse data from a given JSON object.
data: { "data": [ { "name": "John", "age": 24 }, { "name": "Bob", "age": 26 } ] }
import json data = '{"data":[{"name":"John","age":24},{"name":"Bob","age":26}]}' parsed_data = json.loads(data) for item in parsed_data['data']: print(item['name'] + " is " + str(item['age']) + "years old.")
[CS Wikipedia] Kawasaki Zephyr 1100 Kawasaki Zephyr 1100 je motocykl firmy Kawasaki kategorie nakedbike, vyráběný v letech 1992-1998. Slabší modely jsou Kawasaki Zephyr 750, Kawasaki Zephyr 550 a pro Japonsko vyráběný Zephyr 400. Popis Nakedbike klasické koncepce se vzduchem chlazeným řadovým čtyřválcem a dvěma tlumič...
null
null
null
null
Create a python function for calculating the total cost of an item after tax and discounts are applied.
Price: 150 Discount: 20 Tax Rate: 0.1
def calculate_cost(price, discount, tax_rate): discount_amount = price * (discount / 100.0) total = price - discount_amount tax = total * (tax_rate / 100.0) final_cost = total + tax return final_cost price = 150 discount = 20 tax_rate = 0.1 final_cost = calculate_cost(price, discount, tax_rate) pri...
null
Create a Python program that takes a string as input and returns its top 3 most frequent characters
def most_frequent_chars(s): d = {} for i in s: if i not in d: d[i] = 0 d[i]+=1 d = sorted(d.items(),key = lambda x:x[1], reverse=True) return [k for k ,v in d[:3]]
null
Create a C++ class for a student with the attributes "first name", "last name" and "marks".
class Student { private: string firstName; string lastName; int marks; public: // constructor and methods };
null
Write a Python function to compare two lists and return the elements that are in both of them.
list1 = [3, 5, 7, 8] list2 = [3, 5, 10, 12]
def compare_lists(list1, list2): return [x for x in list1 if x in list2]
[DE Wikipedia] Tokanui Tokanui steht für: Tokanui (Southland), Ortschaft in der Region Southland, Neuseeland Tokanui (Waikato), Ortschaft in der Region Waikato, Neuseeland
null
null
null
[HI Wikipedia] अष्टाध्यायी अष्टाध्यायी (अष्टाध्यायी = आठ अध्यायों वाली) महर्षि पाणिनि द्वारा रचित संस्कृत व्याकरण का एक अत्यंत प्राचीन ग्रंथ (8वी ई पू) है। इसमें आठ अध्याय हैं; प्रत्येक अध्याय में चार पद हैं; प्रत्येक पद में 38 से 220 तक सूत्र हैं। इस प्रकार अष्टाध्यायी में आठ अध्याय, बत्तीस पद और सब मिलाकर लगभग 4000 ...
null
null
null
[CS Wikipedia] Věda Věda jako celek je systematický způsob racionálního a empirického poznávání skutečnosti zaměřený na spolehlivost výsledků a často i na možnosti predikce a aplikace (aplikované vědy). Předmětem vědeckého poznání jsou objekty a procesy reálného světa. Základní dělení reálného světa pro účely poznání ...
null
null
null
null
Place the missing parenthesis in the given algorithm.
for i = 1 to n if (A[i] == x) start = i; end = i + k – 1;
for (i = 1; i <= n; i++) if (A[i] == x) start = i; end = i + k - 1;
null
Use a random number generator to generate random numbers between 1 and 10.
import random def random_numbers(): for _ in range(10): num = random.randint(1, 10) print(num) random_numbers()
null
Explain what a REST API is.
A REST API is a web interface that uses HTTP methods (GET, POST, PUT, DELETE) to access resources identified by URLs, typically exchanging JSON.
[EN Wikipedia] Mboro Mboro is a town in the Thiès Region of western Senegal. It is in the Tivaouane Department. The population in 2013 was 27,693. The town received commune status in 2002. Mboro is situated 25 km west of Tivaouane and 117 km north of Dakar. There is a phosphate mine and factory in Mboro. References Po...
null
null
null
null
Create a function "distance" that takes two sets of coordinates in the form of [x1, y1] and [x2, y2] and computes the Euclidean distance between them.
def distance(c1, c2): """Function to calculate Euclidean distance between two sets of coordinates""" x1, y1 = c1 x2, y2 = c2 return math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
null
Create a Python program to detect the presence of outliers in a dataset.
Check for outliers in the following dataset: [30, 45, 12, 18, 32, 44, 25]
def find_outlier(arr): mean = sum(arr)/len(arr) stdev = (sum([(x-mean)**2 for x in arr])/len(arr))**(0.5) for i in arr: z_score = (i - mean)/stdev if z_score >= 3 or z_score <= -3: return i # no outliers found return None arr = [30, 45, 12, 18, 32, 44, 25] ou...
null
Write a function to extract a specific key from a dictionary.
{'a':1, 'b':2, 'c':3}
def extract_key(dictionary, key): return dictionary.get(key)
null
Generate a complete SQL query to select fields from a table
Table name: Orders Fields: Orderid, Price
SELECT OrderID, Price FROM Orders;
[DE Wikipedia] Liste der Naturdenkmale in Offenau Die Liste der Naturdenkmale in Offenau nennt die verordneten Naturdenkmale (ND) der im baden-württembergischen Landkreis Heilbronn liegenden Gemeinde Offenau. In Offenau gibt es zwei als Naturdenkmal geschützte Objekte, beide sind flächenhafte Naturdenkmale (FND), kein...
null
null
null
null
Create a for loop that prints the first five numbers of the Fibonacci sequence.
let x = 0; let y = 1; for (let i = 0; i < 5; i++) { let z = x + y; console.log(z); x = y; y = z; }
[CS Wikipedia] Pardubice Pardubice () jsou univerzitní a statutární město v okrese Pardubice na východě Čech, metropole Pardubického kraje s výraznou správní, obytnou, obslužnou a výrobní funkcí pardubicko-hradecké aglomerace. Leží ve východní části Polabí na soutoku řek Labe a Chrudimky, přibližně 100 kilometrů výcho...
null
null
null
null
Create a Python class that constructor prints “Hello World”.
class HelloWorld: def __init__(self): print(“Hello World”)
null
Generate a function in Python which takes an array as an argument and returns an array of length two, with the first element being the maximum value and the second element being the minimum value of the array.
[1, 5, 7, 3, 9]
def minmax(array): max_val = max(array) min_val = min(array) return [max_val, min_val]
[HI Wikipedia] सचिन सचिन तेंदुलकर - भारतीय क्रिकेट खिलाड़ी सचिन पिलगांवकर - हिंदी फ़िल्म अभिनेता, निर्माता व निर्देशक सचिन पायलट - भारतीय संसद सदस्य सचिन देव बर्मन - हिन्दी और बांग्ला फिल्मों के विख्यात संगीतकार व गायक
null
null
null