text stringlengths 141 2.89k ⌀ | instruction stringlengths 19 1.5k ⌀ | input stringlengths 0 800 ⌀ | output stringlengths 1 2.5k ⌀ |
|---|---|---|---|
null | Create a Python program that finds the longest word in a sentence. | My name is John | def find_longest_word(sentence):
# Split sentence into a list of words
words = sentence.split()
# Track the longest word
longest_word = ''
# Iterate over the list of words
for word in words:
if len(word) > len(longest_word):
longest_word = word
# Return the longest word
... |
null | Write a SQL query to count the number of employees in a department with id “IT-006”. | SELECT COUNT(*) FROM Employees WHERE department_id = 'IT-006'; | |
null | Create a simple web page using HTML and CSS to display a list of the top 5 most popular programming languages. | Not applicable | <!DOCTYPE html>
<html>
<head>
<title>Top 5 Programming Languages</title>
<style>
ul {
list-style: none;
font-family: sans-serif;
font-size: 20px;
}
li {
padding-top: 10px;
}
</style>
</head>
<body>
<h1>Top 5 Programming Languages</h1>
<ul>
<li>JavaScript</li>
<li>Python</li>
<li>Java</li>
<li>C#</li>
... |
[HI Wikipedia] कराड
कराड भारत के महाराष्ट्र राज्य के सातारा ज़िले में एक नगर और तालुका है। यह नगर कृष्णा नदी तथा कोयना नदी के संगम पर सतारा नगर से 85 किमी दक्षिण-पूर्व में बसा है। कराड को "यशवंत नगरी" के नाम से भी जानी जाती है। यह मुम्बई से 320 किमी, सांगली से 45 किमी,और पुणे से 159 किमी दूर है। विवरण इस नगर का स्वायत... | null | null | null |
null | Create an HTML element that displays text “Welcome” with the color blue. | <span style="color: blue;">Welcome</span> | |
null | Build a Python code to convert a list to a dictionary using the list values as the keys. | my_list = ["This", "is", "a", "list"] | my_dict = {}
for item in my_list:
my_dict[item] = None
print(my_dict) |
null | Create a SQL query that returns all employees in the "Marketing" department. | SELECT * FROM employees WHERE department = 'Marketing'; | |
null | Implement a code in Python for reversing a string. | def reverse_string(string):
reversed_string = ""
for char in string:
reversed_string = char + reversed_string
return reversed_string | |
null | Convert the list of numbers into a dictionary where the numeric values are the keys and the corresponding characters are the values. | num_list = [1, 2, 3] char_list = ['a', 'b', 'c'] | dict_num_char = {num_list[i]: char_list[i] for i in range(len(num_list))} print(dict_num_char) |
[HI Wikipedia] गोवा
गोवा या गोआ (कोंकणी: गोंय), क्षेत्रफल के अनुसार से भारत का सबसे छोटा और जनसंख्या के अनुसार चौथा सबसे छोटा राज्य है। पूरी दुनिया में गोवा अपने सुन्दर समुद्र के किनारों और प्रसिद्ध स्थापत्य के लिये जाना जाता है। गोवा पहले पुर्तगाल का एक उपनिवेश था। पुर्तगालियों ने गोवा पर लगभग 450 सालों तक शासन किया ... | null | null | null |
null | Create a class called "Animal" containing three attributes - name, type and age. | class Animal: def __init__(self, name, type, age): self.name = name self.type = type self.age = age | |
null | Create a program in Python that takes in a text document and counts the number of times a specific word is used in it. | Text: "This is a test sentence. This sentence is used for testing."
Word: "test" | text = "This is a test sentence. This sentence is used for testing."
word = "test"
def count_words(text, word):
words = text.split()
count = 0
for w in words:
if w == word:
count += 1
return count
print(count_words(text, word)) #2 |
[HI Wikipedia] इन्दौर
इन्दौर भारत के मध्य प्रदेश राज्य का एक महानगर है। जनसंख्या की दृष्टि से यह मध्य प्रदेश का सबसे बड़ा शहर है, २०११ जनगणना, के अनुसार २१,६७,४४७ लोगों की आबादी सिर्फ ५३० वर्ग किलोमीटर के क्षेत्र में वितरित है। यह मध्यप्रदेश में सबसे अधिक घनी आबादी वाला शहर भी है। यह भारत में टीयर-2 शहरों के अन्तर्गत ... | null | null | null |
null | Write Python code to generate a random letter from A to Z. | import random
def generate_random_letter():
alphabet = list(map(chr, range(65, 91)))
random_letter = random.choice(alphabet)
return random_letter
random_letter = generate_random_letter()
print(random_letter) | |
[HI Wikipedia] दक्षिण कीवू प्रान्त
दक्षिण कीवू प्रान्त (फ़्रान्सीसी: Province du Sud-Kivu, अंग्रेज़ी: South Kivu Province) अफ़्रीका के कांगो लोकतान्त्रिक गणराज्य के पूर्वी हिस्से में स्थित एक प्रान्त है। इसका सीमाएँ कीवू झील से सटी हुई हैं और उसी झील पर इसका और इसके उत्तर में स्थित उत्तर कीवू प्रान्त का नाम पड़ा है। य... | null | null | null |
[EN Wikipedia] Once Upon ay Time in Mumbai Dobaara!
Once Upon a Time in Mumbai Dobaara! (; ) is a 2013 Indian Hindi-language gangster film directed by Milan Luthria and produced by Ekta Kapoor and Shobha Kapoor. A sequel to 2010's Once Upon a Time in Mumbaai, the film stars Akshay Kumar, Imran Khan and Sonakshi Sinha,... | null | null | null |
null | Write a recursive python function to generate a Fibonacci sequence up to n number of elements | def fibonacci(n):
if n == 1:
return [1]
elif n == 2:
return [1, 1]
else:
fib_list = fibonacci(n - 1)
fib_list.append(fib_list[-1] + fib_list[-2])
return fib_list | |
null | Create a C++ class called "TV". | class TV { public: TV(); // Constructor void turnOn(); void turnOff(); void switchChannel(); }; | |
null | Design a program in Python that outputs the N-th Fibonacci number. | def nth_fibonacci_number(n):
if n == 0:
return 0
if n == 1:
return 1
a = 0
b = 1
for i in range(2, n+1):
c = a + b
a = b
b = c
return c | |
null | Write a C++ method to calculate the Fibonacci series. | // C++ program to calculate Fibonacci series #include <iostream> // Fibonacci function int Fibonacci(int n) { if (n <= 1) return n; return Fibonacci(n-1) + Fibonacci(n-2); } int main() { int n; std::cout << "Enter the number of terms: "; std::cin >> n; // This loop will print Fibonacci series till n for (int i = 0; i <... | |
null | Generate a multi-line string in Python. | multi_line_str = '''
This is a multi-line string
that spans multiple lines.
''' | |
null | Read the given list and return the last element. | mylist = [1,2,3,4,5] | 5 |
[CS Wikipedia] Římskokatolická farnost Jiřetín pod Jedlovou
Římskokatolická farnost Jiřetín pod Jedlovou je církevní správní jednotka sdružující římské katolíky na území obce Jiřetín pod Jedlovou a v jejím okolí. Organizačně spadá do děčínského vikariátu, který je jedním z 10 vikariátů litoměřické diecéze. Centrem far... | null | null | null |
null | Create a class in Python to represent a student. This class should contain fields for name, age, and a list of subjects taken. | Not applicable | class Student:
def __init__(self, name, age, subjects):
self.name = name
self.age = age
self.subjects = subjects
def getName(self):
return self.name
def getAge(self):
return self.age
def getSubjects(self):
return self.subjects |
null | Write a function in Python that takes a number as input and prints out if the number is odd or even. | Number = 23 | def OddEven(num): if num%2 == 0 : print("{} is Even".format(num)) else : print("{} is Odd".format(num)) OddEven(23) |
null | Create an API route in Python that allows users to retrieve the top 5 most recent posts from a blog. | Blog post data | import datetime
@app.route('/posts')
def get_posts():
posts = Post.query \
.order_by(Post.created_at.desc()) \
.limit(5)
return jsonify([{
'title': post.title,
'date': post.created_at.strftime('%Y-%m-%d'),
'body': post.body
} for post in posts]) |
null | Using the data provided, write a Python program to find and print the root of the quadratic equation ax2 + bx + c = 0 | a = 1, b = 5, c = 6 | import math
a = 1
b = 5
c = 6
# calculate the discriminant
d = (b**2) - (4*a*c)
# find the two solutions
sol1 = (-b-math.sqrt(d))/(2*a)
sol2 = (-b+math.sqrt(d))/(2*a)
print('The solutions are {0} and {1}'.format(sol1, sol2)) |
null | Create a script in Python to convert fahrenheit temperatures to celsius. | def fahren_to_celsius(fahren): celsius = (fahren - 32) * (5 / 9) return celsius print(fahren_to_celsius(50)) # Output: 10.0 | |
null | Construct a Genetic Algorithm in Python to minimize the distance from a given set of points to a given reference point | Points: [(-2, 3), (4, 6), (7, 2)] |Reference Point: (1, 1) | def genetic_algorithm(points, reference_point):
# define the search space
search_space = [np.random.randint(-20, 20) for _ in range(len(points))]
# set the initial minimum distance
min_distance = float("inf")
# execute the genetic algorithm
while True:
# evaluate the search space
... |
null | Write a function to filter a given list such that all any string starting with an 'S' is removed from the list. | ['Swallow', 'Duck', 'Finch', 'Parrot'] | def filter_list(lst): return [elem for elem in lst if not elem.startswith('S')] if __name__ == "__main__": print(filter_list(['Swallow', 'Duck', 'Finch', 'Parrot'])) |
null | Modify the following Python code to reverse the order of the elements in an array | arr = [1, 2, 3, 4, 5] | arr = arr[::-1] # Reverses the order of elements in the array. |
null | Generate a Python code to automatically add an item to the beginning of a given array. | arr = [1,2,3,4,5]
new_item = 7 | def add_item_to_beginning(arr, new_item):
return [new_item] + arr |
null | Generate 10 random numbers between 5 to 10. | import random # Generate 10 random numbers between 5 and 10 random_numbers = [random.randint(5, 10) for _ in range(10)] print("The 10 random numbers are: ", random_numbers) | |
[CS Wikipedia] Hlybokaje
Hlybokaje (, – Glubokoje) je město ve Vitebské oblasti v Bělorusku, správní středisko Hlybockého rajónu. K roku 2017 mělo přes devatenáct tisíc obyvatel. Poloha a doprava Hlybokaje leží na západě Vitebské oblasti a od Vitebsku, jejího správního střediska, je vzdáleno zhruba 200 kilometrů západ... | null | null | null |
null | Design and develop a CRUD API in Python to store user data in a relational database. The API should include endpoints for creating a new user, updating a user, deleting a user, and listing all users. | Not applicable | from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
# configure the database
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db = SQLAlchemy(app)
# create User model
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(50),... |
[DE Wikipedia] Burtonwood and Westbrook
Burtonwood and Westbrook ist eine Gemeinde (civil parish) in der englischen Unitary Authority Warrington in der Region North West England. Im Jahr 2001 zählte sie 11.265 Einwohner. In Burtonwood befand sich bis 1994 ein Luftwaffenstützpunkt der britischen Royal Air Force, der au... | null | null | null |
null | Create a function in Python that adds a new item to the beginning of a list. | my_list = ["Cats", "Dogs", "Fish"] | def insert_beginning(my_list, item): my_list = [item] + my_list return my_list |
null | Develop an algorithm using Python to optimize the following path planning problem: A robot is placed on an 8x8 grid and needs to find the shortest path to get from point A to point B. | The 8x8 grid has obstacles located at (1,1), (3,4), (6,4), (7,7). | import collections
# initialize the queue
Q = collections.deque()
# add point A to the queue
Q.append((0, 0))
# create a list to hold visited points
visited = []
# create the map of the grid
grid = [[0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 0, 0, 0... |
null | Create a CSS class to make a <div> element have a width of 50%, a height of 75px, and a blue background color. | .divStyle { width: 50%; height: 75px; background-color: blue; } | |
null | Generate a Python program to generate a random password that contains 8 characters including at least one number, one letter and one special character. | import string
import random
def generate_password():
letters_and_digits = string.ascii_letters + string.digits
special_chars = "!@#$%^&*"
chars = letters_and_digits + special_chars
password = random.choice(string.ascii_lowercase)
password += random.choice(string.ascii_uppercase)
password += ran... | |
[CS Wikipedia] Valivý pohyb
Valivý pohyb je druh pohybu tělesa kruhového průřezu po podložce, při kterém nedochází ke smyku (smykovému tření) mezi tělesem a podložkou. Těleso kruhového průřezu je např. válec, koule nebo obruč. Valivý pohyb je pohyb složený z posuvného pohybu a otáčivého pohybu a obvodová rychlost bodů... | null | null | null |
null | Create an array of unique values in JavaScript from the given array. | [1, 2, 3, 1, 2] | let array = [1, 2, 3, 1, 2]; let uniqueArray = [...new Set(array)]; console.log(uniqueArray); // [1, 2, 3] |
null | Write a script in JavaScript to print the first 20 Fibonacci numbers. | let n1 = 0; let n2 = 1; let n3; console.log(n1 + " " + n2); for(let i = 2; i < 20; ++i) { n3 = n1 + n2; console.log(n3); n1 = n2; n2 = n3; } | |
[HI Wikipedia] खेल
खेल, कई नियमों एवं रिवाजों द्वारा संचालित होने वाली एक प्रतियोगी गतिविधि है। खेल सामान्य अर्थ में उन गतिविधियों को कहा जाता है, जहाँ प्रतियोगी की शारीरिक क्षमता खेल के परिणाम (जीत या हार) का एकमात्र अथवा प्राथमिक निर्धारक होती है, लेकिन यह शब्द दिमागी खेल (कुछ कार्ड खेलों और बोर्ड खेलों का सामान्य न... | null | null | null |
null | Create a Python program to implement linear search to find a specified item in an array. | Array = [1, 2, 3, 4, 5], search_number = 4 | def linear_search(arr, x):
for i in range(len(arr)):
if arr[i] == x:
return i
return -1
arr = [1, 2, 3, 4, 5]
search_number = 4
result = linear_search(arr, search_number)
if result == -1:
print("Number not found in the array")
else:
print("Number found at index:", result) |
null | Construct a query in SQL to find the names of the customers who made purchase on a given date. | The table name is 'Orders' and the given date is '2020-06-25'. | SELECT customer FROM orders WHERE date = '2020-06-25'; |
[CS Wikipedia] Kostel Zvěstování Panny Marie (Horní Cerekev)
Kostel Zvěstování Panny Marie (někde uváděn také jako Kostel Zvěstování Páně) je farní kostel v římskokatolické farnosti Horní Cerekev, nachází se v centru města Horní Cerekev na křižovatce ulic Březinova, Havlíčkova a náměstí T. G. Masaryka nedaleko zámku H... | null | null | null |
[CS Wikipedia] Kostel svatého Jiljí (Prosiměřice)
Kostel svatého Jiljí je farní kostel v římskokatolické farnosti Prosiměřice, nachází se v centru městyse Prosiměřice. Kostel je dvoulodní stavba s raně gotickým jádrem. Kostel je chráněn jako kulturní památka České republiky. Historie Kostel byl postaven někdy v době p... | null | null | null |
null | Construct a React component to show an animated loading screen. | import React from 'react'; import { Animate } from '../animations'; class LoadingScreen extends React.Component { render() { return ( <div> <Animate type="fadeIn" delay={0.5}> <div>Loading...</div> </Animate> </div> ); } } export default LoadingScreen; | |
null | Create a Python script to print the sum of all numbers divisible by 3 or 7 in a list. | [1, 2, 3, 4, 5, 6, 7, 8, 9 ,10, 11, 12, 13, 14] | nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
total = 0
for num in nums:
if (num % 3 == 0) or (num % 7 == 0):
total += num
print(total) # Output: 42 |
[DE Wikipedia] Dom St. Peter (Osnabrück)
Der römisch-katholische Dom St. Peter (auch Dom St. Petrus) in Osnabrück ist die Kathedrale des Bistums Osnabrück. Der Dom ist ein spätromanisches Bauwerk und prägt seit seiner Entstehung die Silhouette der Stadt. Hauptpatron ist Sankt Peter. Baugeschichte und Ausstattung Bauwe... | null | null | null |
null | Update the following code to fix a syntax error. | def add_two_number(a,b): return a + b; | def add_two_numbers(a, b): return a + b |
[CS Wikipedia] Re d'Italia
Re d'Italia byla pancéřová šroubová fregata I. stupně italského královského námořnictva. Její sesterskou lodí byla fregata Re di Portogallo. Obě lodi postavila americká loděnice W. H. Webb v New Yorku. Pod velením kapitána 1. třídy Faà di Bruno byla nasazena při ostřelování ostrova Vis ve dn... | null | null | null |
null | Debug the code to fix the error. | def hi_it(name): print("Hi," + name) hi_it("John") | def hi_it(name): print("Hi," + str(name)) hi_it("John") |
null | Modify the given Python program so that it checks the spelling of the given word using an external library. | word = "Hello" | import spellchecker
word = "Hello"
correct_word = spellchecker.correction(word)
if word != correct_word:
print("Did you mean", correct_word, "?") |
null | Create a MongoDB query to find all the documents containing the string "Apple" in the field "Company". | db.collection.find({Company: { $regex: /Apple/ }}); | |
[HI Wikipedia] पिपली
पिपली भारत के हरियाणा प्रान्त का शहर है। राष्ट्रीय राजमार्ग 1 पर बसा यह कस्बा कुरुक्षेत्र का द्वार है तथा यहाँ का बस अड्डा कुरुक्षेत्र हाईवे बस अड्डा के नाम से भी जाना जाता है। हरियाणा के शहर कुरुक्षेत्र | null | null | null |
[CS Wikipedia] Preben Elkjær Larsen
Preben Elkjær Larsen (* 11. září 1957) byl dánský fotbalista. Hrával na pozici útočníka. S dánskou fotbalovou reprezentací získal bronzovou medaili na mistrovství Evropy roku 1984 a zúčastnil se i mistrovství světa 1986 (kde se dostal do all-stars a byl vyhlášen 3. nejlepším hráčem ... | null | null | null |
[HI Wikipedia] जाजपुर
जाजपुर (Jajpur) भारत के ओड़िशा राज्य के जाजपुर ज़िले में स्थित एक नगर है। यह उस ज़िले का मुख्यालय भी है। इन्हें भी देखें जाजपुर ज़िला सन्दर्भ जाजपुर ज़िला ओड़िशा के शहर जाजपुर ज़िले के नगर | null | null | null |
null | Create a function that prints a provided message 3 times | message = "Hello World!" | def print_message(message): for i in range(3): print(message) |
null | Given a string “Python Exercises”, write a Python function to convert it into “python exercises”. | def convert_string(input_string):
return input_string.lower() | |
null | How would you find the frequency of each character in a string using JavaScript? | string = "Hello World" | function getCharacterFrequencies(string) { let charMap = {}; for (let char of string) { charMap[char] = charMap[char] + 1 || 1; } return charMap; } |
null | Find the closest number to given value using a binary search algorithm. | arr = [2, 4, 7, 10, 11, 12], val = 6 | closest_num = 7 # 10 is the closest number to 6 in the array |
[HI Wikipedia] लान्तनौमापुक
लान्तनौमापुक (आइसलैण्डी 'Landnámabók' का सही आइसलैण्डी उच्चारण) या लैन्डनामाबोक (अंग्रेज़ी विकृत उच्चारण), जिसे संक्षिप्त रूप से लान्तनौमा (Landnáma) भी कहते हैं, यूरोप के वाइकिंग युग के दौरान 9वीं और 10वीं सदी ईसवी में आइसलैंड में नॉर्स लोगों के आकर बस जाने का ऐतिहासिक वृत्तांत है। यह मध्... | null | null | null |
null | Edit the code so it displays the numbers 1 to 5. | for i in range(2, 10): print(i) | for i in range(1, 6): print(i) |
null | Suggest a suitable algorithm for solving this problem. | An array of integers is given. Find the highest sum that can be obtained by including different members from the array, such that no two members have the same index. | We can use the dynamic programming approach to solve this problem. At each step, we calculate the maximum possible sum that can be obtained if we include the current element. We keep track of the maximum sum found so far, and then continue with the next element. At the end, we have the highest sum of elements with no t... |
[DE Wikipedia] Schwellwerk
Der Begriff Schwellwerk bezeichnet ein Teilwerk einer Orgel, das in seiner Lautstärke durch eine zusätzliche Einrichtung reguliert werden kann. Die Pfeifen dieses Teilwerkes befinden sich in einem geschlossenen Holzkasten, dem Schwellkasten, dessen Vorderseite sich mit Hilfe verschiedener Te... | null | null | null |
null | Build a web application in python to display the current temperature in Fahrenheit. | from flask import Flask, request
from requests import get
app = Flask(__name__)
@app.route('/', methods=['GET'])
def home():
api_key = # API key for open weather API
url = f'http://api.openweathermap.org/data/2.5/weather?q=current&units=imperial&APPID={api_key}'
output = request.get(url).json()
te... | |
null | Develop a Python program that takes a list of words in variable ‘words’ and creates a new variable with the length of each word. | words = ["Hello", "World", "I", "Love", "You"] | word_lengths = [len(word) for word in words]
print(word_lengths) # [5, 5, 1, 4, 3] |
null | Given a sorted list of integers, write a Python function to search for a specific target element. | def binary_search(list, target): low = 0 high = len(list) - 1 while low <= high: mid = (low + high) // 2 if list[mid] < target: low = mid + 1 elif list[mid] > target: high = mid - 1 else: return mid return False | |
[EN Wikipedia] Gmina Sońsk
Gmina Sońsk is a rural gmina (administrative district) in Ciechanów County, Masovian Voivodeship, in east-central Poland. Its seat is the village of Sońsk, which lies approximately south-east of Ciechanów and north of Warsaw. The gmina covers an area of , and as of 2006 its total population ... | null | null | null |
null | Write a SQL query to retrieve all rows from the table 'movies' whose genre is 'comedy' | SELECT * FROM movies WHERE genre = 'comedy'; | |
null | Write a Python program that takes two lists as input and merges the values from both these lists into the third list. | list1 = [1, 2, 3, 4, 5]
list2 = [6, 7, 8, 9, 0] | list3 = []
list3.extend(list1)
list3.extend(list2)
print(list3) |
null | Incorporate the PUT method in the given URL. | URL: https://example.com/users | https://example.com/users/PUT |
null | Write a query in Python to count the total number of times a value appears in a specific column of a table. | Table: "mytable"
Column: "mycolumn"
Value: "myvalue" | SELECT COUNT(mycolumn)
FROM mytable
WHERE mycolumn = 'myvalue' |
[CS Wikipedia] Stupeň B1039 Falconu 9
Stupeň B1039 Falconu 9 je první stupeň rakety Falcon 9 verze Block 4 vyráběné společností SpaceX. Poprvé tento první stupeň letěl v srpnu 2017 při misi CRS-12, kdy po vynesení nákladu úspěšně přistál na pevninské ploše Landing Zone 1. Následně byl stupeň zrenovován a letěl znovu p... | null | null | null |
null | Create a Python program that takes an array with n elements and returns the index of the element which appears the maximum number of times. | n = 8 | def max_frequency_index(lst):
dct = dict()
for i in range(len(lst)):
if lst[i] in dct:
dct[lst[i]] += 1
else:
dct[lst[i]] = 1
max_freq = 0
max_freq_index = 0
for i in dct:
if dct[i] > max_freq:
max_freq = dct[i]
max_fr... |
null | Create a JavaScript script to toggle a class on the page. | <html> <body> <div id="test" class="test-class">Hello World!</div> </body> </html> | <script> //Toggle the class on click document.getElementById("test").addEventListener("click", function(){ this.classList.toggle("test-class"); }); </script> |
[CS Wikipedia] Československo
Československo (v některých obdobích Česko-Slovensko) byl stát ve střední Evropě, který existoval v letech 1918–1992, s výjimkou období druhé světové války (1939–1945), kdy však měl svoji exilovou vládu v zahraničí. Země zahrnovala území Čech, Moravy, českého Slezska, Slovenska a do roku ... | null | null | null |
null | Write a SQL query to get all the users who have registered in the last 7 days. | SELECT * FROM Users WHERE registration_date > DATE_SUB(CURDATE(), INTERVAL 7 DAY); | |
[EN Wikipedia] Liudvikas Strolis
Liudvikas Strolis (1905–1996) is a Lithuanian ceramist. See also List of Lithuanian artists References 1905 births 1996 deaths 20th-century Lithuanian artists Soviet artists | null | null | null |
null | Create an HTML layout for a website. Make sure the layout has a header, a navigation menu, and a footer. | <!DOCTYPE html> <html> <head> <title>Webpage Layout</title> </head> <body> <header> <h1>Header</h1> </header> <nav> <ul> <li>Home</li> <li>About</li> <li>Contact</li> <li>FAQ</li> </ul> </nav> <footer> <p>Footer</p> </footer> </body> </html> | |
null | Create a sorting algorithm for an array that only needs 1 iteration | def one_iteration_sort(arr): for i in range(len(arr)): min_index = i for j in range(i, len(arr)): if arr[j] < arr[min_index]: min_index = j arr[i], arr[min_index] = arr[min_index], arr[i] | |
[DE Wikipedia] (4092) Tyr
(4092) Tyr ist ein Hauptgürtelasteroid, der am 8. Oktober 1982 von dem dänischen Astronomen Poul Jensen vom Brorfelde-Observatorium aus entdeckt wurde. Der Asteroid wurde nach Tyr benannt, dem Gott des Kampfes und Sieges in den altisländischen Schriften der Edda. Weblinks Hauptgürtelasteroid ... | null | null | null |
null | Create a function in Python for replacing a substring with another substring | String: "Hello world!"
Substring to replace: "world"
Substring to replace with: "universe" | def replace_substring(string, old, new):
new_string = ""
for word in string.split():
if word == old:
new_string += new + " "
else:
new_string += word + " "
return new_string.rstrip()
string = "Hello world!"
new_string = replace_substring(string, "world", "universe")
... |
null | Generate a function in Python to compute the area of a rectangle. | def area_rectangle(length, breadth): return length * breadth | |
null | Construct a Python script to normalize a given vector. | [2, 3, 4] | def normalize_vector(v):
norm = 0
for x in v:
norm += x**2
norm = norm**0.5
for i in range(len(v)):
v[i] = v[i] / norm
return v
result = normalize_vector([2, 3, 4])
print(result) # [0.37139068, 0.55708601, 0.74278135] |
null | Are string and array objects mutable or immutable in JavaScript? | In JavaScript, strings and arrays are both mutable objects. This means that these objects can be changed after they have been created, and can be modified in place. Other primitive data types, such as numbers and booleans, are immutable and cannot be changed after they have been created. | |
null | Construct a query in MongoDB to select documents with a value greater than 3 for the property "value". | db.collection.find( { value: { $gt: 3 } } ) | |
null | Generate a Python program to find the closest pair of points in a two-dimensional plane. | import math
# List of points
points = [[2, 3], [12, 30], [40, 50], [5, 1], [12, 10], [3, 4]]
# Initialize variables
min_distance = float('inf')
closest_pair = ()
# Loop through points
for i in range(len(points)):
for j in range(i+1, len(points)):
# calculate the distance
distance = math.sqrt((po... | |
null | Find the closest decimal approximation of 0.875. | 0.88 | |
null | Design a solution in JavaScript to find the kth smallest element in an unsorted array. | arr = [8, 5, 7, 2, 3, 1, 9, 4] k = 3 | function kthSmallest(arr, k) { // Sort the array arr.sort((a, b) => a - b); // Return kth element in the sorted array return arr[k - 1]; } |
null | Write code to calculate the mean of two numbers | numbers = [4, 6] | def mean(numbers): """Calculate the mean of two numbers""" return sum(numbers) / len(numbers) |
null | Implement a method that reverses a linked list | head = 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> null | // A linked list node class Node: # Constructor to create a new node def __init__(self, data): self.data = data self.next = None # Function to reverse the linked list def reverse(head): prev = None current = head while(current is not None): next = current.next current.next = prev prev = current current = next head = pr... |
null | Write a Python program to implement a text-based game | import random def intro(): print("Welcome to the game! You are stuck in a dungeon and must find a way out. Type 'help' for instructions.") def help_command(): print("Type 'north', 'south', 'west', or 'east' to move in that direction. Type 'check inventory' to view items in your inventory. Type 'quit' to quit.") def mov... | |
[EN Wikipedia] 1924 United States presidential election in Indiana
The 1924 United States presidential election in Indiana took place on November 4, 1924, as part of the 1924 United States presidential election which was held throughout all contemporary 48 states. Voters chose 15 representatives, or electors to the El... | null | null | null |
null | Output the string "Programming is Fun" when you run the code? | print('Programming is Fun') | |
null | Find the lowest common multiple of two numbers a and b. | a = 12, b = 15 | def lcm(a, b): lcm_num = (a * b) // math.gcd(a, b) return lcm_num lcm(12, 15) # 60 |
null | Construct a class in Python named "Person" which stores first name and last name in instance variables | class Person: def __init__(self, first_name, last_name): self.first_name = first_name self.last_name = last_name | |
null | Find the sum of all odd numbers between 1-100. | The sum of all odd numbers between 1-100 is 2500. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.