text stringlengths 141 2.89k ⌀ | instruction stringlengths 19 1.5k ⌀ | input stringlengths 0 800 ⌀ | output stringlengths 1 2.5k ⌀ |
|---|---|---|---|
null | Construct a regular expression to match strings containing only alphabets. | /^[a-zA-Z]+$/ | |
[HI Wikipedia] बरगुज़ीन नदी
बरगुज़ीन नदी (रूसी: Баргузи́н; अंग्रेज़ी: Barguzin) रूस के साइबेरिया क्षेत्र के बुर्यातिया गणतंत्र की एक प्रमुख नदी है। यह 480 किमी लम्बी नदी बयकाल झील के बरगुज़ीन नामक भाग में ख़ाली हो जाती है। सेलेन्गा नदी और ऊपरी अंगारा नदी के बाद बयकाल झील में जल ले जाने वाली यह तीसरी सबसे बड़ी नदी है। ... | null | null | null |
null | Create a new folder called 'data' within the current working directory. | import os # create 'data' folder in the current working directory current_directory = os.getcwd() new_directory = os.path.join(current_directory, 'data') os.mkdir(new_directory) | |
null | Concatenate the elements of the list into a string. | list_of_strings = ['I', 'am', 'a', 'string'] | list_of_strings = ['I', 'am', 'a', 'string'] concat = ' '.join(list_of_strings) print(concat) |
null | Provide a solution using Python to capitalize the first letter of each word in a given phrase. | the quick brown fox | def capitalize(phrase):
words = phrase.split(" ")
capitalized_words = [word.capitalize() for word in words]
capitalized_phrase = " ".join(capitalized_words)
return capitalized_phrase
capitalized_phrase = capitalize("the quick brown fox")
print(capitalized_phrase) |
null | Analyze the time complexity of an algorithm written in Python. | def bubble_sort(arr):
n = len(arr)
# Traverse through all array elements
for i in range(n):
# Last i elements are already in place
for j in range(0, n-i-1):
# traverse the array from 0 to n-i-1
# Swap if the element found is greater
# than the next e... | This algorithm has a time complexity of O(n2). This is due to the nested for loop which means that the runtime of the algorithm is proportional to the square of the size of the input. Consequently, the time complexity increases exponentially with the input size. |
null | Edit the following code to register an account on a website. | import requests url = "www.example.com/register" data = "username=myname" | import requests url = "www.example.com/register" data = { "username" : "myname", "password" : "secret_password", "email" : "myname@example.com" } response = requests.post(url, data=data) |
null | Create a Python script that extracts the text from a webpage | URL: https://www.example.com | import requests
from bs4 import BeautifulSoup
url = "https://www.example.com"
page = requests.get(url)
soup = BeautifulSoup(page.content, 'html.parser')
text = soup.find_all(text=True)
for t in text:
print(t.strip()) |
null | Design a class in Java to build a Binary Search Tree. | public class BST { /* Class containing left and right child of current node and key value*/ class Node { int key; Node left, right; public Node(int item) { key = item; left = right = null; } } // Root of BST Node root; // Constructor BST() { root = null; } // This method mainly calls insertRec() void insert(int key) { ... | |
null | Create a list comprehension expression for adding two lists in Python. | list1 = [1, 2, 3]
list2 = [4, 5, 6] | list3 = [list1[i] + list2[i] for i in range(len(list1))] |
null | In Python, write a program to remove all duplicates from a given list of integers. | def remove_duplicates(arr): result = [] seen = set() for item in arr: if item not in seen: result.append(item) seen.add(item) return result | |
null | Code a React component that renders a button with a given text. | Text of the button: Submit | import React from 'react'; import { Button } from 'react-native'; const SubmitButton = ({ text }) => { return ( <Button title={text} /> ); } export default SubmitButton; |
null | Debug and fix the code in the given input. | def multiply(x,y) { return x*y x = 5 y = 4 print multiply(x,y) | def multiply(x,y) { return x*y x = 5 y = 4 print(multiply(x,y)) |
null | Convert a string of comma-separated values into a list in Python. | "apple, banana, orange" | str = "apple, banana, orange"
# split the string
string_list = str.split(', ')
# print result
print(string_list) # ['apple', 'banana', 'orange'] |
null | Manipulate a string in C++ to delete all special characters from it. | String = “Hello!&@ This#%^$ is a string” | string s = "Hello!&@ This#%^$ is a string"; for (int i = 0; i < s.length(); i++) { if (!isalnum(s[i])) s.erase(s.begin() + i); } |
null | Create a python program to print the Fibonacci sequence for the first ten numbers. | def fibonacciSequence(n):
a = 0
b = 1
sequence = [a, b]
for _ in range(2, n):
c = a + b
a = b
b = c
sequence.append(c)
return sequence
print(fibonacciSequence(10)) # [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] | |
null | Write code to print the following data structure in an easily readable format. | data = { "name": "John Smith", "age": 35, "languages": ["Python", "JavaScript", "SQL"] } | print('Name: {}'.format(data['name'])) print('Age: {}'.format(data['age'])) print('Languages: {}'.format(', '.join(data['languages']))) |
null | Write a Python code to handle this data loading task. | Problem: Load a CSV file that contains data from multiple sources and store it in a DataFrame. | import pandas as pd
def load_data(csv_file):
'''This function will load the CSV file and store the data in a DataFrame'''
data = pd.read_csv(csv_file, sep=',', encoding='utf-8')
return pd.DataFrame(data) |
null | Create a Python script which takes a list of numbers and finds the maximum value. | [1, 4, 6, 2, -5, 10] | # define a function
def maxValue(list_of_nums):
# assign the max as the first item in the list
maximum = list_of_nums[0]
# loop through the list
for num in list_of_nums:
# update the max value if its larger than the current maximum
if num > maximum:
maximum = num
# return the final maximum
return maximum
... |
null | Create a program in Python that reads a text and then prints out the longest word in the text. | This is an example of a sample text. | def find_longest_word(text):
words = text.split(" ")
longest = ""
for word in words:
if len(word) > len(longest):
longest = word
return longest
if __name__ == "__main__":
text = "This is an example of a sample text."
print(find_longest_word(text)) |
null | Can you program a web scraper in Python to extract specific data from a website? | import requests
from bs4 import BeautifulSoup
url = "example.com"
response = requests.get(url)
html = response.text
soup = BeautifulSoup(html, "html.parser")
data = soup.find_all(class_="data-class")
for item in data:
# Extract the data you need here
# ... | |
null | Develop a machine learning algorithm to predict stock prices. | Historical stock prices | The algorithm should include parts like data preprocessing, feature extraction, selecting the right model, hyperparameter optimization and evaluation. |
null | Write a python method to identify whether the given string is a palindrome. | String: "racecar" | def is_palindrome(s):
s = s.lower()
return s == s[::-1]
print(is_palindrome("racecar")) # True |
null | Implement a function to rotate a list by k elements. | list = [1,2,3,4,5], k = 2 | def rotate(list, k): first_part = list[0:k] second_part = list[k:] second_part.extend(first_part) return second_part |
null | Write a code to find the maximum of three numbers using if else. | def maximum_of_three(x, y, z): if x > y and x > z: max = x elif y > x and y > z: max = y else: max = z return max | |
null | Generate a Python program to split a given list of strings into two halves containing even and odd length strings. | def split_list(input_list):
# Create two empty lists to hold the even and odd length strings
even_list = []
odd_list = []
# Iterate through the given list
for element in input_list:
# If the current length of element is even append it to even_list
if len(element) % 2 == 0:
... | |
null | Create a Python program to search for a given item in a list of strings. | ["hello", "world", "foo", "bar"], "bar" | def search_for_item(strings, item):
for string in strings:
if string == item:
return True
return False |
[HI Wikipedia] द्वितीय आंग्ल-मराठा युद्ध
द्वितीय आंग्ल-मराठा युद्ध मराठा साम्राज्य और ब्रिटिश ईस्ट इंडिया कंपनी के बीच १८०३ से १८०५ के दौरान हुआ था। मराठा साम्राज्य | null | null | null |
null | Write a SQL query to find out the total number of books purchased by each customer in a book store. | SELECT custid, COUNT(*) AS 'Number of Purchases' FROM orders GROUP BY custid; | |
null | You are given a list of numbers and a certain threshold value. Write a Python program to automatically find all pairs of numbers in the list whose sum is equal to the threshold value. | [2, 3, 5, 7, 8] and threshold value 10 | def find_pairs_threshold(nums, threshold):
pairs = []
for i in range(len(nums)):
for k in range(i + 1, len(nums)):
if (nums[i] + nums[k] == threshold):
pairs.append((nums[i], nums[k]))
return pairs
print(find_pairs_threshold([2, 3, 5, 7, 8], 10))
# Output : [(2, 8), (... |
null | You have to read a set of numbers and report the number of positive numbers. | [-1, -43, 2, 6, 0, 18] | int count_positive(int arr[], int size) { int count = 0; for (int i = 0; i < size; i++) if (arr[i] > 0) count++; return count; } int arr[] = {-1,-43,2,6,0,18}; int n = sizeof(arr)/sizeof(arr[0]); count_positive(arr, n); |
null | Write an algorithm in Java to reverse the words in a string. | The quick brown fox | String[] words = input.split("\\s"); String reversedString = ""; for (int i = words.length - 1; i >= 0; i--) { reversedString += words[i] + " "; } System.out.println(reversedString); |
[HI Wikipedia] ठाकुर राम लाल
ठाकुर राम लाल (7 जुलाई 1929 - 6 जुलाई 2002) गांव बरथाटा, तहसील जुब्बल, जिला शिमला में पैदा हुए। 1951 में एसडी कालेज शिमला से स्नातक हुए। लॉ कालेज जालंधर से 1955 में इन्होंने एलएलबी पास की। 1957 से 1962 तक यह क्षेत्रीय परिषद के लिए चुने गए। वे 1957, 1962, 1967, 1977, 1980 और 1982 में जुब्बल... | null | null | null |
[EN Wikipedia] Rakovets, Lviv Oblast
Rakovets (, in the past had the name Mlynivtsi ()) – is a small village (selo), which is located in Lviv Raion, Lviv Oblast, of Western Ukraine. It belongs to Solonka rural hromada, one of the hromadas of Ukraine. The village covers an area of 1,28 km2, and the population of the vi... | null | null | null |
null | Write a Python program to evaluate a simple expression and print the output. | "7*6+20" | def evaluate_expression(exp):
return eval(exp)
expression = "7*6+20"
output = evaluate_expression(expression)
print(output) |
[HI Wikipedia] यरुशलम
यरुशलम (, अरबी : अल-क़ुद्स) एक अंतरराष्ट्रीय क्षेत्र है। फिलिस्तीन द्वारा यरुशलम को अपने देश की राजधानी होने का दावा किया जाता है। ये यहूदी पन्थ, ईसाई पन्थ और इस्लाम पन्थ, तीनों की पवित्र नगरी है। येरुशलम फिलीस्तीन देश का केन्द्र और राजधानी रहा है। यहीं मुसलमानों का परमपवित्र अल-अक्सा मस्जिद है। ... | null | null | null |
null | Determine the data type for the given value. | value: "hello" | string |
null | Create a function to calculate the sum of 2 numbers and return 'None' if both the parameters are not numbers. | def sum_of_two_numbers(x, y): if type(x) is not int or type(y) is not int: return None return x + y | |
null | Create a data structure in Python to store unique key-value pairs. | class KeyValuePairs:
def __init__(self):
self.data = dict()
def set(self, key, value):
self.data[key] = value
def get(self, key):
return self.data[key]
def containsKey(self, key):
return key in self.data
def containsValue(self, value):
for ... | |
null | Using HTML and CSS, create a page layout with two columns and a header row. | <html> <head> <style> .table { display: table; width: 100%; } .table-row { display: table-row; } .table-cell { display: table-cell; } </style> </head> <body> <div class="table"> <div class="table-row"> <div class="header table-cell">Header</div> </div> <div class="table-row"> <div class="table-cell">Column 1</div> <div... | |
[EN Wikipedia] Asia Minor (disambiguation)
Asia Minor is an alternative name for Anatolia, the westernmost protrusion of Asia, comprising the majority of the Republic of Turkey. Asia Minor may also refer to: Asia Minor (album), an album by Jamaican-born jazz trumpeter Dizzy Reece "Asia Minor" (instrumental), a 1961 in... | null | null | null |
null | Create a program in Java for displaying all prime numbers between 1 and 100. | public class PrimeNumbers { public static void main(String[] args) { System.out.println("All prime numbers between 1 and 100:"); int counter; for (int i = 2; i <= 100; i++) { counter = 0; for (int num = i; num >= 1; num--) { if (i % num == 0) { counter = counter + 1; } } if (counter == 2) { System.out.println(i); } } }... | |
null | Rewrite the following code snippet to an equivalent code in Python. | int i = 0; while (i < 10) { System.out.println(i); i++; } | i = 0 while i < 10: print(i) i += 1 |
null | Using only the existing variables, edit the code to subtract the `total_price` by 10%. | total_price = 100 final_price = total_price | final_price = total_price - (total_price * 0.10) |
null | Create a Python script that uses a SQL server database to store contact information. The database should include a table for contacts, with fields for first name, last name, email address, and phone number. | Not applicable | import sqlite3
conn = sqlite3.connect('contacts.db')
c = conn.cursor()
# Create a table
c.execute("""CREATE TABLE contacts (
first_name text,
last_name text,
email_address text,
phone_number text
)""")
# Insert a row of Data
c.execute("INSERT INTO contacts VALUES ('John', 'Doe', 'johndoe@example... |
null | Construct an algorithm in Python to calculate the Levenshtein distance between two strings. | def levenshtein(s1, s2):
l1 = len(s1)
l2 = len(s2)
matrix = [[0] * (l2 + 1) for _ in range(l1 + 1)]
for i in range(l1 + 1):
matrix[i][0] = i
for j in range(l2 + 1):
matrix[0][j] = j
for i in range(1, l1 + 1):
for j in range(1, l2 + 1):
if s1[i - 1] ==... | |
[DE Wikipedia] Gordon Davidson
Gordon Davidson ist der Name folgender Personen: * Gordon Davidson (Politiker) (1915–2002), australischer Politiker Gordon Davidson (Eishockeyspieler) (John Gordon Davidson; 1918–2004), kanadischer Eishockeyspieler Gordon Davidson (Regisseur) (1933–2016), US-amerikanischer Regisseur | null | null | null |
[EN Wikipedia] 2020–21 Middle Tennessee Blue Raiders women's basketball team
The 2020–21 Middle Tennessee Blue Raiders women's basketball team represents Middle Tennessee State University during the 2020–21 NCAA Division I women's basketball season. The team is led by sixteenth-year head coach Rick Insell, and plays t... | null | null | null |
null | Write a type hinting program in Python for a templating extension for a web application. | Not applicable | import typehints
@typehints.with_hints
def template(data):
# Retreive the data
greeting = data["greeting"]
message = data["message"]
name = data["name"]
# Construct the greeting
greeting = f"{greeting}, {name}!"
# Construct the final message
message = f"{greeting} {message}"
# Ret... |
null | Calculate the greatest common divisor of 36 and 24 | The greatest common divisor of 36 and 24 is 12. | |
null | Generate a code to make all the elements of a list positive. | def make_positive(lst): return [abs(x) for x in lst] | |
null | Write a SQL query to get the details of all Customers from the database. | SELECT * FROM Customers; | |
null | Write a Java method to swap of two integer values. | public static void swap(int x, int y){ int temp = x; x = y; y = temp; } | |
null | Create a JavaScript function that takes a string as an argument and reverses it. | function reverseString(str) { return str.split('').reverse().join(''); } | |
null | Create a Python script to generate a calendar representation of a given month. | Month : April; Year : 2020 | import calendar
year = 2020
month = 4
# create a calendar of the given month and year
cal = calendar.month(year, month)
# print it
print(cal)
# Output
April 2020
Mo Tu We Th Fr Sa Su
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19 |
null | Can you develop a program in Python that generates a random password of length 8 characters, which includes 1 uppercase letter, 1 lowercase letter, 1 number and 1 special character? | import string
import random
pwd_length = 8
alphabet = string.ascii_letters + string.digits + string.punctuation
pwd = ""
for i in range(pwd_length):
char = random.choice(alphabet)
if i % 4 == 0 and char in string.ascii_uppercase:
pwd += char
elif i % 4 == 1 and char in string.ascii_lowercase:
... | |
null | Create a loop in Java for printing all elements of an array of strings. | ["String1", "String2", "String3", "String4"] | String[] strArr = {"String1", "String2", "String3", "String4"}; for (String str : strArr) { System.out.println(str); } |
null | Build a decision tree model using Scikit-Learn to predict the type of iris plant based on petal length, petal width, sepal length and sepal width. | from sklearn import tree model = tree.DecisionTreeClassifier() model.fit(X_train, y_train) y_pred = model.predict(X_test) | |
null | Create a Python program to take a list of names and sort them alphabetically. | ['Adam', 'David', 'Mark', 'John', 'Sam'] | def sort_names_alphabetically(names):
names.sort()
print(names)
names = ['Adam', 'David', 'Mark', 'John', 'Sam']
sort_names_alphabetically(names)
# Output:
# ['Adam', 'David', 'John', 'Mark', 'Sam'] |
null | Create a script in Python to classify a given array of integers into even and odd numbers. | [1, 2, 3, 4, 5] | def classify(arr):
even = []
odd = []
for x in arr:
if x % 2 == 0:
even.append(x)
else:
odd.append(x)
return even, odd
even, odd = classify([1, 2, 3, 4, 5])
print("Even numbers: ", even)
print("Odd numbers: ", odd) |
null | Create a class object in Python which takes in two numbers and finds the sum and product. | class Numbers(object):
def __init__(self, num1, num2):
self.num1 = num1
self.num2 = num2
def find_sum(self):
return self.num1 + self.num2
def find_product(self):
return self.num1 * self.num2
#creating an object
num_object = Numbers(22, 10)
#finding sum
sum_resu... | |
[HI Wikipedia] टोनी ब्लेयर
टोनी ब्लेयर उर्फ एंथोनी चार्ल्स लिंटन ब्लेयर () (जन्म 6 मई, 1953) एक ब्रितानी राजनीतिज्ञ है, जो मई 1997 से जून 2007 तक यूनाइटेड किंगडम के प्रधानमन्त्री थे। 1994 से 2007 तक लेबर पार्टी के नेता रहे और वर्ष 1983 से 2007 तक सेजफ़ील्ड निर्वाचनक्षेत्र से संसद सदस्य रहे। वह अब अंतर्राष्ट्रीय मध्य-प... | null | null | null |
[HI Wikipedia] हारमोनियम
हारमोनियम (Harmonium) एक संगीत वाद्य यंत्र है जिसमें air प्रवाह किया जाता है और भिन्न चपटी स्वर पटलों को दबाने से अलग-अलग सुर की ध्वनियाँ निकलती हैं। इसमें हवा का बहाव पैरों, घुटनों या हाथों के ज़रिये किया जाता है, हालाँकि भारतीय उपमहाद्वीप में इस्तेमाल होने वाले हरमोनियमों में हाथों का प्रयोग... | null | null | null |
[HI Wikipedia] कनाडा
कनाडा उत्तरी अमेरिका का एक देश है जिसमें दस प्रान्त और तीन केन्द्र शासित प्रदेश हैं। यह महाद्वीप के उत्तरी भाग में स्थित है जो अटलाण्टिक से प्रशान्त महासागर तक और उत्तर में आर्कटिक महासागर तक फैला हुआ है। इसका कुल क्षेत्रफल 99.8 लाख वर्ग किलोमीटर है और कनाडा कुल क्षेत्रफल की दृष्टि से विश्व का दूस... | null | null | null |
null | Write a Python program to classify the following data into classes. | Student 1: {Name: Peter, Age: 34, Marks: 69}
Student 2: {Name:Alice, Age: 20, Marks: 89} | def classify_data(students):
for student in students:
if student['Marks'] < 70:
student['Class'] = 'Average'
elif student['Marks'] >= 70 and student['Marks'] < 90:
student['Class'] = 'Good'
elif student['Marks'] >= 90:
student['Class'] = 'Excellent' |
null | Develop a web page that displays the current temperature in various cities. | <!DOCTYPE html> <html> <head> <title>Weather Tracker</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>Current Weather</h1> <div class="data-table"></div> <script> $(function() { $.get('https://weather-tracker-server.herokuapp.com', function(data) { var ... | |
null | Create a CSS class named "card" to create a card with border-radius = 10 px.. | .card { border-radius: 10px; } | |
null | Create a HTML page that displays the top 5 countries in the world by population. | Country Population (Millions) China 1400 India 1351 United 329 Indonesia 265 Brazil 212 | <!DOCTYPE html> <html> <head> <title>World's Top 5 Countries By Population</title> <style> table { font-family: arial, sans-serif; border-collapse: collapse; width: 100%; } td, th { border: 1px solid #dddddd; text-align: left; padding: 8px; } </style> </head> <body> <h1>World's Top 5 Countries By Population</h1> <table... |
null | Develop a Python script to count the number of characters, words, and sentences present in a given string. | This is a sample sentence to test the program. | string = 'This is a sample sentence to test the program.' character_count = len(string) word_count = len(string.split()) sentence_count = len(string.split('.')) print('Number of characters: ', character_count) print('Number of words: ', word_count) print('Number of sentences: ', sentence_count) Output: Number of charac... |
[DE Wikipedia] Liste der Monuments historiques in Plesnoy
Die Liste der Monuments historiques in Plesnoy führt die Monuments historiques in der französischen Gemeinde Plesnoy auf. Liste der Immobilien |} Weblinks Plesnoy Plesnoy ! | null | null | null |
null | Create an API endpoint in NodeJS that returns a JSON object containing the current time. | const express = require('express'); const app = express(); app.get('/time', (req, res) => { const date = new Date(); const time = { hour: date.getHours(), minutes: date.getMinutes(), seconds: date.getSeconds() } res.json(time) }); app.listen(6000); | |
[CS Wikipedia] Täsong
Vesnice Täsong ( – Täsŏngdong) je jednou ze dvou vesnic v korejské demilitarizované zóně. Patří Jižní Koreji a leží jen přibližně dva kilometry jižně od Společné bezpečnostní oblasti a jen dva kilometry jihovýchodně od Kidžongu, severokorejské vesnice v korejské demilitarizované zóně. Obě vesnice... | null | null | null |
null | Implement a natural language processing model using the NLTK library in Python in order to extract sentiment from user feedback reviews. | "This product is great! It changed my life for the better" | import nltk
from nltk.sentiment.vader import SentimentIntensityAnalyzer
sid = SentimentIntensityAnalyzer()
review_text = "This product is great! It changed my life for the better"
scores = sid.polarity_scores(review_text)
print(scores['compound']) # 0.94
if scores['compound'] >= 0.05:
print("Positive sentime... |
null | Write a Python script to sort dictionaries as per the value. | {"a": 10, "b": 3, "c": 4, "d": 1, "e": 5} | dictionary = {"a": 10, "b": 3, "c": 4, "d": 1, "e": 5}
sorted_dict = dict(sorted(dictionary.items(), key=lambda x: x[1],reverse = False))
print("Sorting Dictionary as per the Value: ")
print("The Original Dictionary : ",dictionary)
print("The Sorted Dictionary : ",sorted_dict) |
null | Modify the code to make sure it is valid according to Java language specification. | public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } | public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } |
[CS Wikipedia] Siard Nosecký
František Kristián Ezechiel Nosecký (později přijal řádové jméno Siard, známý jako malíř Siard (Siardus) Nosecký, 12. dubna 1693, Praha-Staré Město – 18. ledna 1753, Velká Chyška (Pelhřimov), byl český římskokatolický duchovní, strahovský premonstrát a barokní malíř. Život Narodil se jako ... | null | null | null |
null | Create a C++ function to print all possible paths from top left to bottom right of a MxN matrix. | #include <iostream> // Maximum size of the matrix #define M 4 #define N 4 // Function to Print all the paths from top left to bottom right void printPathsUtil(int mat[M][N], int x, int y, int m, int n, int path[M][N]) { // Reached the bottom of the matrix so we are left with // only option to move right if (x == m - 1)... | |
[HI Wikipedia] अग्नि-१
अग्नि-1 मिसाइल स्वदेशी तकनीक से विकसित सतह से सतह पर मार करने वाली परमाणु सक्षम मिसाइल है। इसकी मारक क्षमता सात सौ किलोमीटर है। मिसाइल का परीक्षण ओड़िशा के बालासोर से करीब 100 किलोमीटर दूर व्हीलर द्वीप स्थित इंटीग्रेटेड टेस्ट रेंज [आइटीआर] से किया गया। 15 मीटर लंबी व 12 टन वजन की यह मिसाइल एक क्... | null | null | null |
null | Change the following Python program so that it prints out the palindromic substrings. | string = 'mom' | def palindromicSubstrings(string): for start in range(len(string) + 1): for end in range(start + 1, len(string) + 1): substring = string[start:end] if substring == substring[::-1]: print(substring) palindromicSubstrings(string) |
null | Search a given list for a specific element and return its position. | list_a = ["apple", "banana", "cherry", "date"] element = "date | def search_list(list_a, element): for i in range(len(list_a)): if list_a[i]==element: return i return -1 |
null | Write a JavaScript loop to print out all the values of an array. | arr = [1, 2, 3, 4, 5] | for (let i = 0; i < arr.length; i++) { console.log(arr[i]); } |
[CS Wikipedia] Nikumaroro
Nikumaroro (též Gardnerův ostrov) je součástí Phoenixských ostrovů ve státě Kiribati v západním Tichém oceánu. Ačkoliv se na ostrově nacházelo v minulosti osídlení, dnes je ostrov neobydlen. Popis Jde o odlehlý, protáhlý korálový atol trojúhelníkového tvaru s bohatou vegetací a velkou centrál... | null | null | null |
null | How to extract the domain name from an email address using JavaScript? | function getDomainFromEmail(email_address) { return email_address.split('@')[1]; } getDomainFromEmail('example@domain.com'); // 'domain.com' | |
[HI Wikipedia] व्यवहारवाद
व्यवहारवाद (बिहेवियरिज़म) के अनुसार मनोविज्ञान केवल तभी सच्ची वैज्ञानिकता का वाहक हो सकता है जब वह अपने अध्ययन का आधार व्यक्ति की मांसपेशीय और ग्रंथिमूलक अनुक्रियाओं को बनाये। मनोविज्ञान में व्यवहारवाद (बिहेवियरिज़म) की शुरुआत बीसवीं सदी के पहले दशक में जे.बी. वाटसन द्वारा 1913 में जॉन हॉपीकन... | null | null | null |
null | Code a function in JavaScript to find the area of a triangle given the lengths of its three sides. | function calculateArea(a, b, c) { let s = (a + b + c) / 2; return Math.sqrt(s * (s - a) * (s - b) * (s - c)); } | |
null | Generate a function in Python to find all permutations of a given string. | def permutations(str):
"""
This function returns a list of all possible
permutations of a given string
"""
# Base case
if not str:
return ['']
# Create a result list to store the permutations
result = []
# Iterate through all characters
for i in range(len(str... | |
null | Given the input, create a Python program which prints out all the words inside the input in alphabetical order. | I like cats and playing the piano | def print_words_in_order(string):
"""Print out all the words in the input in alphabetical order"""
words = string.split()
words.sort()
for word in words:
print(word) |
null | Output a valid C++ code to implement a Binary Tree. | class Node { public: int data; Node *left; Node *right; Node(int d) { data = d; left = NULL; right = NULL; } }; class BinaryTree { public: Node *root; BinaryTree() { root = NULL; } }; | |
null | Develop a code to check whether a number is a palindrome. | Number: 1234321 | """ def is_palindrome(num): # Initializing variables n = num rev = 0 while (n > 0): # Storing the remainder rev = (rev * 10) + n % 10 # Updating n n //= 10 # Checking if the reversed number is equal to the given number if (num == rev): return True return False # Function call print(is_palindrome(1234321)) """ Output: T... |
null | Create a Python program to find the area of a given trapezoid. | base1 = 2
base2 = 4
height = 3 | def area_trapezoid(base1, base2, height):
return (base1 + base2) * (height / 2)
print(area_trapezoid(2, 4, 3)) # Output: 9.0 |
null | Write an assembly code to calculate the sum of a series of numbers. | Series of numbers: [1, 5, 8, 10] | MOV R1, #1 ; Load the first number ADD R2, R1 ; Initialize the sum LOOP CMP R1, #10 ; Check if we have reached the last number BEQ SUM ; If yes, jump to SUM ADD R1, #1 ; Increment the number ADD R2, R1 ; Add the number to sum B LOOP ; Loop SUM ; At the end, the sum is in R2 |
null | Develop a dynamic programming approach to solve the 0/1 knapsack problem. | # A Dynamic Programming based Python Program for 0-1 Knapsack problem
# Returns the maximum value that can be put in a knapsack of capacity W
def knapsack(W, wt, val, n):
# Base Case
if n == 0 or W == 0 :
return 0
# If weight of the nth item is more than Knapsack of capacity W, then
#... | |
null | Create a function to calculate the Euclidean distance from (x, y) to (a, b). | def euclidean_distance(x, y, a, b): return np.sqrt((x-a)**2 + (y-b)**2) | |
null | Create a python program to convert a time from 12-hour to 24-hour format. | def time24(a):
if len(a) == 4:
ampm = 'AM'
time = a
elif len(a) == 7:
ampm = a[5:7]
time = a[0:5]
time_split = time.split(':')
if ampm == 'PM':
if time_split[0] != '12':
time_split[0] = str(int(time_split[0])+ 12)
elif ampm == 'AM':
... | |
null | Using the given set and scores, find the maximum score. | set = {1, 2, 3}, scores = {4, 3, 6}, | # Find the maximum score maxScore = max(scores[i] for i in set) print(maxScore) |
null | Describe succinctly the benefits of using a database for storing Big Data. | Using a database for storing Big Data can provide many benefits, such as scalability, improved data consistency and integrity, improved data security, and decreased maintenance costs. Database technologies also facilitate the ability to perform various analytics techniques, such as mining and predictive analytics, on l... | |
null | Design a program in Python to compare two strings and output the number of characters that are different. | def count_differences(str1, str2):
differences = 0
for letter1, letter2 in zip(str1, str2):
if letter1 != letter2:
differences +=1
return differences | |
null | Create a program in Python which takes in a user's name and prints out a customized greeting message. | def greeting(name):
'''This program will take in a user's name and prints out a customized greeting message.'''
print('Hello, %s! Welcome!' % (name))
name = input('What is your name? ')
greeting(name) | |
null | Write a function to square a given number and return its result. | number = 5 | def square_number(number): return number**2 print(square_number(number)) |
null | Generate a universal one-time password (OTP) algorithm in Python. | import secrets
def get_otp(length=6):
digits = "0123456789"
otp = ""
for i in range(length):
otp += secrets.choice(digits)
return otp
print(get_otp()) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.