text
stringlengths
141
2.89k
⌀
instruction
stringlengths
19
1.5k
⌀
input
stringlengths
0
800
⌀
output
stringlengths
1
2.5k
⌀
null
Edit the following C program to print the right-most digit of the given number.
#include<stdio.h> int main() { int num; scanf("%d", &num); // Compute the rightmost digit printf("%d", num); return 0; }
#include<stdio.h> int main() { int num; scanf("%d", &num); // Compute the rightmost digit int right_most_digit = num % 10; printf("%d", right_most_digit); return 0; }
null
Create a statistical anomaly detection system in Python using Scikit-learn to detect fraudulent credit card transactions.
Not applicable
from sklearn.ensemble import IsolationForest # Create an Isolation Forest model model = IsolationForest(contamination=0.1) # Train the model model.fit(X_train) # Make predictions y_pred = model.predict(X_test) # Label the predictions y_pred[y_pred == 1] = 0 y_pred[y_pred == -1] = 1 # Evaluate predictions from skle...
null
Write a function to generate a random 5 letter string.
import random def generate_random_5_letter_string(): res = "" for i in range(5): res += chr(random.randint(97, 122)) return res if __name__ == '__main__': print(generate_random_5_letter_string())
[CS Wikipedia] Kyvadlo, jáma a naděje Kyvadlo, jáma a naděje je český film režiséra Jana Švankmajera z roku 1983. Film je zčásti hraný a zčásti animovaný, a je pomyslně rozdělen na tří části: první dvě inspiroval děj povídky Jáma a kyvadlo od Edgara Allana Poea, tato část je v závěru rozvita Nadějí od Augusta Villiers...
null
null
null
null
We want to display a random number between 1 and 10 using Python. Write a program for that.
import random randomNumber = random.randint(1, 10) print(randomNumber)
null
Write a SQL query to find all rows in a table with a column value of 'John'.
SELECT * FROM table WHERE column = 'John';
null
Create a JavaScript code snippet to get the last three characters from a given string.
str = 'Hello World'
var last3Char = str.substring(str.length - 3); console.log(last3Char);
null
Generate a correct code to compare two date objects
def compare_dates(date1, date2): if date1 > date2: return 1 elif date1 == date2: return 0; else: return -1
null
Given a string of characters, write a function in Python that returns only the uppercase characters.
"Hello, World!"
def get_upper(string): """Return only uppercase characters from given string.""" return ''.join([c for c in string if c.isupper()])
[DE Wikipedia] Neerdar (Wilde Aa) Die Neerdar ist ein 14,6 km langer, nordwestlicher und orographisch linker Zufluss der Wilden Aa (Aar) im Nordostteil des Rothaargebirges. Sie fließt im nordrhein-westfälischen Hochsauerlandkreis und im hessischen Landkreis Waldeck-Frankenberg (Deutschland). Verlauf Die Neerdar entspr...
null
null
null
null
Write a JavaScript program to check whether a particular character is present in a given string or not
String: 'Hello World!' Character: 'l'
function checkChar(str, char) { if (str.indexOf(char) > -1) { return true; } else { return false; } } if (checkChar('Hello World!', 'l')) { console.log('Character is present in the string'); } else { console.log('Character is not present in the string'); }
null
Create an HTML page that displays the contents of a given URL.
https://www.example.com
<html> <head> <title>Loaded URL</title> </head> <body> <iframe src="https://www.example.com" width="100%" height="100%"></iframe> </body> </html>
null
Create an array in Java to store 5 integer values.
int [] numArray = new int[5];
[EN Wikipedia] Purangi River The Purangi River is a river of the Coromandel Peninsula in New Zealand's North Island. It flows north to reach Mercury Bay to the east of Whitianga. See also List of rivers of New Zealand References Thames-Coromandel District Rivers of Waikato Rivers of New Zealand
null
null
null
null
Create a function that takes a list of strings and combines them together into one string
["This", "is", "a", "list", "of", "strings"]
def combineStrings(strings): combined_string = "" for string in strings: combined_string += string + " " return combined_string combined_string = combineStrings(["This", "is", "a", "list", "of", "strings"])
[HI Wikipedia] भूप्रावार भूप्रावार या मैन्टल (अंग्रेज़ी: Mantle) या प्रावार भूविज्ञान में किसी पथरीले ग्रह या प्राकृतिक उपग्रह की एक परत को कहते हैं। यह सबसे बाहरी भूपटल (क्रस्ट) नामक परत के नीचे लेकिन भूकेन्द्र के ऊपर और उसे ढके हुए होती है। भूपटल के मुक़ाबले में भूप्रावार परत बहुत मोटी होती है। हमारी पृथ्वी में भूप्...
null
null
null
null
Create a python program to calculate the average of three numbers.
def average(a,b,c): return (a + b + c) / 3
[EN Wikipedia] Ilja Bereznickas Ilja Bereznickas (born January 1, 1948 in Vilnius, Lithuania) is a Lithuanian animator, illustrator, scriptwriter and caricaturist. Biography In 1970 he graduated in architecture from Kaunas Polytechnic Institute. In 1985 he graduated from the Postgraduate School of Scriptwriters and Fi...
null
null
null
[CS Wikipedia] Josef Vondroušek Josef Vondroušek (1. prosince 1904 Brno – 6. prosince 1995 Brno) byl český bankovní úředník a esperantista. Esperantská činnost Josef Vondroušek se v 28 letech stal tajemníkem Klubu esperantistů v Brně, později byl dlouhá léta jeho předsedou. Zasloužil se o pravidelné klubové přednášky,...
null
null
null
null
Build an AI-powered feature engineering pipeline in Python that takes in a dataset, selects features, and generates a list of features for a given classification task.
Dataset : The dataset contains 4 columns - Age, Gender, Income and Education.
import numpy as np import pandas as pd import scipy from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegression from sklearn.ensemble import ExtraTreesClassifier # Load the data data = pd.read_csv('data.csv') # Separate out the target column X = data.drop('target', axis=1)...
null
Create a python program to check the following string for palindrome
"madam"
def check_palindrome(string): rev_str = string[::-1] if rev_str == string: return "The string is a palindrome" return "The string is not a palindrome" print(check_palindrome("madam"))
[EN Wikipedia] Thomas Baynes Thomas Baynes may refer to: Thomas Mann Baynes (1794–1876), English artist and lithographer Thomas Spencer Baynes (1823–1887), English philosopher
null
null
null
null
Build a function in Python for selecting all rows from a Pandas DataFrame where a column value is equal to a given value.
df = pd.DataFrame({'A':[1, 2, 3, 4, 5], 'B':[2, 3, 4, 5, 6], 'C':[3, 4, 5, 6, 7], 'D':[4, 5, 6, 7, 8]}) col_1 = 'A' value = 3
def select_rows(df, col_1, value): return df[df[col_1] == value]
[HI Wikipedia] संहिता संहिता हिन्दू धर्म के पवित्रतम और सर्वोच्च धर्मग्रन्थ वेदों का मन्त्र वाला खण्ड है। ये वैदिक वाङ्मय का पहला हिस्सा है जिसमें काव्य रूप में देवताओं की यज्ञ के लिये स्तुति की गयी है। इनकी भाषा वैदिक संस्कृत है। चार वेद होने की वजह से चार संहिताएँ हैं (हर संहिता की अपनी अलग अलग शाखा है): ऋग्वेद संहि...
null
null
null
null
Create a Ruby method for calculating the mean of the given array of numbers.
def calculate_mean(numbers) sum = 0 numbers.each { |number| sum += number } return (sum.to_f / numbers.length) end
null
Using the data provided, write a program in Python to determine which city is furthest north.
New York,USA,40.71,-74.00 London,UK,-0.13,51.50 Paris,France,2.35,48.85
cities = [["New York", "USA", 40.71,-74.00], ["London", "UK", -0.13, 51.50], ["Paris", "France", 2.35, 48.85]] def find_furthest_north(cities): furthest_north = cities[0] for city in cities: if city[2] > furthest_north[2]: furthest_north = city return furthest_north furthest_north = find_furthest_nort...
null
Write a function to fill an array of size n with random integers in the range 0...k-1.
def random_fill_array(n, k): arr = [] for _ in range(n): arr.append(random.randint(0, k-1)) return arr
null
Given an array of integers, write a function that returns the index of the smallest number in the array.
array = [3, 1, 9, 6, 17]
def findSmallest(arr): smallest_index = 0 for i in range(1, len(arr)): if arr[i] < arr[smallest_index]: smallest_index = i return smallest_index index_of_smallest = findSmallest(array) print(index_of_smallest) #prints 1
null
Implement a Python program to find all unique combinations of words from a given array of words.
words = ["Test", "Example", "Unique"]
def find_combinations(words): if len(words) == 1: return words combinations = [] for i in range(len(words)): for j in range(len(words)): if i != j: combinations.append(words[i] + words[j]) return combinations combinations = find_combinations(["Test", "Examp...
null
Create a Python script that orders a list of strings alphabetically from a to z.
["Banana", "Apple", "Orange", "Pear"]
def sort_list(list): list.sort() return list sorted_list = sort_list(["Banana", "Apple", "Orange", "Pear"]) print(sorted_list)
null
Design a data structure that can efficiently store the capitals of different countries and their respective populations.
class CountryCapitalPopulation{ HashMap<String, Integer> countryCapPop; public CountryCapitalPopulation(){ countryCapPop = new HashMap<String, Integer>(); } public void addCountryCapitalPopulation(String country, String capital, int population){ countryCapPop.put(country+capital, population); } public int getPopulation...
null
Write a code block in Python to compute the dot product of two vectors.
u = [1, 2, 3] v = [4, 5, 6]
def dot_product(u, v): if len(u) != len(v): raise ValueError("Vectors u and v must be of the same length!") result = 0 for i in range(len(u)): result += u[i] * v[i] return result u = [1, 2, 3] v = [4, 5, 6] print("Dot product of u and v is:" , dot_product(u, v))
[DE Wikipedia] Haberner Steig Der Haberner Steig (tschechisch Haberská stezka), auch bekannt als Haberner Landessteig, war eine der wichtigsten mittelalterlichen Handelsstraßen zwischen Böhmen und Mähren und Teil des Fernhandelswegs von Prag nach Wien. Benannt wurde er nach dem Dorf Habern (tschechisch: Habry), das an...
null
null
null
null
Design an algorithm in Python to determine the highest scoring word in a given text.
The cat runs fast
def highest_scoring_word(text): # Split the text into words words = text.split() # Create a dictionary to store the words # and their corresponding scores scores = {} for word in words: score = 0 for letter in word: score += ord(letter) - 96 s...
null
Program a Python function to calculate the average of a list of integers.
[1, 3, 5, 3, 7, 1]
def avg_list(lst): sum_lst = 0 for i in range(len(lst)): sum_lst = sum_lst + lst[i] return sum_lst/len(lst) print(avg_list([1, 3, 5, 3, 7, 1]))
null
Create a function in C to edit a string. The function should correct all occurrences of two or more consecutive spacets with a single space.
char str[] = "Hi everyone "
void trimSpace(char *str) { int i = 0, j = 0; while (str[i]) { if (str[i] != ' ') str[j++] = str[i]; else if (str[i-1] != ' ') str[j++] = str[i]; i++; } str[j] = '\0'; } trimSpace(str); // str will become "Hi everyone "
null
Create a Python program that sorts the given array of numbers from smallest to largest using the bubble sort algorithm.
arr = [3, 5, 1, 9, 6]
# function to perform bubble sort def bubble_sort(arr): # iterate over a range of the length of the array for i in range(len(arr)): # iterate over the array until the index is equal to the current # iteration of the first loop for j in range(0, len(arr)-i-1): # comp...
null
Write a code snippet to remove all white spaces from a given string in JavaScript.
" Hello World! "
let outputString = "Hello World!"; outputString = outputString.replace(/\s/g, ''); // removes white spaces console.log(outputString);
null
Print the following 2D matrix in row-major order.
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
1 4 7 2 5 8 3 6 9
null
Construct an if-else if condition to grade the user input (1 to 5) between A, B, C, D, or F.
if user_input == 1: print('A') elif user_input == 2: print('B') elif user_input == 3: print('C') elif user_input == 4: print('D') else: print('F')
null
Write a python program to make all the characters of a string into lowercase.
def convert_to_lowercase(string): lowercase_string = "" for char in string: lowercase_string += char.lower() return lowercase_string
null
Suggest a way of replacing all the vowels in a string with a star (*).
string = "Hello World!"
print(''.join([x if x not in 'aeiou' else '*' for x in string])) # Output: H*ll* W*rld!
null
Create a regular expression that matches any URL.
Regex: ^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$
null
Create a Kmeans clustering program in Python for a dataset with 5 numeric featrues and 35 observations.
Example 1st observation data [6.400e+01, -3.800e+01, 2.320e+02, 1.500e+00, 9.400e+00]
import pandas as pd from sklearn.cluster import KMeans data = [[6.400e+01, -3.800e+01, 2.320e+02, 1.500e+00, 9.400e+00], ... ... ... ... ... [2.390e+01, -1.050e+00, 6.400e+01, 4.200e+00, 2.500e+00]] # Create a DataFrame from data df = pd.DataFrame(data, columns=['Featu...
[HI Wikipedia] ओवी ओवी मराठी साहित्य एक प्रकार की लेखनपद्धति है। यह दो प्रकार की होती है- ग्रंथों में प्रयोग की जाने वाली ओवी तथा लोकगीतों में प्रयोग की जानेवाली ओवी। मराठी साहित्य
null
null
null
[CS Wikipedia] Střední Jáva Střední Jáva () je jedna z indonéských provincií. V souladu se svým názvem zabírá centrální část ostrova Jáva. Hlavním a největším městem je Semarang s počtem obyvatel přesahujícím jeden milion, ležící na severu na pobřeží Jávského moře. Střední Jáva zabírá plochu 32 548,20 km² a žije zde z...
null
null
null
[DE Wikipedia] Lan Marie Nguyen Berg Lan Marie Nguyen Berg (* 4. März 1987), häufig auch Lan Marie Berg, ist eine norwegische Politikerin der Miljøpartiet De Grønne (MDG). Von 2015 bis 2021 war sie Byråd für Umwelt und Verkehr in Oslo. Seit 2021 ist sie Abgeordnete im Storting. Im November 2022 wurde sie stellvertrete...
null
null
null
null
Write a function in Python that takes a number, x, and returns True if the number is even or False if the number is odd.
def is_even(x): return x%2 == 0
null
There is a string of code. Can you tell me if there are syntax errors in it?
def foo(): print('bar
true
null
Edit the following SQL statement to select all rows from the "users" table where the "country_id" is 2 and the "level" is greater than 5.
SELECT * FROM users;
SELECT * FROM users WHERE country_id = 2 AND level > 5;
[EN Wikipedia] Bernardas Bučas Bernardas Bučas (1903–1979) was a Lithuanian painter, sculptor, and graphicer. Amongst his works are the statue Agriculture () on the Green Bridge in Vilnius. See also List of Lithuanian painters References 1903 births 1979 deaths 20th-century Lithuanian painters People from Kovno Govern...
null
null
null
[HI Wikipedia] कृषि दर्शन कृषि दर्शन दूरदर्शन पर प्रसारित होने वाला एक भारतीय टेलिविज़न कार्यक्रम है। इस कार्यक्रम का ध्येय किसानों तक कृषि-सम्बन्धी जानकारी पहुँचाना है। दूरदर्शन पर इसका प्रसार २६ जनवरी १९६७ को शुरू हुआ और यह भारतीय टेलिविज़न पर सबसे लम्बी अवधि तक चलने वाले प्रोग्रामों में से एक है। इन्हें भी देखें दू...
null
null
null
null
Create a Python program that encrypts a message using a Caesar cipher.
def caesar_encrypt(message, shift): encrypted_message = "" for c in message: encrypted_c = ord(c) + shift if encrypted_c > 126: encrypted_c -= 94 encrypted_message += chr(encrypted_c) return encrypted_message
[EN Wikipedia] Ernst Palandt Ernst Palandt (7 March 1907 – 6 July 1979) was a German organ builder. Life Born in Bochum, Palandt worked as an organ builder in Halberstadt and Hildesheim between 1933 and 1969. He initially entered into a partnership with Wilhelm Sohnle and operated under the name E. Palandt & Sohnle KG...
null
null
null
null
Create an algorithm in Python to generate a random string of length n using only alphanumeric symbols.
String length of 8
import random # Function to generate random string def get_random_string(length): # Create an empty string letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" random_string = "" # Generate the random string of required length for x in range(length): random_string += random.ch...
null
Create a Python script to visualize the given data.
Weather data, depicting temperature and precipitation
import matplotlib.pyplot as plt # Weather data, depicting temperature and precipitation x = [1, 2, 3, 4, 5] temperature = [30, 28, 33, 32, 29] precipitation = [2.2, .5, 0, 1.2, 0.3] # Plot the data fig = plt.figure() axes = fig.add_axes([0.1, 0.1, 0.8, 0.8]) axes.plot(x, temperature, color='b', label='Temperature') a...
null
Create a dictionary where the keys are the integers up to 10, and the values are the cubes of those same integers.
def create_dict(): cube_dict = {} for i in range(1,11): cube_dict[i] = i**3 return cube_dict
null
Given a list, write a Python code snippet to print the elements of the list in reverse order.
my_list = ["one", "two", "three", "four", "five"]
for element in reversed(my_list): print(element)
null
Write an HTML code snippet to create an unordered list with three list items.
<ul> <li>List item 1</li> <li>List item 2</li> <li>List item 3</li> </ul>
null
Generate a Python object literal from a dictionary.
my_dict = {'a':1, 'b':2, 'c':3}
my_obj = { 'a': 1, 'b': 2, 'c': 3 }
null
Parse the following XML data and print the value of the 'id' key as a string.
<root> <id>123</id> <name>John Doe</name> </root>
String value = '123'
[CS Wikipedia] Izolace DNA Izolace DNA je proces získání DNA ze zkoumaného vzorku pomocí kombinace fyzikálních a chemických metod. Získaná DNA slouží například pro forenzní biologii nebo rekombinantní DNA technologie. DNA byla poprvé izolována roku 1869 Friedrichem Miescherem, v současné době se jedná o rutinní techni...
null
null
null
null
Write an angular directive to highlight the selected word in a text.
myApp.directive('highlight', function() { return { restrict: 'A', link: function(scope, element, attrs) { attrs.$observe('highlight', function(word) { var text = element[0].innerHTML; if (word) { var regex = new RegExp('('+ word +'\\b)', 'gi'); var replacedText = text.replace(regex, '<span class="highlighted">$1</span>...
[HI Wikipedia] मागादान ओब्लास्त मागादान ओब्लास्त (रूसी: Магада́нская о́бласть, अंग्रेज़ी: Magadan Oblast) रूस के साइबेरिया क्षेत्र के सुदूर पूर्व में स्थित रूस का एक संघीय खंड है जो उस देश की शासन प्रणाली में ओब्लास्त का दर्जा रखता है। इसकी राजधानी मागादान शहर है। इसकी सीमाएँ उत्तर में चुकोतका स्वशासित ओक्रुग, पूर्वोत...
null
null
null
[CS Wikipedia] Seznam dílů seriálu Poslední základna Toto je seznam dílů seriálu Poslední základna. Přehled řad Seznam dílů První řada (2012–2013) Externí odkazy Poslední základna
null
null
null
null
Develop an algorithm in Python to print Fibonacci series up to a given number.
def fibonacci(n): a = 0 b = 1 if n < 0: print("Incorrect input") elif n == 0: return a elif n == 1: return b else: for i in range(2,n): c = a + b a = b b = c return b n = int(input("Enter a number: ")...
null
Use this data to predict the weather for the next week.
Current temperature: 34 degrees Humidity: 66% Precipitation chance: 30%
The weather for the next week is predicted to be warm and mostly dry, with only a slight chance of rain scattered throughout the week. Temperatures will remain around the 34 degree mark, and humidity levels should stay fairly moderate, around 66%.
[DE Wikipedia] Barbara Buchner Barbara K. Buchner (* 17. Mai 1974) ist eine österreichische Wirtschaftswissenschaftlerin, Beraterin und Autorin. Sie ist Geschäftsführerin des Programms für Klimafinanzierung der Climate Policy Initiative. Leben Buchner promovierte in Wirtschaftswissenschaften an der Universität Graz. S...
null
null
null
null
Create a customer management system using Python and the Django web framework.
Steps for creating a customer management system using Python and the Django web framework: 1. Create a Django project 2. Add customers app to the project 3. Create a model for customers in the customers app 4. Update the customers app's views function to include the logic for adding, deleting, and updating customers 5....
[EN Wikipedia] 2021–22 Coppa Italia The 2021–22 Coppa Italia (branded as the Coppa Italia Frecciarossa for sponsorship reasons from the second round) was the 75th edition of the national cup in Italian football. The number of participating teams was reduced from 78 of the previous season to 44 clubs. Juventus were the...
null
null
null
null
Create a Python code to classify text into two classes A and B.
dataset = [["This is class A text", "A"], ["This is class B text", "B"]]
# Import the necessary libraries from sklearn.model_selection import train_test_split from sklearn.feature_extraction.text import CountVectorizer from sklearn.feature_extraction.text import TfidfTransformer from sklearn.naive_bayes import MultinomialNB # Extract the data into X (text) and y (labels) X, y = zip(*...
null
prompt the user to enter a number, then output it in a sentence
number = int(input("Enter a number: ")) print("You entered: ", number)
null
Create a program to detect if an array contains duplicate values
def is_duplicate_array(arr): return len(arr) != len(set(arr))
null
Construct a Python program to round the number up to the nearest integer
num = 5.6
def round_up(num): if num == int(num): return int(num) return int(num + 1) num = 5.6 print(round_up(num))
null
Solve this basic algebra problem in Python.
5x - 4 = 35
x = (35 + 4)/5
null
Debug the given python program to output b2 instead of a3.
a1 = 6 a2 = 3 b1 = a1 // a2 a3 = b1 * a2
a1 = 6 a2 = 3 b1 = a1 // a2 b2 = a1 % a2
null
Create an array of five elements using the language of your choice.
my_list = [1, 2, 3, 4, 5]
null
Create a function in Python to search a list for a given item.
list = [1, 2, 3, 4, 5, 6] item = 4
def search_list(lst, item): for i in range(len(lst)): if lst[i] == item: return i return -1 idx = search_list(list, item) if idx == -1: print("Item not found") else: print("Item found at index", idx)
null
Suggest a completion for a python function to find the square of a given number.
def square(num): return num**2
null
Using the JavaScript Math object, calculate the sine of an angle.
angle = 45
"""Using the Math object, calculate the sine of an angle""" angle = 45 sine = Math.sin(angle * Math.PI / 180); console.log(sine); # Output: 0.7071067811865476
[DE Wikipedia] Klotz Valley Das () ist ein Tal am nördlichen Ende der Fildes-Halbinsel von , der größten der Südlichen Shetlandinseln. Durch das breite, flache Tal fließt ein Bach, der den Bellingshausen Dome entwässert; außerdem liegen noch einige Stillgewässer in dem Tal. Das Tal wurde 1996 auf einer chilenischen Ka...
null
null
null
null
Create an algorithm in Python that uses a greedy approach to scheduling tasks. The algorithm should take in a list of tasks and the corresponding deadlines, and output a list of tasks that can be completed without exceeding any deadlines.
[("Task A", 2), ("Task B", 1), ("Task C", 3)]
def schedule_tasks(tasks): scheduled_tasks = [] tasks.sort(key=lambda x: x[1]) # sort tasks by deadline current_time = 0 while len(tasks) > 0: for task in tasks: if current_time + task[1] <= task[2]: # check if the task can be completed before its deadline scheduled_tasks.append(task) # add...
null
Create a Python program that counts the occurrences of each letter of the alphabet in a given sentence.
Sentence: 'The quick brown fox jumps over the lazy dog.'
# Create a dictionary to store the count of each letter letter_counts = {} # Loop through each letter in the given sentence for letter in 'The quick brown fox jumps over the lazy dog.': # Check if the letter is present in the dictionary if letter in letter_counts: # Increment the count if the key i...
null
Create a variable in Python to store 10 multidimensional arrays.
arrays = [[[1,2], [3,4]], [[5,6], [7,8]], [[9,10], [11,12]], [[13,14], [15,16]], [[17,18], [19,20]], [[21,22], [23,24]], [[25,26], [27,28]], [[29,30], [31,32]], [[33,34], [35,36]], [[37,38], [39,40]]]
null
Write a Python function that gets a list of numbers and returns the sum of the elements.
List = [1, 2, 3, 4, 5]
def get_sum(list): total = 0 for num in list: total += num return total
null
Convert a given XML document to JSON document
<?xml version="1.0"?> <root> <person> <name>John Doe</name> <age>22</age> <address> <street>123 Main St.</street> <city>Anytown</city> <state>FL</state> <zip>12345</zip> </address> </person> </root> { "person" : { "name" : "John Doe", "age" : 22, "address" : { "street" : "123 Main St.", "city" : "Anytown", "state" : "F...
null
Develop a machine learning classifier in Python to classify a set of emails as spam or not.
The following emails: 1. "You won the lottery!" 2. "Check out this offer!" 3. "Can you help me with my project?" 4. "Are you free for lunch tomorrow?"
import pandas as pd # Load data into a dataframe emails = pd.DataFrame([ {'text': 'You won the lottery!', 'label': 'spam'}, {'text': 'Check out this offer!', 'label': 'spam'}, {'text': 'Can you help me with my project?', 'label': 'not_spam'}, {'text': 'Are you free for lunch tomorrow?', 'label': 'not_s...
null
Design a function that takes in an integer and prints the multiplication table till that input number.
def print_multiplication_table(n): for i in range(1, n+1): for j in range(1, n+1): print(i*j, end=" ") print() print_multiplication_table(n)
[HI Wikipedia] काव्य काव्य, कविता या पद्य, साहित्य की वह विधा है जिसमें किसी कहानी या मनोभाव को कलात्मक रूप से किसी भाषा के द्वारा अभिव्यक्त किया जाता है। भारत में कविता का इतिहास और कविता का दर्शन बहुत पुराना है। इसका प्रारंभ भरतमुनि से समझा जा सकता है। कविता का शाब्दिक अर्थ है काव्यात्मक रचना या कवि की कृति, जो छन्द...
null
null
null
null
Generate a list of 10 items from the given array.
myArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
null
Write a Python script to fetch the sale price of a product from an online store.
Website = www.productstore.com ProductID = 12345
import requests url = f'https://www.productstore.com/ProductID={ProductID}&format=json' resp = requests.get(url) data = resp.json() sales_price = data['salesPrice'] print('The sale price of the product is {}'.format(sales_price))
null
Create a program that reads 6 numbers from the user and outputs whether they form an increasing subsequence of length 3 or not.
def increasing_subsequence(arr): for i in range(len(arr)-2): if (arr[i] < arr[i+1]) and (arr[i+1] < arr[i+2]): return 'True' return 'False'
null
Create a C++ program that uses command line arguments to print out the argument passed in as a string.
#include <iostream> using namespace std; int main(int argc, char* argv[]) { cout << argv[1]; return 0; }
null
Create a program in C to find the difference between the smallest and the largest number in a given array.
array = { 100, 2, 11, 1, 5, 34, 45 }
#include<stdio.h> // Function to find the difference between smallest and largest element in given array int findDifference(int array[], int n) { int max = 0; int min = array[0]; // Find maximum and minimum element in array for (int i = 0; i < n; i++) { if (array[i] > max) max = array[i]; if (array[i] < min) min = arra...
[DE Wikipedia] Mittelmann Mittelmann ist der Familienname folgender Personen: Fritz Mittelmann (1886–1932), Schriftsteller und Politiker Norman Mittelmann (1932–2019), kanadischer Opernsänger (Bariton) Siehe auch: Mittelsmann-Angriff (in Rechnernetzen)
null
null
null
null
Convert the following SQL query into a Python pandas DataFrame.
SELECT product.name, store.location, store.country FROM product INNER JOIN store ON product.store_id = store.store_id
import pandas as pd df = pd.read_sql_query( 'SELECT product.name, store.location, store.country' 'FROM product' 'INNER JOIN store' 'ON product.store_id = store.store_id', conn )
null
Generate a class in Python that has getters and setters for some public variable.
class SampleClass: def __init__(self): self.public_variable = None def get_public_variable(self): return self.public_variable def set_public_variable(self, value): self.public_variable = value
[HI Wikipedia] नागालैण्ड नागालैण्ड (नागालैंड) भारत का एक उत्तर पूर्वी राज्य है। इसकी राजधानी कोहिमा है, जबकि दीमापुर राज्य का सबसे बड़ा नगर है। नागालैण्ड की सीमा पश्चिम में असम से, उत्तर में अरुणाचल प्रदेश से, पूर्व मे बर्मा से और दक्षिण मे मणिपुर से मिलती है। भारत की 2011 की जनगणना के अनुसार, इसका क्षेत्रफल 16,579 वर...
null
null
null
[DE Wikipedia] Pseudo-Tertullian Pseudo-Tertullian ist der wissenschaftliche Name und damit nur eine nominelle Hilfskonstruktion für den unbekannten antiken Autor des Libellus adversus omnes haereses, eines Anhangs zum Werk De praescriptione haereticorum von Tertullian. In dem Anhang wurden 32 Häresien aufgelistet. In...
null
null
null
[CS Wikipedia] Římskokatolická farnost Dolní Podluží Římskokatolická farnost Dolní Podluží (lat. Grunda) je církevní správní jednotka sdružující římské katolíky na území obce Dolní Podluží a v jejím okolí. Organizačně spadá do děčínského vikariátu, který je jedním z 10 vikariátů litoměřické diecéze. Centrem farnosti j...
null
null
null