text
stringlengths
141
2.89k
⌀
instruction
stringlengths
19
1.5k
⌀
input
stringlengths
0
800
⌀
output
stringlengths
1
2.5k
⌀
null
Create a Python script that connects to a MySQL database. The script should query the database for the list of available tables and print them out.
Not applicable
import pymysql # Connect to the database conn = pymysql.connect(host='localhost', user='username', password='password', db='my_database') # Create a cursor cursor = conn.cursor() # Execute the query cursor.execute('SHOW TABLES') # Fetch and print out the list of tables tables = cursor.fetchall() for table in tabl...
null
Write a Python program to print all integer numbers from a given range.
from 1 to 10
for i in range(1, 11): print(i)
null
Create a Python program that adds logic programming (Prolog) syntax and resolution into Python. Define a Struct class that takes a database, head, and subs as input and adds it to the database. Implement unary + to insert into the database as fact, unary ~ to insert into the database as a query, and << to add a conditi...
# # pythologic2.py # # Add logic programming (Prolog) syntax and *resolution* into Python. # # (c) 2004 Francisco Coelho # after (c) 2004 Shai Berger # and AIMA examples # import string import copy class Struct: def __init__(self, database, head, subs): """ The head and subs are essential - what...
null
Sort the array of strings lexicographically.
arr = ["james", "john", "bob", "michelle"]
def sort_strings_lexicographically(arr): return sorted(arr)
[EN Wikipedia] Modern Art (Matthew Sweet album) Modern Art is the eleventh studio album by alternative rock musician Matthew Sweet. It was released on Missing Piece Records in 2011. Release The album, available as a CD, 2-LP vinyl set, and digital download, was met with little commercial success, but with favorable re...
null
null
null
null
Write a Python program convert a list with nested levels of tuples and lists into a list of strings.
input_list = [('a', 'b', ('c', ['d', 'e', 'f'])), 'g', ['h', ['i', 'j']]]
output_list = [] def flatten_list(my_list): for item in my_list: if isinstance(item, list): flatten_list(item) elif isinstance(item, tuple): flatten_list(list(item)) else: output_list.append(item) flatten_list(input_list) print(output_list)
null
Construct a function in Java that takes a sequence of numbers and finds the maximum value in the sequence.
public static int findMax(int[] sequence) { int maxVal = Integer.MIN_VALUE; for (int val : sequence) { if (val > maxVal) { maxVal = val; } } return maxVal; }
null
Create a list of HTML tags using the Python language.
html_tags = ["a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio", "b", "base", "basefont", "bdi", "bdo", "big", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "dir", "div", ...
null
Create a program in Python to generate a list of prime numbers up to N
def prime_list(N): isPrime = [True for i in range(N + 1)] p = 2 while p * p <= N: if isPrime[p]: for i in range(p * p, N + 1, p): isPrime[i] = False p += 1 prime_nums = [] for p in range(2, N): if isPrime[p]: prime_nums.append(p) re...
[HI Wikipedia] सिलीगुड़ी सिलीगुड़ी (Siliguri) भारत के पश्चिम बंगाल राज्य के जलपाईगुड़ी ज़िले और दार्जीलिंग ज़िले (दोनों) में स्थित एक शहर है। इस से 35 किमी पूर्व में जलपाईगुड़ी बसा हुआ है, और दोनों शहरों में विस्तार के कारण इनका एक बृहत-नगरीय क्षेत्र में विलय होता जा रहा है। विवरण रेल और राजपथ का अंतस्थ होने के कारण, ...
null
null
null
null
Create a bash shell script that assigns two variables with values of 4 and 2 and prints the sum of the two variables.
#!/bin/bash a=4 b=2 echo 'the sum is' $(($a + $b))
null
Suggest an approach to debug a function written in Javascript that is not returning the expected result.
One approach to debug the function would be to use console.log statements to print out the values of the variables inside the function. This would help identify where the problem is and what needs to be changed in order to get the expected result.
null
Create a Python function to shuffle a list of numbers.
[1, 2, 3, 4, 5]
import random def shuffle_list(nums): random.shuffle(nums) return nums shuffled_list = shuffle_list([1, 2, 3, 4, 5]) print(shuffled_list) #[3, 5, 2, 4, 1]
null
Find the Fibonacci number for a given number using a for loop.
def fibonacci(n): fibonacci_numbers = [0,1] for i in range(2, n+1): fibonacci_numbers.append(fibonacci_numbers[i-1] + fibonacci_numbers[i-2]) return fibonacci_numbers[n]
null
Write a C++ program that takes two 2D arrays and compares them for equality.
arr1 = [[1,2], [2,4]] arr2 = [[1,2], [2,4]]
#include <iostream> #include <array> bool areEqual (std::array<std::array<int,2>,2> first, std::array<std::array<int,2>,2> second ) { if( first.size() != second.size() ) return false; for(int i = 0; i < first.size(); i++) { for(int j = 0; j < first[i].size(); j++) { if( first[i][j] != second[i][j] ) return false; } } r...
null
Program a function to add three integers and return the sum.
2, 3 and 6
def addThree(a, b, c): return a + b + c sum = addThree(2, 3, 6)
null
Using the list and additional libraries, write a python program to calculate the sum of all elements in the list.
list = [2, 3, 5, 8, 9]
#Importing the libraries import numpy as np #Defining the list list = [2, 3, 5, 8, 9] #Calculating the sum sum = np.sum(list) #Printing the result print(sum)
null
Write a function in Python to generate a random integer between two numbers, a and b.
a = 4 b = 15
import random def random_int_generator(a, b): return random.randint(a, b)
null
Suggest a regex pattern to match a valid alphanumeric string.
^[a-zA-Z0-9]+$
null
Write an SQL query to select the first five items from a table called 'products' sorted by price in descending order.
SELECT * FROM products ORDER BY price DESC LIMIT 5;
[HI Wikipedia] कीवू झील कीवू झील (अंग्रेज़ी: Lake Kivu) महान अफ़्रीकी झीलों में से एक है। यह कांगो लोकतान्त्रिक गणराज्य और रवाण्डा की अंतरराष्ट्रीय सीमा पर स्थित है। दृश्य इन्हें भी देखें महान अफ़्रीकी झीलें सन्दर्भ महान अफ़्रीकी झीलें अफ़्रीका की झीलें कांगो लोकतान्त्रिक गणराज्य की झीलें रुआण्डा की झीलें
null
null
null
[DE Wikipedia] Key Pittman Key Pittman (* 19. September 1872 in Vicksburg, Mississippi; † 10. November 1940 in Reno, Nevada) war ein US-amerikanischer Politiker. Biografie Frühes Leben Key Pittman wuchs in privilegierten Verhältnissen auf, der unter anderem von Privatlehrern erzogen wurde, und später die Southwestern ...
null
null
null
null
Write a python program to return the average value of numbers in the given list.
numbers = [2, 4, 6, 8]
def avg_list(numbers): total = 0 for x in numbers: total += x return total / len(numbers)
null
Explain what a stack overflow is and how to try to avoid it.
A stack overflow is an error condition in which the program attempts to use more memory space than the stack can hold. It occurs when a program pushes more data onto the stack than the maximum limit (e.g., when a recursive function recurses too many times), or when the recursive calls are too deeply nested. To avoid st...
[HI Wikipedia] शिक्षा शिक्षा का मतलब ज्ञान,सदाचार,उचित आचरण,तकनीकी शिक्षा तकनीकी दक्षता,विद्या आदि को प्राप्त करने की प्रक्रिया को कहते हैं। शिक्षा में ज्ञान, उचित आचरण और तकनीकी दक्षता, शिक्षण और विद्या प्राप्ति आदि समाविष्ट हैं। इस प्रकार यह कौशलों (skills), व्यापारों या व्यवसायों एवं [[तंत्रिका विकास|मानसिक]Kartikk...
null
null
null
null
Create a program to detect plagiarism using Python.
import difflib def detect_plagiarism(text1, text2): sequenceMatcher = difflib.SequenceMatcher(None, text1, text2) matchPercentage = sequenceMatcher.ratio() * 100 return matchPercentage detect_plagiarism("This is a sample text", "This is a sample text.")
null
Edit the given Python code to format the output as a table using tabulate.
fruits = ["apple", "orange", "pineapple", "melon"] for fruit in fruits: print(fruit)
import tabulate fruits = ["apple", "orange", "pineapple", "melon"] table = [(fruit,) for fruit in fruits] print(tabulate.tabulate(table, headers=["Fruits"])) # Output: # Fruits # apple # orange # pineapple # melon
[HI Wikipedia] जर्नल ऑफ़ हाई एनर्जी फिजिक्स जर्नल ऑफ़ हाई एनर्जी फिजिक्स उच्च ऊर्जा भौतिकी के क्षेत्र को समाविष्ट करने वाला सहकर्मी समीक्षा वैज्ञानिक पत्रिका है। यह इंटरनेशनल स्कूल फॉर एडवांस्ड स्टडीज की ओर से स्प्रिंगर विज्ञान + व्यापार मीडिया द्वारा प्रकाशित होता है। बाहरी कड़ियाँ पत्रिका पृष्ठ नाभिकीय भौतिकी भौतिकी...
null
null
null
null
Design a Python program to print all prime numbers between 0 and a given number.
30
def is_prime(num): #Ignore negative numbers and zero if num < 2: return False #Return true if num is prime for i in range(2, num): if num % i == 0: return False return True #Print all prime numbers between 0 and a given number num_input = int(input("Enter a number: ...
null
Create a JavaScript function to validate if a given string is a valid URL.
function isValidUrl(url) { const regex = new RegExp("^(http|https)://"); return regex.test(url); } // Example Usage let url = "https://example.com"; let result = isValidUrl(url); console.log(result); // should be true
[CS Wikipedia] Židovský hřbitov v Trhovém Štěpánově Židovský hřbitov se nachází jižně od města Trhový Štěpánov v okrese Benešov ve Středočeském kraji od roku 1434. Od 3. května 1958 je chráněnou kulturní památkou České republiky. Historie a popis Areál hřbitova je podélného tvaru se vstupem ze západní a východní stran...
null
null
null
null
Develop a Python program to decrypt the given messages using a key?
message: "AB cDE@5sfg90~!", key: 6
def decrypt(message, key): decrypted_message = "" for char in message: ascii_value = ord(char) decrypted_char = chr(ascii_value - key) decrypted_message += decrypted_char return decrypted_message message = "AB cDE@5sfg90~!" key = 6 decrypted_message = decrypt(message, key...
null
Generate Python code to print the first 10 numbers from 10 to 19, seperated by commas.
for i in range(10,20): if i == 19: print(i, end = '') else: print(i, end = ', ')
null
Build a REST API with Python and Flask. The API should include the following endpoints: POST /users, GET /users/{userId}, GET /users/{userId}/posts, POST /posts
Not applicable
# Importing libraries import flask from flask import Flask, request, jsonify # Creating the application instance app = Flask(__name__) # A list to store users data temporarily users = [] @app.route('/users', methods=['POST']) def add_user(): data = request.get_json() users.append(data) return jsonify({'message': ...
[EN Wikipedia] Talbot River (New Zealand) The Talbot River is a river in northern Fiordland, New Zealand. A tributary of Joes River, it rises west of Gulliver Peak. See also List of rivers of New Zealand References Rivers of Fiordland
null
null
null
[CS Wikipedia] Pieter Anthonisz. van Groenewegen Pieter Anthonisz. van Groenewegen (1590/1600–1658) byl nizozemský malíř krajinář. Narodil se v nizozemském městě Delft. Věnoval se především krajinomalbě. Odcestoval do Itálie, kde žil někdy mezi roky 1615–1623 na Via Bocca de Leone v Římě. Stal se členem uměleckého spo...
null
null
null
[EN Wikipedia] Sarah Lindsay Schmidt Sarah Lindsay Schmidt (August 24, 1877 – January 31, 1965) was an American writer of children's literature. Her book New Land was a Newbery Honor recipient in 1934. Biography Sarah Lindsay was born in Chicago, Illinois, on August 24, 1877. Her grandfather, Thomas Milner, had been t...
null
null
null
null
Suggest a completion to the following React component.
import React from 'react'; class MyComponent extends React.Component { constructor(props) { super(props); this.state = {
import React from 'react'; class MyComponent extends React.Component { constructor(props) { super(props); this.state = { name: '', age: 0 }; } }
[DE Wikipedia] Corruption Corruption (engl. „Korruption“) ist ein politischer Porno-Thriller. Die Produktion des Films kostete mehr als 150.000 US-Dollar; damit zählt Corruption zu den teureren Produktionen der Branche. Bryn Pryor wird in den Sexszenen von Chris Cannon gedoubelt. Inhalt Der Film wird mit einem Zitat v...
null
null
null
null
Modify the existing Python code below so that it returns the sum of odd numbers less than the input n.
n = 10 def sum_odd_numbers(n): result = 0
def sum_odd_numbers(n): result = 0 for i in range(n): if i % 2 != 0: result += i return result
null
Implement a search algorithm in Java.
public class SearchAlgorithm { public int search(int[] array, int target) { int left = 0; int right = array.length - 1; while (left <= right) { int mid = (left + right) / 2; if (target == array[mid]) { return mid; } if (target < array[mid]) { right = mid - 1; } else { left = mid + 1; } } return -1; } }
null
Assign a variable 'name' with a value of your choice in JavaScript.
let name = "John";
null
Generate a Python script to classify emails into spam/ham categories.
import pandas as pd import numpy as np from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.naive_bayes import MultinomialNB from sklearn.model_selection import train_test_split # Read the data df = pd.read_csv('data.csv') # Split the data into features and labels features = df['text'] labels = df...
null
This code audits a user table and compares the current date to the last password update. If the last update exceeds the threshold, it sends a notice to the users. To use this code, define the imported libraries, turn the mail function on or off, define today and lookback day, define msg as multipart, application, and m...
#!/usr/bin/python2.7 -Wd ''' file:user_audit.py use: audits users table and compares current date to last password update if last update exceeds threshold send a notice to users author: ty.talmadge@gmail.com date: 20131002 connector: mysqldb because the SQL only changes per table layout ''' # define imported librar...
null
Write a python program to classify a given sentence into positive or negative
""" Program to classify a sentence into positive or negative """ def classify_sentence(sentence): """Classifies a given sentence into positive or negative Args: sentence (str): The sentence to be classified Returns: str: 'positive' or 'negative' """ tokenized_sentence = sentence.s...
null
Write a REST API endpoint handler to get the latest books from a database.
@app.route("/books/latest", methods=["GET"]) def get_latest_books(): cursor = conn.cursor() query = "SELECT * FROM books ORDER BY id DESC LIMIT 10;" cursor.execute(query) books = cursor.fetchall() return jsonify(books)
null
Generate a Python program to print out all possible permutation of a given list of elements.
[1, 2, 3]
def permutations(input_list): if len(input_list) == 1: return input_list output_list = [] for value in input_list: temp_list = input_list[:] temp_list.remove(value) permutations_list = permutations(temp_list) for sub_list in permutations_list: output_list....
null
Given input strings s and t, find the length of the longest common substring.
s = "abcde" t = "acfgh"
The length of the longest common substring of s and t is 2, since the characters "a" and "c" are the longest common substring.
null
Edit the following code such that output is an array of objects of key value pairs.
let fruit = ["apple", "banana", "orange"]; let colors = ["red", "yellow", "orange"];
let fruits = ["apple", "banana", "orange"]; let colors = ["red", "yellow", "orange"]; let fruitObj = []; for (let i = 0; i < fruits.length; i++) { let obj = {}; obj.name = fruits[i]; obj.color = colors[i]; fruitObj.push(obj); }
null
Create a function to sort an array of objects by the value of a certain key.
arr = [{'name': 'john', 'age': 20}, {'name': 'tim', 'age': 25}, {'name': 'mike', 'age': 30}];
def sort_by_key(arr, key): sorted_arr = sorted(arr, key=lambda k: k[key]) return sorted_arr # Testing arr = [{'name': 'john', 'age': 20}, {'name': 'tim', 'age': 25}, {'name': 'mike', 'age': 30}] sorted_arr = sort_by_key(arr, 'age') print("Sorted array by age: ", sorted_arr)
null
Write a function to parse a query string into its components in JavaScript.
query = "name=John&age=30"
function parseQueryString(query) { let components = query.split("&"); let data = {}; for (let c of components) { let pair = c.split("="); data[pair[0]] = pair[1]; } return data; } console.log(parseQueryString(query)); // {name: 'John', age: '30'}
null
Create a JavaScript function to merge two variables into a single object.
var a = {name: 'John', age: 21}; var b = {surname: 'Doe', gender: 'male'};
function merge(a, b) { return Object.assign({}, a, b); } let result = merge(a, b); console.log(result); // {name: 'John', age: 21, surname: 'Doe', gender: 'male'}
null
Formulate a regex expression in JavaScript to verify if a given string contains only numbers.
const isOnlyNumbers = (str) => { let regex = /^[0-9]+$/; return regex.test(str); };
[EN Wikipedia] Esther Shumiatcher-Hirschbein Esther Shumiatcher-Hirschbein (Yiddish: אסתר שומיאַטשער־הירשבײן) was a Belarusian-born Canadian and American Yiddish poet and screenwriter. Biographical details Shumiatcher was born on October 21, 1896, in Gomel to parents Judah and Chasia as one of eleven siblings. (Katz g...
null
null
null
[DE Wikipedia] Percee P Percee P, eigentlich John Percy Simon (* 9. Juli 1969 in der Bronx, New York) ist ein US-amerikanischer Underground Hip-Hop-Künstler. Nach über 14 Jahren mit zahlreichen viel beachteten Gastauftritten, bekam er 2003 einen Vertrag beim Plattenlabel Stones Throw. Leben 1988 wurde seine erste Sing...
null
null
null
null
Update the following code to sum the elements in a given list
list = [1,3,4,5]
sum = 0 for elem in list: sum += elem
null
Create a function in Python that sorts the elements of a given list.
[5, 7, 2, 3, 4, 1]
def sort_list(numbers): numbers.sort() return numbers result = sort_list([5, 7, 2, 3, 4, 1]) print(result)
null
What is an object in object-oriented programming?
In object-oriented programming, an object is a self-contained entity that contains both data and code, which together define and control its behavior. Objects can communicate with one another by sending messages and receiving data in response. Objects are used to represent real-world concepts, such as people, places, a...
null
Write a python script to detect duplicate words in a sentence.
Sentence: "She was driving, driving down the road."
sentence = 'She was driving, driving down the road.' list_words = sentence.split(" ") duplicates = {i for i, x in enumerate(list_words) if list_words.count(x) > 1} print("Duplicate words in the sentence are: ", end="") for duplicate in duplicates: print(list_words[duplicate], end=" ")
null
Craft an algorithm in Python to move all zeroes in a list to the end of the list.
[3, 0, 1, 0, 5, 0, 2]
def move_zeroes(lst): # Count the number of non-zero elements num_non_zeroes = 0 for num in lst: if num != 0: num_non_zeroes += 1 # Initialize the new list new_lst = [] # Move all non-zeroes to the beginning of the new list for i in range(num_non_zeroes): ne...
[DE Wikipedia] Aileu (Mau-Nuno) Aileu ist eine osttimoresische Aldeia im Suco Mau-Nuno (Verwaltungsamt Ainaro, Gemeinde Ainaro). 2015 lebten in der Aldeia 443 Menschen. Geographie und Einrichtungen Die Aldeia Aileu bildet den Mittelteil des Sucos Mau-Nuno. Westlich befindet sich die Aldeia Mama-Lau und östlich die Ald...
null
null
null
null
Write a function in JavaScript to reorder the given list in ascending order.
[3, 1, 2]
function sortAscending(list) { list.sort(function (a, b) { return a - b; }); return list; }
null
Identify and explain a memory leak in the following Python code.
def getData(): data = [] while True: val = input("Enter a value: ") if val == "done": break data.append(val) return data
The code in question contains a memory leak due to an infinite loop. Inside the loop, a new value is continuously added to the list ‘data’ without ever being removed. This will result in the list growing without bounds, resulting in the memory associated with the list being allocated indefinitely but never freed. To fi...
[CS Wikipedia] Luke Grimes Luke Timothy Grimes (* 21. ledna 1984) je americký herec, známý například svými rolemi ve filmech Americký sniper (2014) nebo v třídílné sérii Padesát odstínů. Objevil se však také ve dvou televizních seriálech. Externí odkazy Američtí herci Narození v roce 1984 Narození 21. ledna Narození v...
null
null
null
[HI Wikipedia] हैरी पॉटर और हाफ़-ब्लड प्रिंस (फ़िल्म) हैरी पॉटर और हाफ़-ब्लड प्रिंस () हॉलिवुड फ़िल्म, जो इसी नाम के उपन्यास पर आधारित है। यह हैरी पॉटर फिल्म श्रृंखला में छठी फिल्म है। सारी श्रंखला के डिस्ट्रिब्यूटर है वॉर्नर ब्रदर्स। पात्र राजेश काव प्रतिस्थापित करण त्रिवेदी जैसा हिन्दी डबिंग आवाज़ के लिए डैनियल रैड्...
null
null
null
null
Create a function that will accept a list and return the sum of all elements in the list
def sum_list(mylist): s = 0 for x in mylist: s += x return s
[EN Wikipedia] Ada Ada may refer to: Places Africa Ada Foah, a town in Ghana Ada (Ghana parliament constituency) Ada, Osun, a town in Nigeria Asia Ada, Urmia, a village in West Azerbaijan Province, Iran Ada, Karaman, a village in Karaman Province, Turkey Europe Ada, Bosnia and Herzegovina, a village Ada, Croatia, a vi...
null
null
null
null
Create a function to make a pyramid in Python with a given height.
def pyramid(height): # Dot symbol for each row dots = "." # loop for printing the pyramid for i in range(height): # insert spaces for j in range(height-i-1): print(" ", end='') for j in range(i+1): # print dots and concatenate print(...
null
Devise a Python code to make a pyramid of stars.
def stars(n): for i in range(1, n + 1): for j in range(1, i + 1): print("* ", end="") print()
null
Write a Python program to calculate the median of three given numbers.
def median_num(n1, n2, n3): if n1 > n2 and n2 > n3: return n2 elif n3 > n2 and n2 > n1: return n2 elif n1 > n3 and n3 > n2: return n3 elif n2 > n3 and n3 > n1: return n3 elif n2 > n1 and n1 > n3: return n1 else: return n1
null
Create a function in JavaScript to convert a number to its equivalent string format.
123
function numberToString(num){ return num.toString(); }
[CS Wikipedia] Kam, pánové, kam jdete? Kam, pánové, kam jdete? je československý barevný film natočený režisérem Karlem Kachyňou v roce 1987 na námět Milana Ležáka ve Filmovém studiu Barrandov. V hlavní roli architekta procházejícího krizí středního věku se představí Karel Heřmánek. Filmová alegorie reflektuje náladu ...
null
null
null
null
Write a code in Python to generate unique random numbers between 1 and 100
import random def generate_unique_randoms(n): res = [] while len(res) < n: x = random.randint(1, 100 ) if x not in res: res.append(x) return res
[DE Wikipedia] Ángel Espinosa Ángel Espinosa Capó (* 2. Oktober 1966 in Holguín, Kuba; † 12. April 2017 in Hialeah Gardens, Florida, Vereinigte Staaten) war ein kubanischer Amateurboxer. Karriere Der hart schlagende Rechtsausleger war einer der überragenden Halbmittel- und Mittelgewichtler der 1980er Jahre und Angstge...
null
null
null
null
Generate a Python function that takes a string and returns the longest substring without repeating characters.
def longestSubstringWithoutRepeatingCharacters(string): longest = "" current = "" for c in string: if c not in current: current += c else: if len(current) > len(longest): longest = current current = c if len(current) > len(longest): ...
null
Add a function to implement a basic calculator in C++.
#include <iostream> using namespace std; int addition(int a, int b){ return (a+b); } // Subtraction function int subtraction(int a, int b){ return (a-b); } // Multiplication function int multiplication(int a, int b){ return (a*b); } // Division function int division(int a, int b){ return (a/b); } // Function to perform...
null
Write a Python program to create a dictionary with values being doubled for every key.
{'a':4, 'b':7}
my_dict = {'a': 4, 'b': 7} double_dict = {k : 2*v for (k,v) in my_dict.items()} print(double_dict)
null
Edit the following code to generate a list of the vowels in a given string.
def get_vowels(str): vowels = ['a', 'e', 'i', 'o', 'u'] res = [] for letter in str: if letter.lower() in vowels: res.append(letter) return res
[DE Wikipedia] Banjarnegara (Regierungsbezirk) Banjarnegara ist ein indonesischer Regierungsbezirk (Kabupaten) in der Provinz Jawa Tengah, im Zentrum der Insel Java. Mitte 2022 lebten hier über eine Million Menschen. Die Hauptstadt und Regierungssitz des Verwaltungsbezirks ist die Stadt Banjarnegara. Die Stadt liegt c...
null
null
null
null
Write a C# program to sort a given array using the Quick Sort algorithm.
array = [8, 4, 1, 9, 6]
using System; namespace QuickSortExample { class Program { static void Main(string[] args) { int[] array = { 8, 4, 1, 9, 6 }; int left = 0; int right = array.Length - 1; quickSort(array, left, right); Console.WriteLine("Sorted array is:"); foreach (int val in array) { Console.WriteLine(val); } } static void quickSort(i...
[HI Wikipedia] रदरफोर्ड प्रकीर्णन रदरफोर्ड प्रकीर्णन अर्नेस्ट रदरफोर्ड द्वारा 1911 में प्रतिपादित भौतिक परिघटना है, जिसे बाद में परमाणु का रदरफोर्ड मॉडल (प्रतिमान) नाम से जाना जाने लगा और बाद में बोर मॉडल। रदरफोर्ड प्रकीर्णन को कई बार कुलाम्ब प्रकीर्णन की विशेष अवस्था भी कहा जाता है क्योंकि यह केवल स्थैतिक (कुलाम्ब) ब...
null
null
null
null
Create a Python program to generate a random password at least eight characters long.
import string import random def gen_password(length): all_chars = string.ascii_letters + string.digits + string.punctuation generated_password = ''.join(random.choice(all_chars) for _ in range(length)) return generated_password if __name__ == '__main__': password = gen_password(8) print(password)
[HI Wikipedia] दरभंगा दरभंगा (𑂠𑂩𑂦𑂁𑂏𑂰) भारत के बिहार राज्य के मिथिला क्षेत्र में दरभंगा ज़िले में स्थित एक नगर है। यह ज़िले का मुख्यालय भी है। विवरण दरभंगा बागमती नदी के किनारे बसा हुआ है। यह ज़िले एवं प्रमंडल का मुख्यालय है। दरभंगा प्रमंडल के अंतर्गत तीन जिले दरभंगा, मधुबनी एवं समस्तीपुर आते हैं। दरभंगा के उत्तर...
null
null
null
[EN Wikipedia] Waiaruhe River The Waiaruhe River is a river of the Northland Region of New Zealand's North Island. It flows northeast from its origins close to Ngawha Springs to reach the northern Waitangi River ten kilometres south of Kerikeri. See also List of rivers of New Zealand References Rivers of the Northland...
null
null
null
[HI Wikipedia] पॉस्सम पॉस्सम (Possum) ऑस्ट्रेलिया, नया गिनी और सुलावेसी पर पाए जाने वाले ७० धानीप्राणी (मारसूपियल) जातियों के एक समूह का नाम है। आधुनिक युग में मानवीय गतिविधियों से यह न्यू ज़ीलैंड और चीन में भी विस्तृत हो गए हैं। यह छोटे और मध्यम आकारों के होते हैं। विवरण पॉस्सम चार पाँव पर चलने वाले और अधिकतर वृक्षों...
null
null
null
null
Create a SQL query to get the total count of the employees in the team that have the job title of "software engineer".
Table: Employees Columns: id (int), name (string), job_title (string), team (string)
SELECT COUNT(*) AS total_count FROM Employees WHERE job_title="software engineer"
null
Replace words with corresponding synonyms in the given text
text: "The cat is lazy and likes to sleep." word: "sleep" synonym: "nap"
# Replace words with corresponding synonyms in the given text text = "The cat is lazy and likes to sleep." # Replace the word text = text.replace("sleep", "nap") print(text) # "The cat is lazy and likes to nap."
null
Generate a Python class for storing employee information. The class should include properties for name, age, salary, and role as well as methods for getting, setting, and displaying information for an employee.
Not applicable
class Employee: def __init__(self, name, age, salary, role): self.name = name self.age = age self.salary = salary self.role = role def get_name(self): return self.name def set_name(self, name): self.name = name def get_age(self): return self.age def set_age(self, age): self.age = age def get_sal...
null
Given a string, write a code that counts the number of alphabets in it.
input_string = "Hello World!"
input_string = "Hello World!" # Count the number of alphabets num_alphabets = sum(c.isalpha() for c in input_string) print("Number of alphabets in the string:", num_alphabets)
null
Write a Python program to fill a dictionary with key as a number and value as a string for square with {1: "1", 2: "4", 3: "9", ...}.
dic = {} for i in range (1,11): dic[i] = str(i ** 2) print(dic)
[DE Wikipedia] Suaman District Der Suaman District ist der kleinste der neun Distrikte der Western North Region des Staates Ghana. Er grenzt im mittleren Westen an das Nachbarland Elfenbeinküste. Der waldreiche Distrikt liegt in der Zone des tropischen Regenwaldes. Der größte Fluss ist der Bia. Die Nationalstraße 12 f...
null
null
null
null
Develop a program in Python that implements Binary Search tree.
class Node: def __init__(self, key): self.key = key self.left = None self.right = None def insert(root, key): if root is None: return Node(key) if root.key < key: root.right = insert(root.right, key) else: root.left = insert(root.left, k...
null
Modify the given program so that it can output the average of numbers a,b, and c.
a = 2 b = 5 c = 7
def average(a, b, c): return (a + b + c) / 3 a = 2 b = 5 c = 7 average = average(a, b, c) print("Average of a, b and c is:", average)
null
How do you create a MySQL query to find a specific employee by their name in a table named 'employees'?
SELECT * FROM employees WHERE name = '<employee_name>';
null
Create a program in Python that takes a list of words and an integer n and returns a list of words that appear at least n times in the given list.
words =['a', 'b', 'a', 'c', 'd', 'a', 'x', 'd', 'd'] n = 3
from collections import Counter def frequent_words(words, n): counts = Counter(words) return [word for word, count in counts.items() if count >= n] result = frequent_words(words, n) print(result) # prints ['a', 'd']
null
Describe the action taken by the following code snippet and provide a sample output
def format_string(x): return "The output is: {}".format(x)
The code snippet takes an input string, ``x``, and formats it by adding a prefix of "The output is: " to it and returns the formatted string. For example, if the input string is "Hello", the output string will be "The output is: Hello".
null
Write a Python program to remove the nth index character from a nonempty string.
var_str = Python, n = 0
def remove_character(var_str, n): first_part = var_str[:n] last_part = var_str[n+1:] return first_part + last_part print(remove_character('Python', 0)) Output: ython
[EN Wikipedia] Alexis Carrel Alexis Carrel (; 28 June 1873 – 5 November 1944) was a French surgeon and biologist who was awarded the Nobel Prize in Physiology or Medicine in 1912 for pioneering vascular suturing techniques. He invented the first perfusion pump with Charles Lindbergh opening the way to organ transplant...
null
null
null
[EN Wikipedia] Gmina Wilga Gmina Wilga is a rural gmina (administrative district) in Garwolin County, Masovian Voivodeship, in east-central Poland. Its seat is the village of Wilga, which lies approximately 17 kilometres (10 mi) south-west of Garwolin and 49 km (30 mi) south-east of Warsaw. The gmina covers an area of...
null
null
null
null
Given a string, find the longest palindrome within it.
string = "ananabay"
def longest_palindrome(string): """ Find the longest palindrome within a given string """ start, end, max_len = 0, 0, 0 for i in range(len(string)): # Odd length of palindrome left, right = i, i while left >= 0 and right < len(string) and string[left] == string[right]: length = right - left + 1 if max_len < length: max...