text
stringlengths
141
2.89k
⌀
instruction
stringlengths
19
1.5k
⌀
input
stringlengths
0
800
⌀
output
stringlengths
1
2.5k
⌀
null
Develop a program in Python to store 5 integer numbers in a list and print out the maximum value.
[7, 9, 23, 0, 4]
numbers = [7, 9, 23, 0, 4] maximum = max(numbers) print("The maximum value is: "+ str(maximum))
null
Create a Python script to scrape all links from a web page.
<link to web page>
import requests from bs4 import BeautifulSoup page = requests.get('<link to web page>') soup = BeautifulSoup(page.text, 'html.parser') links = [] for link in soup.find_all('a'): links.append(link.get('href')) # Usage print(links)
null
Write an outbound rule in Firewall to block traffic from a certain IP address.
IP address: 123.123.123.123
sudo iptables -A OUTPUT -s 123.123.123.123 -j DROP
[CS Wikipedia] Memoriál Zdeňka Jánoše Memoriál Zdeňka Jánoše je fotbalový turnaj určený internacionálům starším 35 let. Pojmenován je na počest prvoligového brankáře Zdeňka Jánoše. Propozice turnaje Turnaj se hraje systémem, kdy každý účastník sehraje utkání s každým dalším účastníkem. Za vítězné utkání mužstvo obdrží...
null
null
null
null
Create a python script to categorize a given text into three categories: positive, negative and neutral.
import re def categorize_text(text): """Categorizes the given text into positive, negative or neutral.""" text = text.lower() if re.search(r"\b(happy|glad|fun)\b", text): return "positive" elif re.search(r"\b(sad|angry|fearful)\b", text): return "negative" else: return "neut...
null
Embed a mathematical expression in Python and print the expression.
x**3 + 2*x**2 + 3
expression = 'x**3 + 2*x**2 + 3' print(eval(expression))
null
Create a function in Python to extract words from a sentence.
def extract_words(sentence): return sentence.split()
[HI Wikipedia] इलिनॉय इलिनॉय () अमरीका का एक राज्य है। इसकी राजधानी स्प्रिंगफील्ड है। इस राज्य में शिकागो सबसे बड़ा शहर है। इसे 1818 में राज्य का दर्जा प्राप्त हुआ। यह 6वां सबसे अधिक जनसंख्या वाला राज्य और भूमि क्षेत्र के मामले में 25वां सबसे बड़ा राज्य है। इलिनोइस का एक विविध आर्थिक आधार है और यह एक प्रमुख परिवहन कें...
null
null
null
null
Using a for loop, calculate the distance between one point to every other point in the given list.
points = [ (10, 20), (12, 22), (14, 24) ]
# Using a for loop, calculate the distance between one point to every other point in the given list from math import sqrt distances = [] for i in range(len(points)): for j in range(len(points)): if i != j: x1, y1 = points[i] x2, y2 = points[j] distance = sqrt((x2 - x1)**2 + (y2 - y1)**2) distances.append(distance) prin...
null
Can you create a Python program that converts binary numbers to decimal numbers?
binary_number = "1010"
def binary_to_decimal(binary_number): decimal_number = 0 for digit in binary_number: decimal_number = decimal_number*2 + int(digit) return decimal_number binary_number = "1010" print(binary_to_decimal(binary_number)) # 10
null
Create a function that prints the binary representation of a number.
number = 5
def print_binary(number): binary_string = "" while number != 0: remainder = number % 2 binary_string = str(remainder) + binary_string number = number // 2 return binary_string print(print_binary(number))
null
Write a code snippet to create a new JavaScript array of n length.
var array = []; for (var i = 0; i < n; i++) { array.push(null); }
null
Create a data visualization in Python using Matplotlib that displays the total number of cases for coronavirus in different countries.
[[United States, 212000], [Russia, 180000], [Italy, 105000], [Spain, 90000], [Germany, 70000]]
import matplotlib.pyplot as plt country_data = [['United States', 212000], ['Russia', 180000], ['Italy', 105000], ['Spain', 90000], ['Germany', 70000]] country = [data[0] for data in country_data] cases = [data[1] for data in country_data] plt.barh(country, cases) plt.title("Total number of Coronavirus cases by count...
null
Create a Python function to generated permutations of a given list of numbers.
[1, 2, 3]
def permutations(arr): if len(arr) == 0: return [] if len(arr) == 1: return [arr] l = [] for i in range(len(arr)): m = arr[i] remL = arr[:i] + arr[i+1:] for p in permutations(remL): l.append([m] + p) return l permutations([1, 2, 3])
null
Debug the following code by finding the syntax error.
def calculate_value(nums): result = 0 for num in nums result += num return result
def calculate_value(nums): result = 0 for num in nums: # missing colon result += num return result
null
Solve the following equation for x.
3x + 4 = 10
x = (10 - 4) / 3 x = 2
null
Write an algorithm in Python to sort a given list using the bubble sort technique.
def bubble_sort(arr): n = len(arr) for i in range(n): for j in range(0, n-i-1): if arr[j] > arr[j+1] : arr[j], arr[j+1] = arr[j+1], arr[j]
null
Write a Python script to convert a string containing temperatures in Celsius to Fahrenheit
string celsius = '25, 15, 32'
def convertCelsiusToFahrenheit(celsius): temperature_fahrenheit = [] for c in celsius.split(','): temperature_fahrenheit.append(float(c)*1.8 + 32) return temperature_fahrenheit fahrenheit = convertCelsiusToFahrenheit(celsius) print(fahrenheit)
null
Transform the below SQL query into MongoDB.
SELECT user_id, COUNT(*) FROM orders WHERE status = 'completed' GROUP BY user_id ORDER BY COUNT(*) DESC;
db.orders.aggregate([ {$match: {status: 'completed'}}, {$group: {user_id: '$user_id', count: {$sum: 1}}}, {$sort: {count: -1 }} ])
[EN Wikipedia] Xe Bang Fai River The Xe Bang Fai River (Nam Xebangfai) is a river in Laos. It originates in the Annamite Range on the border between Laos and Vietnam at . It flows through Khammouane Province and Savannakhet Province. Xe Bang Fai River Cave Xe Bang Fai River Cave is in Hin Namno National Park in Khammo...
null
null
null
null
Generate a Python class to store a database table into memory.
Table Name: "People" Columns: "id", "name", "age", "gender", "address"
class People: def __init__(self, id, name, age, gender, address): self.id = id self.name = name self.age = age self.gender = gender self.address = address def get_data(self): data = { 'id': self.id, 'name': self.name, 'age': se...
null
Design a Flask application in Python to create an API endpoint for user registration.
Not applicable
from flask import Flask, request app = Flask(name) @app.route('/users', methods=['POST']) def create_user(): data = request.json # Create the user # ... return {'status': 'user created'} if name == 'main': app.run(debug=True)
null
Write Python code to extend a string to be twice as long as the original string
Example string: "Hello world"
input = "Hello world" output = input + input
null
Design a Python class to store and manipulate data from a tabular dataset.
class TableData: def __init__(self, data): self.data = data self.column_names = list(data[0].keys()) self.row_count = len(data) def get_rows(self): rows = [] for row in self.data: rows.append(list(row.values())) return rows def get_columns(self)...
null
Generate code for a for loop to iterate through the numbers from 0 to n-1.
n = 5
for i in range(0, n): print(i)
null
Create a python script that displays the information of three different cities.
Edinburgh: Scotland, 54.6°N, UK Paris: France, 48.86°N, Europe Dhaka: Bangladesh, 23.78°N, Asia
def get_city_info(city, country, latitude, continent): print("City: {}, Country: {}, Latitude: {}, Continent: {}".format( city, country, latitude, continent)) get_city_info('Edinburgh', 'Scotland', '54.6°N', 'UK') get_city_info('Paris', 'France', '48.86°N', 'Europe') get_city_info('Dhaka', 'Bangladesh', '2...
null
What is a Python list?
A Python list is an ordered collection of objects, stored in memory and indexed by number that can contain items of different types such as numbers, strings, and other lists.
null
Write a JavaScript code snippet to query a given database table.
Table Name: users
const query = "SELECT * FROM users"
null
Write a single line of code to convert a string to a date in Python.
date = datetime.strptime('01/01/2019', '%d/%m/%Y')
null
Develop a Python program to convert an integer from one binary representation to another.
15
def decimal_to_binary(n): return bin(n).replace("0b", "") def binary_to_decimal(n): return int(n,2) input_decimal = 15 finding_binary = decimal_to_binary(input_decimal) result = binary_to_decimal(finding_binary) print(result)
null
Create a while loop that prints each element in the list from the end.
numbers = [1, 2, 3, 4, 5]
i = len(numbers) while i > 0: print(numbers[i-1]) i -= 1
null
Create a python function to find out if an item exists in a given list.
def is_item_in_list(item, my_list): '''This function checks if an item exists in a given list and returns a boolean value. Parameters ---------- item: The item to be checked. my_list: The list in which the item is to be checked. Returns -------- boolean: True if the item is present...
null
Write an HTML code to add a padding of 10px to the paragraph tag
<p style="padding: 10px;"> </p>
null
Given a string, write the appropriate regex pattern that checks if the string contains any digit.
import re def check_digits(string): """ This function takes a string and checks if it contains any digit. """ regex_pattern = r"[0-9]" return bool(re.search(regex_pattern, string))
null
Construct a 2-dimensional array, A, of size M*N, filled with all zeroes.
M=4, N=5
A = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]
null
Explain the differences between Bitwise AND, OR, and XOR operations.
The bitwise AND (&) operation returns a 1 in a given bit position if both bits being compared are equal to 1. The bitwise OR (|) operation returns a 1 in a given bit position if either or both of the bits being compared are equal to 1. The bitwise XOR (^) operation produces a result of 1 if the two bits being compared ...
null
Develop an algorithm in Python to replace all the vowels in a string with an asterisk.
string = “Hello World”
string = “Hello World” def replaceVowels(string): vowels = ("a", "e", "i", "o", "u") result = "" for char in string: if char in vowels: result += "*" else: result += char return result new_string = replaceVowels(string) print(new_string) # This will print out "H...
null
Create a CSS code that demonstrates a nice hover effect for a button.
.button { background: #3498db; color: #fff; font-size: 1.2em; padding: 10px; transition: 0.2s; } .button:hover { background: #4578ba; box-shadow: 0px 0px 5px #ccc; transform: scale(1.1); }
null
Create a class in Python that inherits properties from a parent class named 'Animal'.
class Animal: def __init__(self, name): self.name = name class Dog(Animal): def __init__(self, name, breed): super().__init__(name) self.breed = breed
[HI Wikipedia] ख़ोरूग़​ ख़ोरूग़​ (ताजिक: Хоруғ, , Khorugh) मध्य एशिया के ताजिकिस्तान देश के कूहिस्तोनी-बदख़्शान स्वशासित प्रान्त की राजधानी है। यह उस प्रान्त के शुग़नोन​ ज़िले की प्रशासनिक राजधानी भी है। पामीर पर्वतों में २,२०० मीटर की ऊँचाई पर पंज नदी और ग़ुन्द​ नदी के संगम-स्थल पर स्थित यह शहर अपने मनोहर पर्वतीय वात...
null
null
null
[DE Wikipedia] West Horsley Place West Horsley Place ist ein Grade-I-Bauwerk in West Horsley, Surrey, England. Auf dem Anwesen gibt es acht weitere Bauwerke im Grade II, darunter ein Hundezwinger aus der Mitte des 19. Jahrhunderts. Geschichte Die Ursprünge des Gebäudes gehen zurück auf das Jahr 1425. Es wurde aus rote...
null
null
null
[DE Wikipedia] ARR ARR steht als Abkürzung für: Absolute Risikoreduktion, Maß einer Therapiewirksamkeit, siehe Relative und absolute Risikoreduktion Adolf-Reichwein-Realschule (Witten) Agencja Rynku Rolnego, polnische Agentur für den Agrarmarkt Air Armenia, armenische Fluggesellschaft (ICAO-Code) Alaska Railroad, US-a...
null
null
null
null
Name a few use cases of Convolutional Neural Networks.
Convolutional Neural Networks are widely used in domains such as computer vision, natural language processing, pattern recognition, time series analysis, audio processing, object recognition and classification, and for other tasks such as image segmentation, automated image captioning, image deblurring, object detectio...
null
List out all the sorting algorithms supported in Python.
The sorting algorithms supported in Python include bubble sort, insertion sort, selection sort, merge sort, quick sort, and heap sort.
null
Suggest an edit to fix the following code snippet.
for num in range(10): if num % 2 == 0 print(num);
for num in range(10): if num % 2 == 0: print(num);
[HI Wikipedia] नेपालभाषा नेपालभाषा, नेपाली भाषा से अलग है। इसी तरह खस भाषा भी नेपाल भाषा से भिन्न है। इनमें भ्रमित न हों। नेपाल भाषा ('नेवा' अथवा 'नेपाल भाय्') नेपाल की एक प्रमुख भाषा है। यह भाषा १४वीं शताब्दी से लेकर १८वीं शताब्दी के अन्त तक नेपाल की प्रशासनिक भाषा थी। आजकल नेपाल की जो राजभाषा है वह नेपाली है, न कि न...
null
null
null
null
Create a list in Python of elements 0-9 in random order.
import random # Generate a list of 10 numbers nums = [i for i in range(10)] # Shuffle the list random.shuffle(nums) # Print the shuffled list print(nums) # [5, 0, 2, 3, 9, 8, 4, 1, 7, 6]
null
Design a code generation program in Python to generate a HTML page with text content.
def generate_html(text): html = "<html>\n" html += "<body>\n" html += "<p>" + text + "</p>\n" html += "</body>\n" html += "</html>\n" return html if __name__ == "__main__": text = "Hello World!" html = generate_html(text) print(html)
[EN Wikipedia] Vytautas Pranas Bičiūnas Vytautas Pranas Bičiūnas (August 20, 1893 in Klovainiai – October 30, 1943 in Sverdlovsk) was a Lithuanian painter, theatre actor, writer and literary critic. Between 1914 and 1916, he studied at Kazan Art School. Then in 1917, along with Juozas Tumas-Vaižgantas, he edited the n...
null
null
null
[CS Wikipedia] Itreksjód Itreksjód, Ítreksjóð či Itreksiod je v germánské mytologii jeden ze synů Ódina a bůh. Je zmíněn v 75. kapitole Prozaické Eddy v knize Skáldskaparmál, kde se o něm mluví jako o jednom z Ásů a synů Ódina. Reference Severští bohové
null
null
null
null
Write code to determine the type of a given variable in Python.
def get_type(var): return type(var).__name__
null
What is a web server?
A web server is a computer system that hosts web applications and responds to requests from users over the internet. The web server processes the requests and sends a response back to the users, usually in the form of an HTML web page.
null
Write a SQL query to list all the product categories with their sales numbers in the given data set.
Table: Products | id | product_name | category | sale_price | 1 iPhone Phones 400 2 iPad Tablets 500 3 Apple Watch Phones 300 4 In-ear headset Audio 50 5 Pen Drive Storage 20 6 32GB RAM Storage 100
SELECT category, SUM(sale_price) as total_sales FROM Products GROUP BY category
null
Write a method in Python to append a given list to another list.
list_1 = [1,2,3] list_2 = [4,5,6]
list_1.extend(list_2)
null
Implement a 3d vector class with a constructor, a dot product method and a normalization method.
class Vector3d { double x, y, z; //Constructor Vector3d(double x, double y, double z) { this.x = x; this.y = y; this.z = z; } // Dot product double dotProduct(Vector3d vec2) { double result = this.x * vec2.x + this.y * vec2.y + this.z * vec2.z; return result; } // Normalization Vector3d normalize() { double magnitude =...
[CS Wikipedia] Ivar Nilsson Ivar Bengt Nilsson (12. června 1933 Göteborg – 26. února 2019 Hindås) byl švédský rychlobruslař. Na mezinárodní scéně se poprvé představil v roce 1960. Tehdy nejprve skončil čtvrtý na Mistrovství Evropy, posléze byl dvanáctý na Mistrovství světa a nakonec závodil na Zimních olympijských hrá...
null
null
null
null
Create a web service to fetch data from a database.
A web service can be created using programming languages such as Python, JavaScript, etc. It will contain code to connect to the database, fetch the data, and return it in the appropriate format.
null
What is the command to delete all occurrences of the element "5" from a given Python array?
arr = [3, 4, 5, 2, 5, 1, 5] arr = [x for x in arr if x != 5]
[CS Wikipedia] Treble Treble je ve fotbalové terminologii označení pro úspěch klubu, který v jednom roce (resp. sezóně) získá tři trofeje, zpravidla domácí double (tedy vítězství v domácí lize a národním poháru) a k tomu vyhraje některou významnou kontinentální pohárovou soutěž (např. Ligu mistrů, Pohár osvoboditelů, ...
null
null
null
null
Write a Python function that takes three numbers as argument and prints the largest one.
3, 5, 9
def largest_number(a, b, c): max = a if b > max: max = b if c > max: max = c print(max) largest_number(3, 5, 9)
[DE Wikipedia] Niski Młyn Niski Młyn () ist ein Ort in der polnischen Woiwodschaft Ermland-Masuren. Er gehört zur Gmina Bisztynek (Stadt- und Landgemeinde Bischofstein) im Powiat Bartoszycki (Kreis Bartenstein). Geographische Lage Niski Młyn liegt am Westufer des Flüsschens Rhein () in der nördlichen Mitte der Woiwods...
null
null
null
null
Convert this regular expression to JavaScript regex expression.
/[A-Z][a-z]+/
/[A-Z][a-z]+/g
null
Using the given Python code, update its style using pep 8 conventions.
def factorial (x): if x <= 1: return 1 return x * factorial (x-1)
def factorial(x): if x <= 1: return 1 return x * factorial(x - 1)
null
Given the following JSON snippet, design a MongoDB schema for the corresponding collection.
{ "users": [ { "name": "John", "addr": { "street": "123 Main St", "city": "New York" } } ] }
db.users.insert({ name: String, addr: { street: String, city: String } })
null
Develop a web scraping program using Python to extract the names and contact information of 10 randomly selected people from a popular website.
Not applicable
import requests import random from bs4 import BeautifulSoup #specify website url website_url = 'https://www.example.com/people' #scraping function def scrape_contacts(): #load website html = requests.get(website_url).text #parse html soup = BeautifulSoup(html, 'html.parser') contacts = [] #ext...
null
Write a JavaScript function to convert a number from octal to decimal.
octal_number = 014
function octToDec(octal_number){ let dec_number = 0; let i = 0; while(octal_number != 0){ dec_number += (octal_number % 10) * Math.pow(8,i); octal_number = Math.floor(octal_number/10); i++; } return dec_number; } var decimal_number = octToDec(014); console.log(decimal_number);
null
Develop a Python program to remove all characters from an input string that are not a-z, A-Z, 0-9, or white space.
"Hello,@ $World."
import re def remove_non_alphanum(s): return re.sub('[^a-zA-Z0-9 \n\.]', '', s) string = "Hello,@ $World." res = remove_non_alphanum(string) print(res)
null
Change the variable "str" below to upper case.
let str = 'hello world!';
let str = 'HELLO WORLD!';
null
Create a code to sort this list in a descending order
my_list = [1,9,3,5,7]
""" Sort this list in a descending order """ my_list = [1,9,3,5,7] # Sort the list in a descending order my_list.sort(reverse=True) print(my_list)
null
Implement a JavaScript for creating alert message when a page loads.
window.onload = function(){ alert("Welcome to this page!"); }
null
Analyze the following sentence to determine the type of verb phrase involved.
We have met several times.
The verb phrase in this sentence is a perfect verb phrase, as it indicates an action that has been completed in the past and has a continuing result in the present. The verb in the phrase is "have met".
[DE Wikipedia] Relatives Gehör Relatives Gehör beschreibt die Fähigkeit einer Person, einen Ton mithilfe eines Referenztons zu identifizieren oder wiederzugeben, indem das Intervall zwischen Referenz- und Zielton genutzt wird. Das relative Gehör ist sehr viel weiter verbreitet als das absolute Gehör, das nur bei einem...
null
null
null
null
Write a Python program to edit the given JSON string using the given selection criteria.
JSON String: { “name”: “Alice”, “role”: “programmer”, “department”: “engineering” } Selection Criteria: Change the department of the given JSON string.
import json json_str = '{ "name": "Alice", "role": "programmer", "department": "engineering" }' data = json.loads(json_str) data["department"] = "marketing" json_str = json.dumps(data) print(json_str)
null
Insert a node at the beginning of a linked list.
[10 -> 15 -> 20 -> 25]
// Java program to insert a node // at the beginning of a Singly Linked List public static void push(Node head_ref, int new_data) { // allocate node Node new_node = new Node(new_data); // put in the data new_node.data = new_data; // link the old list off the new node new_node.next = head_ref; // move the head to point ...
null
How would you print a big "Hello World" on the console output?
print('
null
Generate a function in Python for finding the maximum value in a list of numbers with time complexity O(n).
num_list = [3, 7, 4, 2, 8, 16, 1, 9, 10]
def max_val(num_list): if len(num_list) == 0: return None max_num = num_list[0] for num in num_list: if num > max_num: max_num = num return max_num
null
How does a hash table work?
A hash table is a data structure that stores data items in an associative array where the key is used to quickly search for the data item. It is based on the concept of hashing which converts a key into an address in the array. Each address points to the data item associated with that key. The hash table offers fast lo...
null
Create a Python program to find the sum of the series - 1² + 2² + 3² + ... + n²
n = 5
def series_sum(n): sum = 0 for i in range(1, n+1): sum += i**2 return sum print(series_sum(5))
[CS Wikipedia] Jennifer Ehle Jennifer Ehle (* 29. prosince 1969) je americká divadelní i filmová herečka. Je nositelkou mnoha ocenění za svoji divadelní i filmovou tvorbu. Mezi její nejslavnější hollywoodské role patří například Králova řeč (2010), Nákaza (2011), RoboCop (2014) nebo trojice filmové série Padesát odstí...
null
null
null
null
Generate a python code for linear regression.
from sklearn.linear_model import LinearRegression model = LinearRegression() model.fit(X, y)
null
Generate a neural network model which uses the Keras API in Python to predict whether an email is spam or not.
Not applicable
from tensorflow.keras.layers import Dense, Input from tensorflow.keras.models import Sequential model = Sequential() input = Input(shape=(1,)) x = Dense(32, activation='relu')(input) x = Dense(32, activation='relu')(x) x = Dense(1, activation='sigmoid')(x) model = Model(inputs=input, outputs=x) model.compile(optimiz...
null
Create a Python program to read 2 numbers from the user and calculate their sum.
Not applicable
num1 = int(input("Enter first number: ")) num2 = int(input("Enter second number: ")) # Adding two numbers sum = num1 + num2 print("Sum of {0} and {1} is {2}" .format(num1, num2, sum))
null
Generate a Python program which returns the most recognized word in a given list of strings.
["Hello", "Hi", "Greeting"]
def most_recognized(strings): max_string = "" max_count = 0 for string in strings: count = len(string.split()) if count > max_count: max_string = string max_count = count return max_string strings = ["Hello", "Hi", "Greeting"] most_recognized_word = most_recogni...
null
Create a function that takes a sentence as a string and returns a string containing the sentence in reverse order.
"I am learning to code"
public String reverse(String sentence) { StringBuilder reversedSentence = new StringBuilder(); String[] words = sentence.split(" "); for (int i = words.length - 1; i >= 0; i--) { reversedSentence.append(words[i]); reversedSentence.append(" "); } return reversedSentence.toString().trim(); }
null
Create a program in Python that displays a 3x3 chess board, with pieces at starting positions.
Not applicable
import numpy as np chess_board = np.array([["R", "N", "B", "Q", "K", "B", "N", "R"], ["P", "P", "P", "P", "P", "P", "P", "P"], [" ", " ", " ", " ", " ", " ", " ", " "], [" ", " ", " ", " ", " ", " ", " ", " "], [" ", " ", " ", " ", " ", " ", " ", " "], [" ", " ", " ", " ", " ", " ", " ", " "], ["p", "p", "p", "p...
[EN Wikipedia] Pearson River The Pearson River is a river of the West Coast region of New Zealand's South Island. It flows north from Mount Aspiring's glacial lake, which is fed by the Volta and Bonar Glaciers, to reach the Waiatoto River. See also List of rivers of New Zealand References Rivers of the West Coast, New...
null
null
null
null
Create classes and interfaces to represent an online news system.
class NewsSystem { public string title; public string content; public NewsSystem(string title, string content) { this.title = title; this.content = content; } } interface INewsActions { void PostNewArticle(NewsSystem article); void EditArticle(NewsSystem article); void DeleteArticle(NewsSystem article); }
[HI Wikipedia] चेरतला चेरतला (Cherthala) भारत के केरल राज्य के आलाप्पुड़ा ज़िले में स्थित एक नगर है। यह इसी नाम की तालुका का मुख्यालय भी है। आवागमन महाराष्ट्र में मुम्बई के उपनगर पनवेल से तमिल नाडु में भारत की मुख्यभूमि के दक्षिणतम छोर कन्याकुमारी तक जाने वाला राष्ट्रीय राजमार्ग 66 यहाँ से गुज़रता है और इसे देशभर के क...
null
null
null
null
Output the following string in reverse order using loops.
Hello World
for (let i = 10; i >= 0; i--) { console.log(msg[i]); }
null
Generate a CPython code for reversing a given list of numbers.
[1,2,3,4]
def reverse_list(nums): return nums[::-1]
null
You are given a list of numbers. Count how many of them are prime numbers.
[1,2,3,4,5,6,7]
def count_primes(numbers): count = 0 for number in numbers: if is_prime(number): count += 1 return count def is_prime(number): if number <= 1: return False for i in range(2, number): if number % i == 0: return False return True
null
Write a Python program to efficiently delete all items from a set that are in another set.
A = {1, 2, 3, 4, 5} B = {2, 4}
A = {1, 2, 3, 4, 5} B = {2, 4} A -= B
null
Populate an array with numbers from 1 to 10 in Python.
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
null
Create a function to raise a given number to the Nth power.
def power(n, x): if x == 0: return 1 return n * power(n, x-1)
null
Write a SQL query to find the first ten customers by their joining date.
SELECT * FROM customers ORDER BY joining_date ASC LIMIT 10;
null
Calculate how many distinct values can be inserted in a binary tree containing 2 nodes.
2^2 - 1 = 3 distinct values can be inserted in a binary tree containing 2 nodes.
null
Write a Python program to generate n-grams of the given text with a window size of 3.
The quick brown fox jumps over the lazy dog
from collections import Counter def generate_ngrams(text, window_size): text = text.lower().split(' ') ngrams = [] for n in range(window_size, len(text)+1): for i in range(len(text)-n+1): ngrams.append(' '.join(text[i:i+n])) return Counter(ngrams) text = "The quick brown fox jump...
null
Given an array of positive integers, remove all the duplicates.
List1 = [1, 2, 3, 3, 4, 4, 2]
List1 = list(set(List1)) # Output: List1 = [1, 2, 3, 4]
[EN Wikipedia] Timeline of PlayStation 3 SKUs The PlayStation 3 was originally launched in Japan on November 11, 2006 and in North America on November 17, 2006 with two SKUs: a 20 GB version and a 60 GB version. Both of these models included hardware backwards compatibility for PlayStation 2 games. In January 2007, So...
null
null
null
null
Create a loop to print "I love Python" five times
for i in range(5): print("I love Python")