text
stringlengths
141
2.89k
⌀
instruction
stringlengths
19
1.5k
⌀
input
stringlengths
0
800
⌀
output
stringlengths
1
2.5k
⌀
[DE Wikipedia] Amalie Christiane von Baden Katharina Amalie Christiane Luise von Baden (* 13. Juli 1776 in Karlsruhe; † 26. Oktober 1823 in Bruchsal) war eine Prinzessin von Baden. Biografie Familie Amalie war die älteste Tochter des Erbprinzen Karl Ludwig von Baden und der Erbprinzessin Amalie von Hessen-Darmstadt un...
null
null
null
null
Code a function in R which concatenates two strings of a given length and returns the resulting string.
let string1 = "Hello"; let string2 = "World"; let length = 10;
concat_strings <- function(string1, string2, length) { return( substr(paste0(string1,string2), 1, length) ) }
null
Write a JavaScript function to create an array with given size and filled with the characters given in second argument.
3, "*"
``` function createArray(size, character) { let arr = []; for (let i = 0; i < size; i++) { arr[i] = character; } return arr; }; ```
null
Optimize the following Python code to compute the sum of even numbers in a list.
my_list = [1, 2, 3, 4, 5, 6] total = 0 for num in my_list: if num % 2 == 0: total += num print(total)
my_list = [1, 2, 3, 4, 5, 6] # sum comprehension total = sum(num for num in my_list if num % 2 == 0) print(total)
null
Write a script in Python to format a date.
import datetime now = datetime.datetime.now().strftime("%d/%m/%Y") print(now)
null
Create an SQL table with four columns and necessary parameters.
CREATE TABLE mytable ( id INTEGER NOT NULL, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, age INTEGER NOT NULL, PRIMARY KEY(id) );
null
Implement Binary Search in Python
[2, 3, 4, 5, 11, 19, 20]
# function to do binary search def binarySearch(array, x): l, r = 0, len(array)-1 while l <= r: mid = l + (r - l)//2; # Check if x is present at mid if array[mid] == x: return mid # If x is greater, ignore left half elif array[mid] < x: l = mid + 1 # If x is smaller, ignore right half else: r = mid - 1 # If we reach he...
[CS Wikipedia] Dehtáře (Žabovřesky) Ves Dehtáře () se nachází v okrese České Budějovice, kraj Jihočeský, zhruba 14 km ZSZ od Českých Budějovic a představuje jednu ze dvou částí obce Žabovřesky. Historie První písemná zmínka o vesnici pochází z roku 1334. Archeologické nálezy však dokládají neolitické sídliště z 5. tis...
null
null
null
null
Convert the following list of strings to a dictionary whose keys are numbers and whose values are strings.
list1 = ["One", "Two", "Three"]
dict1 = {} for i, s in enumerate(list1): dict1[i+1] = s Input: list1 = ["One", "Two", "Three"] Output: dict1 = {1: "One", 2: "Two", 3: "Three"}
null
Generate a Python function that takes a string and reverses its order of characters.
def reverse_string(my_string): reversed_string = '' for i in range(len(my_string) - 1, -1, -1): reversed_string += my_string[i] return reversed_string
null
Write a shell script to print the unique values from an array.
[1, 2, 2, 3, 4, 4, 5]
#!/bin/bash InputArray=(1 2 2 3 4 4 5) echo "Unique values in the array: " echo $(echo "${InputArray[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')
null
Create an algorithm in Python that receives an array of integers and returns an array with the unique values of the input array.
def unique(arr): uniq_arr = [] for x in arr: if x not in uniq_arr: uniq_arr.append(x) return uniq_arr
[EN Wikipedia] Treaty of the Cedars The Treaty of the Cedars was concluded on the Fox River, west of what is today the village of Little Chute, Wisconsin, on September 3, 1836. Under the treaty, the Menominee Indian nation ceded to the United States about of land for $700,000. The Wisconsin cities of Marinette, Oconto...
null
null
null
[HI Wikipedia] अनुरूप संकेत अनुरूप संकेत या एनालॉग सिग्नल (अंग्रेजी:Analog signal), एक सतत संकेत है जिसका समय परिवर्ती गुण (चर) किसी अन्य समय परिवर्ती राशि को निरूपित करता है, यानि यह उस दूसरे समय परिवर्ती संकेत के अनुरूप होता है। उदाहरण के लिए, एक अनुरूप श्रव्य संकेत (एनालॉग ऑडियो सिग्नल) में, संकेत की तात्कालिक वोल्...
null
null
null
[EN Wikipedia] Algorithms (journal) Algorithms is a monthly peer-reviewed open-access scientific journal of mathematics, covering design, analysis, and experiments on algorithms. The journal is published by MDPI and was established in 2008. The founding editor-in-chief was Kazuo Iwama (Kyoto University). From May 2014...
null
null
null
null
Store this JSON data into a database of your choice.
[ { "name": "Bob", "age": 30, "city": "New York" }, { "name": "Alice", "age": 25, "city": "San Francisco" } ]
Using MongoDB: const MongoClient = require('mongodb').MongoClient; const users = [ { "name": "Bob", "age": 30, "city": "New York" }, { "name": "Alice", "age": 25, "city": "San Francisco" } ]; const url = 'mongodb://localhost:27017'; const dbName = 'myDatabase'; MongoClient.connect(url, {useNewUrlParser: true}, (err, cl...
[EN Wikipedia] Prince-Désir Gouano Prince Désiré Gnahoré Gouano (born 24 December 1993), known as Prince-Désir Gouano, is a French professional footballer who plays as a defender. He primarily plays as a centre-back in a four or three man back-line. Club career Le Havre Born in Paris, Gouano began his career with the ...
null
null
null
[DE Wikipedia] Wasserburg Schloß-Nauses Die Wasserburg Schloß-Nauses befindet sich in der Gemeinde Otzberg im südhessischen Landkreis Darmstadt-Dieburg in einem Tal bei etwa 170 m über NN südöstlich des Otzbergs. Nahe der Wasserburg liegen die Örtchen Schloß-Nauses und Ober-Nauses. Geschichte 766 kam das Gebiet um den...
null
null
null
null
For a given list of numbers, write a palindrome checker.
sample = [1, 2, 3, 4, 5, 4, 3, 2, 1]
def is_palindrome(sample): res = True i = 0 j = len(sample) - 1 while i < j: if sample[i] != sample[j]: res = False break else: i += 1 j -= 1 return res
null
Generate a regular expression that matches any number that is greater than 0.
No input
/[1-9]\d*\.?\d*|0\.\d*[1-9]\d*/
null
Create an API using Python Flask that returns a list of customer data fetched from a database. The API should be able to handle requests with query parameters to filter the results based on customer name.
Not applicable
""" Flask API to return customer data """ import sqlite3 from flask import Flask, jsonify, request, g DATABASE = 'customer_database.db' app = Flask(__name__) def get_db(): db = getattr(g, '_database', None) if db is None: db = g._database = sqlite3.connect(DATABASE) return db @app.teardown_appc...
null
Train a machine learning model to classify cats and dogs.
""" Train a machine learning model to classify cats and dogs """ import numpy as np import pandas as pd import matplotlib.pyplot as plt from keras.preprocessing.image import ImageDataGenerator from keras.models import Sequential from keras.layers import Conv2D, MaxPooling2D from keras.layers import Activation, Dropout,...
null
Write a code to create a function to rotate a given linked list.
""" Create a function to rotate a given linked list """ # Create a class node class Node: # Create a constructor to initialise the node object def __init__(self, data): self.data = data self.next = None class LinkedList: # Create a constructor to initialise the linked list def __init__(self): self.head = None # Create ...
null
Edit the following python code such that it can take a list of elements and return the distinct elements in the list
def unique_elements(lst): elements = [] for num in lst: if num not in elements: elements.append(num) return elements
def unique_elements(lst): elements = [] for num in lst: if num not in elements: elements.append(num) return list(set(elements))
null
Develop a web service to convert a temperature value from Fahrenheit to Celsius.
Temperature in Fahrenheit: 98
#!/bin/bash import web urls = ( '/convert', 'ConvertFahrenheitToCelcius' ) app = web.application(urls, globals()) class ConvertFahrenheitToCelcius: def GET(self): web.header('Content-Type', 'text/plain; charset=utf-8') tempFahrenheit = web.input().t tempCelcius = (tempFahrenheit - 32) * (5/9) return str(tempCelcius) if...
null
Create a HTML table element with 4 columns and 5 rows.
<table> <tr> <th>Column1</th> <th>Column2</th> <th>Column3</th> <th>Column4</th> </tr> <tr> <td>Row1</td> <td>Row1</td> <td>Row1</td> <td>Row1</td> </tr> <tr> <td>Row2</td> <td>Row2</td> <td>Row2</td> <td>Row2</td> </tr> <tr> <td>Row3</td> <td>Row3</td> <td>Row3</td> <td>Row3</td> </tr> <tr> <td>Row4</td> <td>Row4</td>...
null
We have a list of numbers and a given sum. Write a program to determine if any two numbers from the list sum up to the given sum.
[1,2,3,4], 6
def two_sum(nums, target): for i in range(len(nums) - 1): for j in range(i+1, len(nums)): if nums[i] + nums[j] == target: return (i, j) return -1
null
Generate code to programmatically generate the Fibonacci Sequence in Python.
Not applicable
def fibonacci(n): a, b = 0, 1 for i in range(n): a, b = b, a + b return a for i in range(10): print(fibonacci(i))
[CS Wikipedia] Anexe Savojska Annexe Savojska je obecný název používaný pro připojení (réunion, podle výrazu použitého ve smlouvě) Savojska (budoucí departmenty Savojsko a Horní Savojsko), tou dobou součástí Sardinského království, k Francii v roce 1860. Stalo se tak na základě dohody mezi oběma zeměmi, kdy Francie zí...
null
null
null
null
Generate a program in Python to print the union of two given sets.
[1, 2, 3], [2, 3, 4, 5]
def union_sets(set1, set2): return list(set(set1) | set(set2)) set1 = [1, 2, 3] set2 = [2, 3, 4, 5] print(union_sets(set1, set2)
null
Create a method that deletes all the empty elements from a given array of strings.
arr = ["a", "", "b", "", "c"]
def delete_empty_elements(arr): return [e for e in arr if e] # Output: ["a", "b", "c"]
null
Use the given test data to debug the following code.
def check_odd_even(number): if number % 2 == 0: print("even") else: print("odd") Test data: 1. number: 4 2. number: -7
Test 1: check_odd_even(4) Output: 'even' Test 2: check_odd_even(-7) Output: 'odd'
[EN Wikipedia] Marlbrook, Virginia Marlbrook is an unincorporated community in Rockbridge County, Virginia, United States. It sits at an elevation of 1204 feet (367 m). References Unincorporated communities in Rockbridge County, Virginia Unincorporated communities in Virginia
null
null
null
[HI Wikipedia] तक्षक हिन्दू पौराणिक कथाओं के अनुसार, तक्षक नागों में से एक नाग जो कश्यप का पुत्र था और कद्रु के गर्भ से उत्पन्न हुआ था श्रृंगी ऋषि का शाप पूरा करने के लिये राजा परीक्षित को इसी ने काटा था। इसी कारण राजा जनमेजय इससे बहुत बिगड़े और उन्होंने संसार भर के नागों का नाश करने के लिये नागयज्ञ आरंभ किया। तक्षक इ...
null
null
null
null
Generate a code to merge two python dictionaries and update the values.
dict_1 = { 'a': 1, 'b': 2 } dict_2 = { 'b': 3, 'c': 4 }
def merge_dicts(dict_1, dict_2): # copy both dictionaries merged_dict = dict_1.copy() merged_dict.update(dict_2) return merged_dict print(merge_dicts(dict_1, dict_2))
null
Using the given data, write a Python program to extract each name along with its age in the following format:
data = [{"name": "John", "age": 25}, {"name": "James", "age": 26}]
for item in data: print(f'Name: {item["name"]}, Age: {item["age"]}')
[CS Wikipedia] Parlamentní volby na Kubě 2018 Parlamentní volby na Kubě 2018 do Národního shromáždění lidové moci Kuby se uskutečnily dne 11. března 2018. Zástupci byli voleni na pětileté funkční období. Jedinou kandidující stranou byla Komunistická strana Kuby. Kandidovat však mohli i lidé bez politické příslušnosti,...
null
null
null
null
Given a list of integers, find the numbers which are greatest than the given number X.
List: [-3, 0, 3, 5, 9], X = 4
function greaterThan(list, x) { let result = []; for (let i=0; i<list.length; i++) if (list[i] > x) result.push(list[i]); return result; }
null
What is the data structure of a hash table?
A hash table is a data structure that maps keys to values using a hash function. It is composed of a key-value pair, where the key is used to locate a specific item in the table, and the value is the item itself.
null
Create a JavaScript object with two properties and their respective values.
var myData = { name: 'John', age: 28 };
[CS Wikipedia] Jan Kašpar (herec) Jan Kašpar (6. září 1952 Praha – 11. června 2013 Praha) byl český divadelní a filmový herec a komik, dlouholetý člen Divadla Járy Cimrmana. Život Byl vyučeným zámečníkem, ale hned po vojenské službě nastoupil do Městských divadel pražských jako kulisák. V roce 1975 odtud musel odejít ...
null
null
null
null
In Python, generate a 3 layer feed-forward neural network for a binary classification problem.
# import necessary libraries import numpy as np from keras.layers import Dense from keras.models import Sequential # define model model = Sequential() # first layer model.add(Dense(16, activation='relu', input_dim=2)) # second layer model.add(Dense(8, activation='relu')) # output layer model.add(Dense(1, activation='s...
null
Develop a user interface in python tkinter to add, modify, and delete items from a list.
# imports import tkinter as tk # window config win = tk.Tk() win.title("list operations") # list variable data = [] # functions def add_item(): data.append(txt_input.get()) refresh_list() def delete_item(): data.remove(lst_data.get(tk.ACTIVE)) refresh_list() def modify_item(): data[lst_dat...
null
Using the existing code as guidance, add a 2nd player and 2nd input field to the game.
playername1=input("What is your name? ") player_score1=0 if turn==1: player_score1+=1 print("It is now " + playername1 + " turn. You have " + str(player_score1) + " points")
playername1=input("What is your name? ") playername2=input("What is your opponent's name? ") player_score1=0 player_score2=0 if turn==1: player_score1+=1 if turn==2: player_score2+=1 print("It is now " + playername1 + "'s turn. You have " + str(player_score1) + " points") print("It is now " + playername2 + "'s turn. Yo...
null
Build an artificial neural network in Python to predict the price of a house
import numpy as np from tensorflow.keras import models, layers #create basic model def create_model(): model = models.Sequential() model.add(layers.Dense(128, activation = 'relu', input_dim = 18)) model.add(layers.Dense(64, activation = 'relu')) model.add(layers.Dense(32, activation = 'relu')) mode...
null
Write a Python program for finding the root of a given quadratic equation.
a = 1, b = 5, c = 4
def quadratic(a, b, c): # calculate the discriminant d = (b**2) - (4*a*c) # find the two roots root1 = (-b-d**0.5)/(2*a) root2 = (-b+d**0.5)/(2*a) return root1, root2
null
Create a function to evaluate a given expression written in infix notation.
exp = "5 + (7 * 8) / 3"
def eval_exp(exp): stack = [] for char in exp: if char in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" or char in "0123456789": stack.append(char) else: val1 = stack.pop() val2 = stack.pop() stack.append(str(eval(val2 + char + val1))) return int(stack.pop()) print(eval_exp(exp))
null
Write a code to print the common elements of two given arrays
arr1 = [2, 3, 4, 5] arr2 = [3, 6, 7, 8]
def common_elements(arr1, arr2): common = [] for i in arr1: if i in arr2: common.append(i) return common
null
Generate an SQL query that returns the names of all employees who are engineers.
SELECT name FROM Employees WHERE title = 'Engineer'
[EN Wikipedia] Henry Hervey Henry Hervey may refer to: Henry Hervey, 1st Baron Hervey, of the Barons Hervey Henry Hervie, Archdeacon of Middlesex See also Henry Harvey (disambiguation)
null
null
null
null
Develop an algorithm in Python to find the average of four numbers.
[2, 4, 8, 5]
def avg(numbers): sum = 0 for num in numbers: sum += num return sum/len(numbers) average = avg([2, 4, 8, 5]) print(average)
null
Write a Python program to replace all empty strings in a given list with "NULL".
data = ["A", "", "B", "", "C", ""]
data = ["A", "NULL", "B", "NULL", "C", "NULL"] ## new_data = [] for i in data: if i == "": new_data.append("NULL") else: new_data.append(i) print(new_data)
null
Create a class named 'Animal' with one private data member 'numberOfLegs'.
public class Animal { private int numberOfLegs; }
null
Create a Python program to generate a multiplication table.
def generate_table(): for i in range(1, 11): for j in range(1, 11): print('{0} x {1} = {2}'.format(i, j, i*j)) print('\n')
null
Write a SQL query that outputs the names of all the students in a given table sorted in descending order
SELECT name FROM students ORDER BY name DESC;
null
Identify the type of data present in the given JSON string.
String: [true, false, 0, "Sample String"]
Boolean, Boolean, Integer, String.
null
Create a Python script that monitors a given URL and sends an email notification if there is an error while accessing the resource
""" Create a Python script that monitors a given URL and sends an email notification if there is an error while accessing the resource """ import requests import smtplib # Monitor the URL URL = 'https://example.com' response = requests.get(URL) status_code = response.status_code # Send an email if there is an error ...
null
Optimize the following Python function. The function calculates the sum of squares of two given numbers.
def SumOfSquares(x,y): result = x**2 + y**2 return result
def SumOfSquares(x, y): return x * (x + y) + y * y
null
Generate a function in Python for generating a random integer between two given numbers (inclusive).
import random def random_integer(start, end): return random.randint(start, end)
null
Write a JavaScript program to convert a given number of seconds into the equivalent time in days, hours, minutes and seconds.
15000
let totalSeconds = 15000; let days = Math.floor(totalSeconds / (24*60*60)); let remainingSeconds = totalSeconds % (24*60*60); let hours = Math.floor(remainingSeconds / (60*60)); let remainingSeconds2 = remainingSeconds % (60*60); let minutes = Math.floor(remainingSeconds2 / (60)); let seconds = remainingSeconds2 % (60)...
null
Using a while loop, create a Python program that prints the Fibonacci sequence from 0 to 100.
a, b = 0, 1 while b <= 100: print(b) a, b = b, a+b
null
Construct an SQL query to read the contents of a table called "users".
SELECT * FROM users;
null
Find the maximum subarray sum in an array of integers.
arr = [-2, -3, 4, -1, -2, 1, 5, -3]
def max_subarray_sum(arr): """This function takes an array of integers and returns the maximum subarray sum """ current_max = arr[0] overall_max = arr[0] for num in arr[1:]: current_max = max(current_max + num, num) overall_max = max(current_max, overall_max) return overall_max # Example Usage arr = [-2, -3, 4, -1, -2,...
null
Generate a web service in Python Flask to provide the weather data for a given date and region.
# Import packages from flask import Flask, jsonify, request import requests # Create Flask app app = Flask(__name__) # Make a GET request to fetch weather data for a given date and region @app.route('/weather', methods=['GET']) def get_weather_data(): region = request.args.get('region') date = request....
null
Output the Fibonacci sequence from 0 to 15.
The Fibonacci sequence from 0 to 15 is 0, 1, 1, 2, 3, 5, 8, 13.
null
Create a new Python list containing the square of the values in the given list.
[2, 4, 6]
new_list = [4, 16, 36]
null
Write a HTML web page with a heading, paragraph, and a form with two input fields, one for name and one for age.
<html> <head> <title>Example HTML</title> </head> <body> <h1>Heading</h1> <p>This is a paragraph.</p> <form> Name: <input type="text" name="name" /> Age: <input type="number" name="age" /> <input type="submit" /> </form> </body> </html>
[EN Wikipedia] Alexander Graham Bell Alexander Graham Bell (, born Alexander Bell; March 3, 1847 – August 2, 1922) was a Scottish-born inventor, scientist and engineer who is credited with patenting the first practical telephone. He also co-founded the American Telephone and Telegraph Company (AT&T) in 1885. Bell's fa...
null
null
null
null
Implement a method in C# that reverses the digits of an integer.
public static int ReverseDigits (int num) { int result = 0; while (num > 0) { int temp = num % 10; result = (result * 10) + temp; num = num / 10; } return result; }
null
Create a program in Java that sort a given array using bubble sort algorithm.
Array: [4, 3, 5, 2, 1]
public static void bubbleSort(int[] arr) { int n = arr.length; int temp = 0; for(int i=0; i < n; i++){ for(int j=1; j < (n-i); j++){ if(arr[j-1] > arr[j]){ temp = arr[j-1]; arr[j-1] = arr[j]; arr[j] = temp; } } } }
null
Use a for-loop in PHP to generate a random number between 0 and 10.
<?php for ($i=1; $i<=10; $i++){ $rand_num = rand(0, 10); echo $rand_num . "\n"; } ?>
null
Create a class in Python which implements a binary search tree for integers and a method to print the results.
Not applicable
class Node: def __init__(self,value): self.left = None self.right = None self.value = value class BinarySearchTree: def __init__(self): self.root = None # Insert nodes to the binary search tree. def insert(self,value): new_node = Node(value) if self....
null
Make a class in Python which will represent a binary search tree.
class BinarySearchTree: def __init__(self, value): self.left = None self.right = None self.value = value def inorder(self): if self.left: self.left.inorder() print(self.value) if self.right: self.right.inorder() def insert(self, value): if value <= self.value: if self.left is None: self.left = BinarySearchTree(value) e...
null
Write a CSS style for a h3 heading to always have a purple background and white text color.
h3 { background-color: purple; color: white; }
null
With given input string, create a program that returns a new string with the first character capitalized.
hello world
def capitalize(text): return text[0].upper() + text[1:]
[DE Wikipedia] Plymouth (Vermont) Plymouth ist eine Town im Windsor County des Bundesstaates Vermont in den Vereinigten Staaten mit 641 Einwohnern (laut Volkszählung von 2020). Geografie Geografische Lage Plymouth liegt in Zentral-Vermont inmitten der Green Mountains. Im Gebiet der Town entspringen mehrere Flüsse, so ...
null
null
null
[CS Wikipedia] Chvála Chvála může být: vyslovená, psaná nebo přednesená pochvala, kladně hodnocená lidská činnost římskokatolický pozdrav Chvála Kristu křesťanský chvalozpěv, vzdaní chvály Hospodinu příjmení Emanuel Chvála (1851–1924), český hudební kritik a skladatel Jan Chvála (1981–2021), český sportovní lezec a mi...
null
null
null
[HI Wikipedia] हिन्दी समाचारपत्र (Official/Personal) भारत के प्रमुख हिन्दी समाचारपत्र हैं :- हिन्दुस्तान (समाचार पत्र) चौथी दुनिया पाञ्चजन्य नई दुनिया नवभारत टाइम्स आज प्रभात खबर अमर उजाला प्रयुक्ति जलते दीप दैनिक जागरण जनसत्ता पंजाब केसरी देशबन्धु दैनिक भास्कर हरिभूमि राँची एक्सप्रेस राजस्थान पत्रिका स्वतंत्र भारत दी...
null
null
null
null
Generate a program using Python which collects environmental data from a list of cities and organizes it in a table.
Cities: New York, Los Angeles, San Francisco, Chicago
""" Generate a program using Python which collects environmental data from a list of cities and organizes it in a table. """ import requests # API key for openweathermap KEY = '123456789' def get_weather_data(cities): weather_data = [] for city in cities: url = 'http://api.openweathermap.org/data/2....
null
Generate a Python script to cluster handwritten numbers by a given similarity metric.
# import the necessary libraries import matplotlib.pyplot as plt from sklearn.cluster import KMeans from sklearn.datasets import load_digits # load the digits dataset digits = load_digits() # define the clustering model kmeans_model = KMeans(n_clusters=10, random_state=42) # fit the model to the digits dataset kmea...
null
Create a basic class in Python with three properties and a constructor.
class MyClass: def __init__(self, data1, data2, data3): self.data1 = data1 self.data2 = data2 self.data3 = data3
null
What should be the return type of the following function in Java?
public int add(int a, int b) { return a + b; }
int.
null
Create a function to calculate the sum of a sequence of integers.
[1, 2, 3, 4, 5]
# Python code def sum_sequence(sequence): sum = 0 for num in sequence: sum += num return sum
null
Generate a random string of 10 characters with two vowels, three consonants and five digits.
import random def generate_string(vowels,consonants,digits): s = '' for _ in range(vowels): s+=random.choice('aeiou') for _ in range(consonants): s+=random.choice('bcdfghjklmnpqrstvwxyz') for _ in range(digits): s+=str(random.randint(0,9)) return s print(generate_string(2,3,5))
null
Write an SQL query to find the maximum salary of an employee in the same department as the given employee.
Employee name: ‘John Doe’ Department: ‘Finance’
SELECT MAX(salary) FROM employees WHERE department = 'Finance' AND NOT employee_name = 'John Doe';
null
Write a Python script to detect if two numbers have the same frequency of digits.
def same_frequency(num1,num2): str1 = str(num1) str2 = str(num2) if len(str1) != len(str2): return False dict = {} for char in str1: if char in dict: dict[char] += 1 else: dict[char] = 1 for char in str2: if not char in dict: return False dict[char] -= 1 for k in dict: if dict[k] != 0: return False return True
[CS Wikipedia] Xenopithecus koruensis Xenopithecus koruensis je druh vyhynulých úzkonosých primátů, žijících v časném miocénu (před 19 – 20 miliony let) v západní části dnešní Keni. Byl popsán v roce 1933 na základě pouze jednoho zlomku horní čelisti z lokality Legetet u obce Koru. Dosud nebyly další ostatky tohoto ro...
null
null
null
[DE Wikipedia] Hofwiesenpark Der Hofwiesenpark ist eine Parkanlage in Gera in Thüringen, der die westliche Innenstadt vom Stadtteil Untermhaus trennt. Benannt ist der Park nach seiner Lage am Berg mit dem ehemaligen Schloss Osterstein. Im Park befinden sich ein Hallenbad (Hofwiesenbad) und das Stadion der Freundschaft...
null
null
null
null
Develop a web resource monitor in Python that records the amount of data transferred from a given web resource.
import requests def monitor_web_resource(url): response = requests.get(url) total_data = 0 while response.status_code == 200: total_data += len(response.content) response = requests.get(url) return total_data total_data = monitor_web_resource("http://example.com")
[DE Wikipedia] Rhäden Der Rhäden ist ein Feuchtgebiet in Hessen und Thüringen im Gebiet der Gemeinde Wildeck (Landkreis Hersfeld-Rotenburg, Hessen) und der Stadt Werra-Suhl-Tal (Wartburgkreis, Thüringen). Der Landes- und Gemeindezugehörigkeit entsprechend unterteilt sich das Gebiet in die Naturschutzgebiete Dankmarshä...
null
null
null
[HI Wikipedia] पारो-भूटान पारो (जोंगखा; སྤ་རོ་) भूटान की पारो घाटी में स्थित एक नगर और पारो जिले का मुख्यालय है। यह एक ऐतिहासिक नगर है जिसमें कई पवित्र स्थल और ऐतिहासिक इमारतें बिखरी हुई हैं। भूटान का एकमात्र अंतर्राष्ट्रीय हवाई अड्डा, पारो हवाई अड्डा भी यहीं स्थित है। भूटान के आबाद स्थान
null
null
null
null
Write a code to convert HTML to Markdown using Python.
import markdown import re def convert_html_to_markdown(html): lines = html.split('\n') for line in lines: line = markdown.markdown(line) # remove HTML tags line = re.sub(r'<[^>]*>', '', line) # strip whitespace line = line.strip() print line html = '<p>This is an example of HTML text.</p>' convert_html_to_markdown(html...
null
Create a basic HTML page with a title, a heading and a brief introduction to yourself.
My name is John Doe, I am an engineer and webdeveloper.
<html> <head> <title>Introducing John Doe</title> </head> <body> <h1>Introducing John Doe</h1> <p> Hi, I'm John Doe. I am an engineer and webdeveloper with 20 years of experience. I have worked on projects for some of the biggest companies in the world, and I'm proud to say that I have always delivered quality work. I'...
null
Write a CSS rule to change the font color of the h1 element to green.
h1 { color: green; }
null
Create a Python script to generate the following pattern:
for i in range(1,6): for j in range(1,i+1): print("*", end=" ") print()
null
Using SQL, write a query to get the last three rows from a table.
Table name: "customer"
SELECT * FROM customer ORDER BY id DESC LIMIT 3;
null
Create a Python program that calculates the longest increasing subsequence of an array.
[10, 22, 9, 33, 21, 50, 41, 60, 80]
def longest_increasing_subsequence(nums): n = len(nums) lengths = [1] * n for i in range(n): for j in range(i): if nums[j] < nums[i]: lengths[i] = max(lengths[i], lengths[j] + 1) longest_increasing_subsequence_length = max(lengths) return longest_increasing_subsequence_length nums = [10, 22, 9, 33, 21, 50...
null
Create a function in Python that takes two parameters, x and y, and prints out all numbers between x and y.
def display_numbers(x, y): for i in range(x,y+1): print(i)
[HI Wikipedia] प्राचीन इतिहास प्राचीन इतिहास अतीत की घटनाओं का समुच्चय है। इसकी शुरआत दर्ज किये गए मानव इतिहास से प्रारंभिक मध्य युग, यहाँ तक कि वैदिक युग तक विस्तृत है। इतिहास की अवधि 5000 साल है जिसकी शुरुआत सुमेरियन क्यूनीफ़ॉर्म लिपि, जो 30 वीं सदी की प्राचीनतम व सुसंगत लेखन पद्दति से होती है। सन्दर्भ प्राचीन इतिहा...
null
null
null
null
Generate a python program to modify all the characters in a string to lowercase
string = "HELLO WORLD"
def to_lowercase(string): lowercase_string = "" for char in string: lowercase_string += char.lower() return lowercase_string if __name__ == '__main__': string = "HELLO WORLD" print(to_lowercase(string))