text stringlengths 141 2.89k ⌀ | instruction stringlengths 19 1.5k ⌀ | input stringlengths 0 800 ⌀ | output stringlengths 1 2.5k ⌀ |
|---|---|---|---|
null | Use NLP techniques in Python to generate a tagline from a sample text | Sample text: this painting is an amazing representation of the beauty of nature. | import nltk
from nltk.tokenize import word_tokenize
sample_text = "This painting is an amazing representation of the beauty of nature."
words = word_tokenize(sample_text)
tags = nltk.pos_tag(words)
generator_words = ["Explore","Discover","Witness","Captivate", "Embrace"]
for tag in tags:
if tag[1] == 'JJ':
... |
null | Edit the given HTML code so that the header of the web page is centered. | <html> <head> <title>Centering a header</title> </head> <body> <h1>This header is not centered</h1> </body> </html> | <html> <head> <title>Centering a header</title> </head> <body> <h1 style="text-align: center;">This header is now centered</h1> </body> </html> |
null | Create a function to extract the first key of a given dictionary in Python. | def get_first_key(d):
if d:
return next(iter(d))
return None | |
null | Create an object-oriented Python program to model a Vehicle. | class Vehicle:
def __init__(self, capacity, speed):
self.capacity = capacity
self.speed = speed
def increase_speed(self):
self.speed += 10
def decrease_speed(self):
if self.speed > 0:
self.speed -= 10 | |
null | Write a Java program to find the sum of two arrays of length 10 | public static int[] sumArrays(int[] arr1, int[] arr2){ int[] result = new int[arr1.length]; for(int i=0; i<arr1.length; i++){ result[i] = arr1[i] + arr2[i]; } return result; } | |
null | Write a for loop to output all the odd numbers from 1 to 10 in Python. | for i in range(1,11): if (i % 2 != 0): print(i) | |
null | Create a Python program that takes a given list of strings and prints out the string with the maximum length. | ['code', 'programming', 'computer science', 'javascript', 'HTML'] | max_len = 0 max_string = '' for elem in ['code', 'programming', 'computer science', 'javascript', 'HTML']: if len(elem) > max_len: max_len = len(elem) max_string = elem print(max_string) |
null | Write an SQL script to list all items with a price greater than 10$. | Table Name = Item | SELECT * FROM Item WHERE price > 10; |
null | Suggest a plugin or software that can be used to debug a React application. | React's official debugging tool, the React Developer Tools, is a great plugin for debugging React applications. It is available for both Chrome and Firefox, and provides detailed information about the component hierarchy, current props and state of the application, and detailed performance metrics. Additionally, React'... | |
null | Given two numbers, find their LCM. | a = 15 b = 10 | 30 |
null | Create an automation script using Python Selenium to navigate to a web page, click a link, and take a screenshot of the page. | Input: URL:
https://www.example.com | from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# initialise the driver
driver = webdriver.Chrome()
# go to the given URL
driver.get("https://www.example.com")
# wait for the page to load
wait = WebDriverWait(driv... |
null | Develop a Python program that calculates the mean of list of numbers. | [1, 5, 2, 4, 9] | def calculate_mean(nums):
total = 0
for n in nums:
total += n
mean = total / len(nums)
return mean
mean = calculate_mean([1, 5, 2, 4, 9]) |
null | Describe how reinforcement learning works. | Reinforcement learning is a type of machine learning algorithm that allows an agent to learn from its environment through trial and error. The agent takes an action within a given environment and receives a reward or punishment based on its performance. The agent uses this feedback to adjust its actions over time in or... | |
null | Write a python code that takes the starting and ending numbers of a range, and returns the largest prime within that range. | 3, 22 | def largest_prime_in_range(start, end):
largest_prime = 0
# Iterate over the range
for i in range(start, end + 1):
# Check if number is prime
is_prime = True
if i > 1:
for j in range(2, ceil(sqrt(i))+ 1):
if i % j == 0:
is_prime = False... |
null | Generate a JavaScript object with two properties. | const myObject = { name: 'John', age: 25 }; | |
[HI Wikipedia] गोविन्द शंकर कुरुप
गोविन्द शंकर कुरुप या जी शंकर कुरुप (५ जून १९०१-२ फरवरी १९७८) मलयालम भाषा के प्रसिद्ध कवि हैं। उनका जन्म केरल के एक गाँव नायतोट्ट में हुआ था। ३ साल की उम्र से उनकी शिक्षा आरंभ हुई। ८ वर्ष तक की आयु में वे 'अमर कोश' 'सिद्धरुपम' 'श्रीरामोदन्तम' आदि ग्रन्थ कंठस्थ कर चुके थे और रघुवंश महा... | null | null | null |
[CS Wikipedia] The Weather Girls
The Weather Girls je americké dívčí pěvecké duo, které bylo založeno v roce 1982. Skupina se zviditelnila díky klubovému hitu "It's Raining Men". Tato dívčí formace je známa i jako Two Tons O' Fun . Historie Skupinu tvoří Martha Washová a Izora Armsteadová. I když Weather Girls byla te... | null | null | null |
null | Create a classification model using the SciKit-Learn library in Python to predict if a given email is a spam email or not. | Example training data of emails and their label ("spam" or "not spam") | from sklearn.model_selection import train_test_split
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB
# load the data
labels = ['spam', 'not spam']
data = [...] # example data of emails and labels
# convert the text to a bag of words model
vectorizer = CountVec... |
null | Create a for-loop in Python to print a list of strings that contain only the vowels from a given list of strings. | words = ["apple", "bear", "cat", "dog"] | for word in words:
vowels = ""
for x in word:
if x in ('a', 'e', 'i', 'o', 'u'):
vowels += x
print(vowels) |
null | Create a Python script that takes a list of strings as an input and prints the length of each string in the list. | words = ['dog', 'cat', 'spring', 'summer'] | words = ['dog', 'cat', 'spring', 'summer']
for word in words:
print(len(word)) |
null | Generate an HTML select element containing the names of all continents. | <select name="continents"> <option value="Africa">Africa</option> <option value="Antarctica">Antarctica</option> <option value="Asia">Asia</option> <option value="Australia">Australia</option> <option value="Europe">Europe</option> <option value="North America">North America</option> <option value="South America">South... | |
null | Create a Python Program to sort a list of strings according to the length of their elements. | list = ["apple", "cat", "banana", "dog"] | def ascending_sort(list):
list.sort(key=len)
return list
list = ["apple", "cat", "banana", "dog"]
result = ascending_sort(list)
print(result) |
[DE Wikipedia] Bernie Plain
Bernie Plain (eigentlich Bernard John Plain; * 3. Dezember 1946) ist ein ehemaliger britischer Langstreckenläufer. Bei den British Commonwealth Games 1970 in Edinburgh wurde er für Wales startend Elfter über 10.000 m und kam über 5000 m auf den 13. Platz. 1971 siegte er bei den Walisischen ... | null | null | null |
null | Write an SQL query to list all customers who are over the age of 25. | SELECT * FROM customers WHERE age > 25; | |
null | JAVA code to calculate the Fibonacci number at a given position. | public class Fibonacci { public static long Fibonacci(int n) { if (n <= 1) { return n; } return Fibonacci(n - 1) + Fibonacci(n - 2); } } | |
null | Create a Python program that reads in a list of strings from the keyboard and sorts them alphabetically. | sorted_list = []
input_strings = input("Enter a list of strings, separated by spaces: ")
input_strings = input_strings.split()
for string in input_strings:
sorted_list.append(string)
sorted_list.sort()
print(sorted_list) | |
[HI Wikipedia] जॉर्ज सुदर्शन
एन्नाक्कल चांडी जॉर्ज सुदर्शन () (ई॰ सी॰ जी॰ सुदर्शन के नाम से भी जाने जाते थे; जन्म १६ सितम्बर १९३१ - १३ मई २०१८) टेक्सास विश्वविद्यालय, ऑस्टिन में प्रोफेसर, लेखक और भारतीय वैज्ञानिक थे। पूर्व जीवन जॉर्ज सुदर्शन का भारत में केरल राज्य के कोट्टायम जिले के पल्लम नामक ग्राम में जन्म सैंट थॉम... | null | null | null |
null | Create a script in Python that calculates the average length of a given list of strings | list_of_strings = ["cat", "dog", "mouse", "elephant"] | def calculate_avg_string_length(string_list):
total_length = 0
for item in string_list:
total_length += len(item)
return total_length / len(string_list)
list_of_strings = ["cat", "dog", "mouse", "elephant"]
result = calculate_avg_string_length(list_of_strings)
print(result) |
null | Create a SQL query to find all users from the “users” table who have a last name of “Smith”. | SELECT * FROM users WHERE lastName = 'Smith'; | |
null | Construct a Python class that takes a given number and calculates the sum of the digits. | 6342 | class SumOfDigits:
def __init__(self, num):
self.num = num
def calculate_sum_of_digits(self):
total = 0
for ch in str(self.num):
total += int(ch)
return total
digit_sum = SumOfDigits(6342)
result = digit_sum.calculate_sum_of_digits()
print(result) |
null | Develop a kNN model in Python to predict the type of wine based on the features and the data listed in the input. | Input:
Data:
Type | Alk | Res | Mal
Red | 11 | 0.3 | 6.8
White | 12 | 0.5 | 5.3
Features: Alk, Res, Mal | import pandas as pd
from sklearn.neighbors import KNeighborsClassifier
# Data
data = [['Red', 11, 0.3, 6.8],
['White', 12, 0.5, 5.3]]
df = pd.DataFrame(data, columns=['Type', 'Alk', 'Res', 'Mal'])
# Feature and target
X = df.drop('Type', axis=1)
y = df['Type']
# Model development
knn = KNeighborsClassifier(n... |
null | Create an array of descending numbers starting from 10 to 1 using a for loop. | numberArray = [] for x in range(10, 0, -1): numberArray.append(x) print(numberArray) # [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] | |
[EN Wikipedia] Bangalore Muslims FC
Bangalore Muslims Football Club is a professional football club based in Bangalore, Karnataka, that emerged as one of the strongest football teams during the 1930s, 40s and 50s. History Bangalore Muslims became the first Indian club to win Rovers Cup in 1937, the second oldest footb... | null | null | null |
null | Construct a function to print out the odd numbers in a given array | def odd_numbers(arr): for i in range(len(arr) ): if arr[i] % 2 != 0: print(arr[i]) | |
[EN Wikipedia] Albert Weinert
Albert Weinert (June 13, 1863 – November 29, 1947) was a German-American sculptor. Born in Leipzig, Kingdom of Saxony, Weinert attended the Royal Academy of Art and Applied Art there and then the Académie Royale des Beaux-Arts in Brussels, Belgium. In 1886, he emigrated to the United Stat... | null | null | null |
null | Write a module in Rust to identify palindromic strings. | fn is_palindrome(target: &str) -> bool { let mut char_vec: Vec<char> = target.chars().collect(); char_vec.reverse(); let reversed_target: String = char_vec.into_iter().collect(); if target == reversed_target { return true; } return false; } | |
null | Print a multiplication table of a given number | num = 5 | for i in range(1,11): print(f'{num} x {i} = {num * i}') |
null | Write a Python script to process user input and generate a response according to the user's query. | Sample queries:
"Give me the weather in New York"
"What is the population of China?" | # Libraries
import requests
import json
# Get user input
user_input = input('Please enter your query: ')
# Process user input
if 'weather' in user_input:
# Get weather data
city = user_input.split()[-1] # extract city from user query
r = requests.get(f'http://api.openweathermap.org/data/2.5/weather?q={city}&units... |
null | Using the following HTML, add an id attribute to the <div> element. | <div>Hello</div> | <div id="myDiv">Hello</div> |
[HI Wikipedia] नेल्सन मंडेला
नेल्सन ख़ोलीह्लह्ला मंडैला (ख़ोसा: Nelson Rolihlahla Mandela; 18 जुलाई 1918 – 5 दिसम्बर 2013) दक्षिण अफ्रीका के प्रथम अश्वेत भूतपूर्व राष्ट्रपति थे। राष्ट्रपति बनने से पूर्व वे दक्षिण अफ्रीका में सदियों से चल रहे रंगभेद का विरोध करने वाले अफ्रीकी नेशनल कांग्रेस और इसके सशस्त्र गुट उमखोंतो ... | null | null | null |
null | Create a REST API using Python and Flask for a blog post. This API should provide endpoints to create a new post, update an existing post, delete a post, and list all posts. | Not applicable | from flask import Flask, request
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
# creating the necessary dictionaries to store blog posts
blog_posts = {}
class BlogPost(Resource):
# endpoint to create a blog post
def post(self, post_id):
post_data = request.get_j... |
[DE Wikipedia] Traralgon International 2022/Herren
Das Traralgon International 2022 war ein Tennisturnier, das vom 3. bis 9. Januar 2022 in Traralgon stattfand. Es war Teil der ATP Challenger Tour 2022 und wurde im Freien auf Hartplatz ausgetragen. Das Teilnehmerfeld der Einzelkonkurrenz bestand aus 48 Spielern, jenes... | null | null | null |
null | Calculate the area of a triangle with base b=4 and height h = 5. | The area of the triangle is 10 square units. | |
[CS Wikipedia] TG3
TG3 (celým názvem Telegiornale Tre) je zpravodajská relace vysílaná na programu Rai 3 od roku 1979. Celosvětově se vysílá na Rai Italia. Historie TG3 se začal vysílat v roce 1979, společně s TGR, které bylo až do reformy v roce 1987 s TG3 úzce spjato. Vysílala se dvě vydání, v 19.00 a 22.00 hod. Obs... | null | null | null |
null | Given a string s, determine if it is an isogram. | "isogram" | bool isIsogram(string s) { int count[256] = {0}; int length = s.length(); for (int i=0; i<length; i++) { if (count[s[i]] == 0) count[s[i]]++; else return false; } return true; } |
null | Suggest a code to find the longest sub-string in a string. | string = "The quick brown fox jump over lazy dog" | def find_longest_substring(string): # get the length of the string length = len(string) # variable to store the longest substring length longest_substring_length = 0 # variable to store the longest substring longest_substring = '' # loop through the string for i in range(length): tmp_str = '' for j in range(i, length):... |
null | Develop a recursive solution in Python to calculate the Fibonacci sequence up to the nth term. | n = 7 | def fibonacci_sequence(n):
if n <= 1:
return n
else:
return(fibonacci_sequence(n-1) + fibonacci_sequence(n-2))
print("The Fibonacci sequence up to the nth term:")
for i in range(7):
print(fibonacci_sequence(i)) |
null | Write a code to reverse a sentence word by word. | This is a sentence | def reverse_words(sentence): words = sentence.split(' ') reversed_words = [word[::-1] for word in words] return ' '.join(reversed_words) print(reverse_words('This is a sentence')) # Output: sihT si a ecnetnes |
[HI Wikipedia] बरेली
भारत के सबसे बड़े राज्य उत्तर प्रदेश में स्थित बरेली जनपद राष्ट्रीय राजधानी दिल्ली और उत्तर प्रदेश की राजधानी लखनऊ तक के राष्ट्रीय राजमार्ग के बीचों-बीच स्थित है। प्राचीन काल से इसे बोलचाल में बांस बरेली का नाम दिया जाता रहा और अब यह बरेली के नाम से ही पहचाना जाता है। इस जनपद का शहर महानगरीय है। य... | null | null | null |
[DE Wikipedia] Agnes-Bernauer-Straße
Die Agnes-Bernauer-Straße ist eine 3,2 km lange Straße und verbindet den Münchner Stadtteil St. Ulrich in Laim mit Pasing. Beschreibung Sie verläuft südlich parallel zur Landsberger Straße. An ihr liegen das Westbad, das Eis- und Funsportzentrum West, St. Ulrich (104), St. Willibal... | null | null | null |
null | Use a loop to print out each element of the list. | list = [1, 2, 3, 4] | for element in list: print(element) |
[CS Wikipedia] Danny Ecker
Danny Ecker (* 21. července 1977, Leverkusen) je bývalý německý sportovec, atlet, jehož specializací byl skok o tyči. Závodil za atletický oddíl TSV Bayer Leverkusen. V roce 2007 se stal v Birminghamu halovým mistrem Evropy a vybojoval bronzovou medaili na světovém šampionátu v Ósace. Již dř... | null | null | null |
null | Write a function to query a database table 'trips' and return a list of all trips made over the past three months. | def query_trips(): start_date = datetime.datetime.now() - datetime.timedelta(days=90) end_date = datetime.datetime.now() sql = 'SELECT * FROM trips WHERE date_of_trip >= %s AND date_of_trip <= %s' try: conn = connect_to_database() cur = conn.cursor() cur.execute(sql, (start_date, end_date)) trips = cur.fetchall() cur.c... | |
null | Describe a use case of the ternary operator in Python. | The ternary operator can be used to conditionally assign a value. For example, the following code assigns max to the larger value of x and y: max = x if x > y else y | |
[EN Wikipedia] Arithmetic mean
In mathematics and statistics, the arithmetic mean ( ), arithmetic average, or just the mean or average (when the context is clear) is the sum of a collection of numbers divided by the count of numbers in the collection. The collection is often a set of results from an experiment, an obs... | null | null | null |
null | Create a program to print all prime numbers from 1 to a given number. | def print_prime_numbers(n): for num in range(2,n+1): if is_prime(num): print(num) | |
null | Design a function in Python to find all the elements in an array that are divisible by 3. | arr = [3, 8, 15, 20, 7] | arr = [3, 8, 15, 20, 7] def divisible_by_3(arr): result = [] for element in arr: if element % 3 == 0: result.append(element) return result print(divisible_by_3(arr)) # Output: [3, 15, 20] |
null | Add code to a Python program that will print a multiplication table of numbers from 1 to 5. | for i in range(1,6):
for j in range(1,6):
print(i*j,end="\t")
print("\n")
# Output:
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25 | |
null | Create a Python library to manipulate 2D matrices. The library should include functions for creating matrices, multiplying matrices, and analyzing the elements of matrices. | Not applicable | from collections import defaultdict
class Matrix:
def __init__(self, rows, cols):
self.rows = rows
self.cols = cols
self.matrix = [[0 for i in range(cols)] for j in range(rows)]
def create_matrix(rows, cols, values):
m = Matrix(rows, cols)
for i in range(rows):
for j in range(cols):
m.matrix[i][j]... |
null | Create a program that adds up 11 numbers. | 11 numbers: 3, 6, 8, 12, 4, 19, 23, 12, 15, 10, 20 | # defining a function def add_ele(numbers): # Initialize result result = 0 i = 0 # Iterating elements in list for i in range(len(numbers)): result += numbers[i] return result # Driver code numbers = [3, 6, 8, 12, 4, 19, 23, 12, 15, 10, 20] print(add_ele(numbers)) |
null | Create a Python module to analyze SQL database tables and return meta information like number of rows, column names and data types. | import sqlite3
def get_table_meta_info(db_name, table_name):
conn = sqlite3.connect(db_name)
cur = conn.cursor()
cur.execute("SELECT * FROM "+ table_name)
col_names = [tuple[0] for tuple in cur.description]
row_length = len(col_names)
cur.execute("PRAGMA table_info("+ table_name +")"... | |
null | Explain the concept of assembly language. | Assembly language is a low-level programming language that provides a symbolic representation of the machine instructions for a specific processor or family of processors. It is typically used when writing code for embedded systems, or when the target processor and/or instruction set of the program is not well-known. A... | |
null | Create an HTML page with a layout consisting of 3 containers: one on the left and two on the right. | <html> <head> </head> <style> #container{ width: 100%; display: flex; } #left-container{ width: 20%; } #right-containers{ width: 80%; display: flex; } #right-container1{ width: 50%; } #right-container2{ width: 50%; } </style> <body> <div id="container"> <div id="left-container"> <!-- Left Container Content --> </div> <... | |
null | Find the index of the element that occurs only once in the array. | arr = [1, 1, 5, 5, 6, 8]; | def find_unique_element(arr): index = -1 for i in range(len(arr)): freq = 0 for j in range(len(arr)): if arr[i] == arr[j]: freq += 1 if freq == 1: index = i break return index # Testing arr = [1, 1, 5, 5, 6, 8] index = find_unique_element(arr) print("Index of the unique element is: ", index) |
null | Write a function in Python to optimize a given objective function using gradient descent. | def gradient_descent(lr, x, y):
m_curr = b_curr = 0
iterations = 10000
n = len(x)
for i in range(iterations):
y_predicted = m_curr*x + b_curr
cost = (1/n) * sum([val**2 for val in (y-y_predicted)])
md = -(2/n)*sum(x*(y-y_predicted))
bd = -(2/n)*sum(y-y_predicted)
... | |
null | Using C#, write a method that returns a list of strings containing only elements of an input string array containing the letter 'a'. | string[] s = {"apple", "banana", "cat"}; | public static List<string> FilterByLetterA(string[] s) { List<string> list = new List<string>(); foreach (string item in s) { if (item.Contains("a")) { list.Add(item); } } return list; } |
null | Write a SQL query to find all records from the table 'products' with a price equal to 10. | SELECT * FROM products WHERE price = 10; | |
null | Write a Python program to find all palindromic words in a given list. | words = ["word", "racecar", "level", "pop", "mom", "nursesrun"] | def palindrome_words(words):
"""This function takes in a list of words and returns a list of palindromic words"""
palindrome_words = []
for word in words:
if word == word[::-1]:
palindrome_words.append(word)
return palindrome_words |
null | Write an SQL query that displays a table of the ten most commonly used words in the given article. | Today, I climbed the tallest mountain in the world. It was an incredible experience with stunning views and a sense of accomplishment at the top. | SELECT word, COUNT(*) AS occurrence FROM article GROUP BY word ORDER BY occurrence DESC LIMIT 10; |
null | You are given a list of float numbers. Write a code to sort them in ascending order. | arr = [2.5, 3.2, 2.1, 4.6, 1.6] | def bubbleSort(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] return arr sorted_arr = bubbleSort(arr) print(sorted_arr) // Output: [1.6, 2.1, 2.5, 3.2, 4.6] |
null | Write an R command to sort the data in a data frame based on the values of one column. | df <- data.frame(A = c(4, 5, 11, 8), B = c(13, 12, 6, 11), C = c(4, 5, 7, 3)) | df <- df[order(df$A),] |
null | Rewrite the following code in the form of list comprehension. | names = ["Max","John","Monica","Harry","Steve"] upper_names = [] for name in names: upper_names.append(name.upper()) | upper_names = [name.upper() for name in names] |
null | Create an algorithm for finding the minimum element in an array of integers. | [3, 7, 14, 2, 11] | def find_min(array): min_element = array[0] for i in range(1, len(array)): if array[i] < min_element: min_element = array[i] return min_element |
[DE Wikipedia] Anthony Zambrano
Anthony José Zambrano de la Cruz (* 17. Januar 1998 in Maicao) ist ein kolumbianischer Leichtathlet, der sich auf den 400-Meter-Lauf spezialisiert hat. 2019 wurde er bei den Weltmeisterschaften in Doha mit Südamerikarekord Vizeweltmeister. 2021 gewann er bei den Olympischen Sommerspiele... | null | null | null |
null | Generate a valid SQL query to select data from table 'user_accounts' | SELECT * FROM user_accounts; | |
null | Write a function that takes in a string of text and counts the number of times each letter appears in the string | text = "The quick brown fox jumps over the lazy dog" | def count_letters(text): letter_count = {} for character in text: if character not in letter_count: letter_count[character] = 1 else: letter_count[character] += 1 return letter_count print(count_letters(text)) |
null | Construct a SQL query to find all the authors whose book titles contain "python" in a given database. | SELECT author
FROM books
WHERE title LIKE '%python%'; | |
[CS Wikipedia] Volby v Monaku
Volby v Monaku jsou svobodné. Volí se pouze do jednokomorového parlamentu 24 členů na pětileté volební období. Volit mohou občané nad 18 let. Dominantní politické strany Monacká unie Obzor Monaka Obnova Reference | null | null | null |
null | Create a program in Python that computes the n-th Fibonacci number. | 15 | def calculate_fibonacci(n):
"""
Calculates the n-th Fibonacci number.
Args:
n: the n-th Fibonacci number.
Returns:
The Fibonacci number at a given index.
"""
# Base cases
if n == 0:
return 0
elif n == 1:
return 1
# Calculate n-th Fibonacci number
... |
[CS Wikipedia] Seemann
Seemann (česky Námořník) je druhý singl skupiny Rammstein. Byl vydán 8. ledna 1996. Na obalu singlu je vyobrazena loď z videoklipu k songu Seemann, jenž byl natočen roku 1996 v berlínských ateliérech. Na singlu se nenachází remixy, kromě skladby Seemann obsahuje také píseň „Wollt ihr das Bett in... | null | null | null |
null | Write a Python function to check if two given strings are anagrams or not. An anagram is two phrases or sentences that use the same exact letters and line up one letter to another. | def is_anagram(str1, str2):
# Get oder of the strings
str1_order = sorted(str1)
str2_order = sorted(str2)
# Compare the order of strings
if (str1_order == str2_order):
return True
return False | |
null | Using a for loop, print out a countdown from 10 to 1. | for i in range(10, 0, -1): print(i) | |
[EN Wikipedia] Henrikas Natalevičius
Henrikas Natalevičius (born 1953 in Vilnius) is a Lithuanian painter. Henrikas is a Lithuanian artist. His works have been displayed in galleries all over Lithuania, in Vilnius, the Lithuanian Art Museum and the National M. K. Čiurlionis Museum of Art in Kaunas. See also List of Li... | null | null | null |
null | Modify the following Python program to explore and retrieve data from a dataset using Pandas. | import pandas as pd
df = pd.read_csv('data.csv')
print(df) | import pandas as pd
df = pd.read_csv('data.csv')
print(df.head())
print(df.info())
print("Average age of passengers:", df['Age'].mean())
print("Number of female passengers:", df[df['Sex'] == 'female'].shape[0])
print("Oldest passenger:", df.loc[df['Age'].idxmax()]) |
null | Analyze the given HTML code. | <div> <h3>Title</h3> <p>paragraph</p> <button>Button</button> </div> | This code creates a div element which contains an h3 for a title, a p for a paragraph, and a button element. It will be rendered as a box with the title at the top, followed by the paragraph and button below it. |
null | Create a python function to calculate the BMI of a person given the person's weight and height in 'Metric' unit. | weight = 80 (kg)
height = 180 (cm) | def calculateBMI(weight, height):
# convert height from cm to m
height = height/100
# calculate BMI
BMI = weight / (height*height)
return BMI
if __name__ == '__main__':
weight = 80 # in kg
height = 180 # in cm
BMI = calculateBMI(weight, height)
print(f'The BMI of the ... |
[CS Wikipedia] György Sárosi
György Sárosi, rodným jménem György Stefanicsics (5. srpen 1912 – 20. červen 1993), byl maďarský fotbalista. Hrával na pozici útočníka či záložníka. S maďarskou reprezentací vybojoval stříbrnou medaili na mistrovství světa roku 1938. Na tomto šampionátu byl kapitánem svého týmu, vstřelil 5... | null | null | null |
null | Develop a Python function for validating email addresses according to RFC2822. | import re
def is_valid_email(email):
# Making sure it contains an @ and at least one '.'
if re.match("^.+@[^.].*\.[a-z]{2,10}$", email) is None:
return False
return True | |
null | Identify all the variables in this C++ program. | #include <iostream> int main() { int number = 10; std::cout << number; return 0; } | The variable in the above program is 'number'. |
null | Create a command line application in Python that takes two numbers as arguments and prints the addition of them. | Not applicable | import sys
def add(num1, num2):
return num1 + num2
if __name__ == '__main__':
num1 = int(sys.argv[1])
num2 = int(sys.argv[2])
print(add(num1, num2)) |
null | Create an object with two fields, a name and an id. | var obj = { name: 'John', id: '12345' }; | |
null | Generate a four-line Python program that uses a loop to add all the integers from 1 to 10 and print the result. | n = 0
for i in range(1,11):
n = n + i
print("The sum of all the numbers between 1 and 10 is:", n) | |
null | Extract the common key words from the given two strings using a Python script. | String 1: This programming language is easy to learn String 2: Comparing to other languages, this language is simpler | common_key_words = ["language", "easy", "learn", "comparing", "other", "simpler"] |
null | Given a tree, traverse it in the pre-order manner. | def pre_order_traversal(tree): # Visit the root print(tree.value) # Traverse the left subtree, if it exists if tree.left: pre_order_traversal(tree.left) # Traverse the right subtree, if it exists if tree.right: pre_order_traversal(tree.right) | |
null | Write a function that returns the sum of all the elements of a list in Python. | def mySum(list):
total = 0
for num in list:
total += num
return total | |
null | Evaluate the given algebraic expression by substituting 4 for x. | expression = 2x + 6 | expression = 2 * 4 + 6 = 14 |
null | Reorder a given array in specialized order | def reorder_array(arr): """ Reorder a given array in specialized order :param arr: the input array to reorder :return: the reordered array """ # determine the size of the array n = len(arr) # create a new array to store the reordered results reordered = [0] * n # loop through the array for i in range(n): # calculate th... | |
null | Write a Python program to find the maximum number in a list of numbers. | [1, 9, 5, 18, 21, 2] | def find_max(nums):
max_num = nums[0]
for x in nums:
if x > max_num:
max_num = x
return max_num
print(find_max([1,9,5,18,21,2])) |
[EN Wikipedia] Anatomy
Anatomy () is the branch of biology concerned with the study of the structure of organisms and their parts. Anatomy is a branch of natural science that deals with the structural organization of living things. It is an old science, having its beginnings in prehistoric times. Anatomy is inherently... | null | null | null |
null | Develop a unit test in Python to verify correctness of an algorithm. | def algorithm(arr):
sum = 0
for i in range(len(arr)):
sum += arr[i]
return sum | import unittest
class TestAlgorithm(unittest.TestCase):
def test_algorithm(self):
10 = algorithm([1, 2, 3, 4])
self.assertEqual(10, 10)
40 = algorithm([10, 10, 10, 10])
self.assertEqual(40, 40)
if __name__ == '__main__':
unittest.main() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.