text stringlengths 141 2.89k ⌀ | instruction stringlengths 19 1.5k ⌀ | input stringlengths 0 800 ⌀ | output stringlengths 1 2.5k ⌀ |
|---|---|---|---|
null | Write a function that takes a sentence and returns the string with all occurrences of the longest word removed. | "This is a very long sentence" | def remove_longest_word(sentence): # Split the sentence into words words = sentence.split(' ') # Find the longest word longest_word = "" for word in words: if len(word) > len(longest_word): longest_word = word # Remove all occurrences of the longest word new_sentence = [] for word in words: if word != longest_word: new... |
[HI Wikipedia] चन्द्रशेखर कम्बार
चंद्रशेखर कंबार (; जन्म : २ जनवरी १९३७) एक कन्नड़ भाषा के कवि, नाटककार एवं लोकसाहित्यकार हैं। उन्होंने कन्नड़ भाषा में फिल्मों का निर्देशन भी किया है और वे हम्पी में कन्नड़ विश्वविद्यालय के संस्थापक कुलपति भी रहे हैं। उनके उल्लेखनीय साहित्यिक योगदान के आलोक में उन्हें 2010 के लिए ज्ञान... | null | null | null |
null | Write a SQL query to return the ranking of the employees with highest salary. | SELECT * FROM Employees ORDER BY Salary DESC | SELECT e.*, RANK() OVER (ORDER BY Salary DESC) AS Rank FROM Employees e |
[DE Wikipedia] Pauly Shore
Paul Montgomery „Pauly“ Shore (* 1. Februar 1968 in Los Angeles) ist ein US-amerikanischer Komödiant und Schauspieler. Leben Pauly Shore ist der Sohn von Sam und Mitzi Shore, den Gründern des Comedy-Clubs The Comedy Store. Geboren in Hollywood, wuchs er in Beverly Hills auf. 1986 schloss er ... | null | null | null |
null | Add code to this function to return the square of the input number. | def square_number(number): 1 | def square_number(number): return number*number |
[DE Wikipedia] Palast von Panah Ali Khan
Der Palast von Panah Ali Khan (aserbaidschanisch Pənahəli Xanın sarayı) war die Privatresidenz von Pənahəli Xan, dem Gründer des Khanats Karabach (1747–1806), in der aserbaidschanischen Stadt Ağdam. In unmittelbarer Nähe des Palastes befindet sich der Imarət-Friedhof, ein adeli... | null | null | null |
null | Write a Python program to display the multiplication table of a given number. | def multiplication_table(n):
print('Multiplication Table of ', n)
for i in range(1, 11):
product = i * n
print('{0} x {1} = {2}'.format(i, n, product)) | |
null | Create a bash script that creates three TextFiles named first.txt, second.txt, and third.txt each having 10 lines of text. | #!/bin/bash for file in {first,second,third}.txt; do touch $file for i in {1..10}; do echo "This is line $i in the file $file" >> $file done done | |
null | Create a function in Python that will print out a random word from a given list. | words_list = ['cat', 'dog', 'ball', 'toy'] | import random def random_word(words_list): word = random.choice(words_list) print(word) random_word(words_list) |
null | Construct a class in Python to represent a point in Cartesian coordinates. | class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def distance_from_origin(self):
return (self.x ** 2 + self.y ** 2) ** 0.5
p = Point(3, 4)
print(p.distance_from_origin()) | |
[EN Wikipedia] Utakura River
The Utakura River is a river of the Northland Region of New Zealand's North Island. It flows west from its sources northwest of Kaikohe, reaching the Waihou River at the point where it widens to become an arm of the Hokianga Harbour. Long and short-fin eels, smelt, īnanga, torrentfish and ... | null | null | null |
null | Compute the sum of the squares of all the numbers between 1 and 10 (inclusively). | 385 | |
[EN Wikipedia] Nonprofit and Voluntary Sector Quarterly
Nonprofit and Voluntary Sector Quarterly is a peer-reviewed academic journal that covers research on the nonprofit and voluntary sector. The journal's editors are Joanne Carman (University of North Carolina at Charlotte) and Jaclyn Piatak (University of North Car... | null | null | null |
null | Construct a function in Python to calculate the area of a triangle with three sides | side1: 3
side2: 4
side3: 5 | def triangleArea(side1, side2, side3):
s = (side1 + side2 + side3) / 2
area = (s * (s - side1) * (s - side2) * (s - side3)) ** 0.5
return area |
null | Create a function in Python that takes in a string and returns true if all characters in the string are unique and false if there is at least one repeated character. | def check_unique(s):
seen=set()
for c in s:
if c in seen:
return False
else:
seen.add(c)
return True | |
[HI Wikipedia] बलूचिस्तान (पाकिस्तान)
बलूचिस्तान (उर्दू: بلوچستان , बलोची: بلۏچستان) पाकिस्तान का पश्चिमी प्रान्त है। बलूचिस्तान नाम का क्षेत्र बड़ा है और यह ईरान (सिस्तान व बलूचिस्तान प्रान्त) तथा अफ़गानिस्तान के सटे हुए क्षेत्रों में बँटा हुआ है। यहाँ की राजधानी क्वेटा है। यहाँ के लोगों की प्रमुख भाषा बलूच या बलूची... | null | null | null |
null | Find a way to get the size of a linked list without traversing it. | head: 1 -> 2 -> 3 -> 4 -> 5 -> null | def get_list_size(head): count = 0 temp = head while(temp): count += 1 temp = temp.next return count |
null | Create a dictionary and assign four key-value pairs. | my_dict = {'apple': 'fruit', 'carrot': 'vegetable', 'house': 'structure', 'dog': 'animal'} | |
null | Generate
a python program that calculates the total cost of all items in a given list | [("apple", 5, 50),("mango",6,70)] | def total_cost(items):
total_cost = 0
for item in items:
quantity = item[1]
unit_price = item[2]
total_cost += quantity * unit_price
return total_cost |
null | Write an Objective-C statement to create an empty array to hold names. | NSMutableArray *names = [NSMutableArray array]; | |
[HI Wikipedia] सिन्धु नदी
सिन्धु नदी एशिया की सबसे लंबी नदियों में से एक है। यह पाकिस्तान, भारत (जम्मू और कश्मीर) और चीन (पश्चिमी तिब्बत) के माध्यम से बहती है। सिन्धु नदी का उद्गम स्थल, तिब्बत के मानसरोवर के निकट सिन-का-बाब नामक जलधारा माना जाता है। इस नदी की लंबाई प्रायः ३६१० किलोमीटर है। यहां से यह नदी तिब्बत और कश्... | null | null | null |
null | Compute the sum of list integers using Python. | Target list: [3, 5, 7, 9] | mylist = [3, 5, 7, 9]
total = 0
for item in mylist:
total = total + item
print("The sum of list items is:", total) |
null | Modify the following code to print out all even numbers in the list. | lst = [1, 2, 3, 4, 5] | for i in lst: if i % 2 == 0: print(i) |
null | Create a SQL query to retrieve the names and birthdates of all employees in a table called "employees". | SELECT name, birthdate FROM employees; | |
null | What is the proper way to check if a variable of type String is empty in Bash? | if [ -z "$var" ]; then echo "The variable is empty." fi | |
null | Generate code to optimize a matrix multiplication in Python. | A 3x3 matrix | # import numpy
import numpy as np
# Declare matrix A and B
A = np. array([[2, 3, 5], [5, 7, 2], [4, 2, 6]])
B = np.array([[6, 2, 1], [3, 4, 5], [5, 3, 7]])
# use numpy for matrix multiplication
C = np.dot(A, B)
# Vectorization
D = np.zeros((3,3))
for i in range(3):
for j in range(3):
for k in range(3):
D[i,j] +... |
null | Design a program in Python to find the greatest of three numbers. | 25, 39, 12 | def greatest_num(num1, num2, num3):
greatest = 0
if num1 > num2 and num1 > num3:
greatest = num1
elif num2 > num1 and num2 > num3:
greatest = num2
else:
greatest = num3
print("The greatest of the three numbers is:", greatest)
# Here we call the function with the three nu... |
null | Display the results from a MySQL query in HTML table format. | MySQL query: SELECT * FROM employees WHERE name LIKE '%john%' | <?php $query = "SELECT * FROM employees WHERE name LIKE '%john%'"; $result = mysqli_query($conn, $query); echo "<table>"; echo "<tr><th>ID</th><th>Name</th><th>Age</th></tr>"; while ($row = mysqli_fetch_assoc($result)) { echo "<tr><td>".$row['id']."</td><td>".$row['name']."</td><td>".$row['age']."</td></tr>"; } echo "<... |
[DE Wikipedia] Bahnstrecke Skalsko–Stará Paka
|} Die Bahnstrecke Skalsko–Stará Paka ist eine regionale Eisenbahnverbindung in Tschechien, die ursprünglich von der Lokalbahn Sudoměř-Skalsko–Alt Paka (tschech.: Místní dráha Sudoměř-Skalsko–Stará Paka) als landesgarantierte Lokalbahn erbaut wurde. Sie zweigt in Skalsko v... | null | null | null |
null | Write a Python program to predict the future stock price of a company. | Predict the stock price of Apple in 2021. | import pandas as pd
# Read the data
data = pd.read_csv("apple stock data.csv")
# Extract the data points
X = data[['open', 'high', 'low', 'volume']]
y = data['close']
# Fit the model
model.fit(X, y)
# Predict the stock price of Apple in 2021
predict = model.predict([[Apple_open, Apple_high, Apple_low, Apple_volume... |
null | Write a JavaScript function that swaps the values of two variables. | function swap(a, b) { let temp = a; a = b; b = temp; } | |
null | Write an HTML link tag to open a link in a new tab. | <a href="http://example.com" target="_blank">Link</a> | |
null | Output the following array in a column | [1, 2, 3, 4] | for x in [1,2,3,4]: print(x) # Output: 1 2 3 4 |
null | Write a Perl script to output the 8th character in a given string. | String = "SoftwareTestingHelp" | $str = "SoftwareTestingHelp"; print substr($str, 8, 1); |
null | Write a sql query to fetch records from a table with a condition that must provide results with an id greater than 10. | SELECT * FROM table WHERE id > 10; | |
null | Write a prompt message that asks the user to enter their name. | Please enter your name: | |
null | Create a cryptography program that computes the factorial of a given number. | num = 5 | def factorial(n): if n == 0: return 1 return n * factorial(n-1) if __name__ == '__main__': num = 5 result = factorial(num) print(result) |
[CS Wikipedia] Marek Brodský
Marek Brodský (* 19. května 1959 Praha) je český hudebník, textař, výtvarník, publicista a herec, syn herce Vlastimila Brodského, též poloviční bratr herečky Terezy Brodské. V roce 1983 spoluzaložil hudební skupinu Nahoru po schodišti dolů band, jejímž vedoucím, bubeníkem a hlavním textaře... | null | null | null |
[EN Wikipedia] IRobot R-Gator
The iRobot R-Gator is an unmanned robotic platform from iRobot Corporation and John Deere. The robot is built upon Deere's M-Gator currently in use by the US Military. The R-Gator can operate autonomously, performing perimeter patrol and other missions while keeping personnel out of harm'... | null | null | null |
[HI Wikipedia] तंज़ानिया
तंजानिया का संयुक्त गणराज्य (स्वाहिली: Jamhuri ya Muungano wa Tanzania), अफ्रीका महाद्वीप के पूर्वी भाग में स्थित एक देश है, जिसकी सीमायें, उत्तर में कीनिया और युगांडा, पश्चिम में रवांडा, बुरुंडी और कांगो, दक्षिण में ज़ाम्बिया, मलावी और मोजाम्बिक से मिलती हैं, तथा देश की पूर्वी सीमा हिंद महासा... | null | null | null |
null | Write a Java code to generate a Fibonacci number at a given index. | public class Fibonacci { public static int getFibonacciNumber(int index) { // base cases if (index == 0) { return 0; } if (index == 1 || index == 2) { return 1; } // recursive case return getFibonacciNumber(index - 1) + getFibonacciNumber(index - 2); } } | |
null | Sort a given list using bubble sort in Python. | list = [3,5,2,4,7,5] | def bubble_sort(list):
for i in range(len(list)):
for j in range(len(list)-1):
if list[j]>list[j+1]:
list[j],list[j+1] = list[j+1],list[j]
return list
if __name__ == '__main__':
list = [3,5,2,4,7,5]
print(bubble_sort(list)) |
null | Describe the difference between a loop and a conditional statement. | A loop is a set of instructions that is execute repeatedly until a certain condition is met. A conditional statement is an instruction that is used to check a condition, and if the condition is true, it will execute certain code. Loops can be used to execute a block of code multiple times, while a conditional statement... | |
[EN Wikipedia] Punakitere River
The Punakitere River is a river of the Northland Region of New Zealand's North Island. It is a tributary of the Waima River, though it is longer than the Waima itself. The Punakitere has its origins in several streams which flowe through and to the south of Kaikohe, and flows predominan... | null | null | null |
null | Write a code in Python to parse a JSON string. | {
"name": "James",
"age": 27
} | import json
json_string = '{"name": "James","age": 27}'
data = json.loads(json_string)
print(data["name"], data["age"]) |
null | Write a python program that implements the following function: | Given two sorted lists, return a merged sorted list. | def merge_sorted_lists(list1, list2):
merged_list = []
while list1 and list2:
if list1[0] < list2[0]:
merged_list.append(list1.pop(0))
else:
merged_list.append(list2.pop(0))
merged_list += list1 + list2
return merged_list |
[CS Wikipedia] Harmonia confessionum fidei
Harmonia confessionum fidei (Souzvuk vyznání víry) je teologický spis z roku 1581, který vznikl v reformovaném prostředí a byl vydán tiskem v Ženevě. Představuje jeden z prvních pokusů o komparativní symboliku. Kniha formuluje deset základních věroučných otázek, k nimž přináš... | null | null | null |
[DE Wikipedia] Pierre d’Estaing
Pierre d’Estaing, auch d’Estaing OSB (* 1320 in Estaing; † 18. oder 25. November 1377 in Rom) war ein französischer Benediktiner, Bischof und Kardinal. Leben D’Estaing wurde 1320 auf dem Familienschloss als viertes der neun Kinder von Guillaume III. d’Estaing und dessen Ehefrau Esmengar... | null | null | null |
null | Generate an optimized python program to calculate the sum of all digits in a given positive integer number. | 123456 | input_number = 123456
def find_sum_of_digits(number):
n = number
sum = 0
while n > 0:
sum += n % 10
n //= 10
return sum
sum_of_digits = find_sum_of_digits(input_number)
print("Sum of all digits in {} is {}." .format(input_number,sum_of_digits)) |
null | Create an algorithm in Python that finds the longest consecutive subarray within a given array. | array = [1, 2, 3, 4, 5, 6, 7] | def longest_consecutive_subarray(array):
longest_length = 0
current_length = 0
Hash = {}
for val in array:
if val not in Hash:
Hash[val] = 1
current_length += 1
if current_length > longest_length:
longest_length = current_... |
null | Compare and contrast Java and Python for developing applications. | Java and Python are both popular programming languages used for developing applications. Java is a statically typed language and requires extra effort in the form of type checking during compilation, while Python is a dynamically typed language and no type checking is required. Java is more suitable for large-scale ent... | |
null | Design a function in Python to find the minimum of three numbers. | 2, -6, 4 | def find_min(a, b, c):
if a<b and a<c:
return a
elif b<a and b<c:
return b
else:
return c
min = find_min(2, -6, 4)
print(min) |
null | Write a Python function to dynamically generate HTML content from a JSON object. The HTML content should have an appropriate structure and classes that correspond to the data. | data = { 'title': 'My Title', 'content': 'My Content' } | def generate_html(data):
header = '<h1 class="title">{title}</h1>'.format(title=data.get('title'))
content = '<p class="content">{content}</p>'.format(content=data.get('content'))
html = '<div class="container">{header}{content}</div>'.format(header=header, content=content)
return html |
[DE Wikipedia] Jakob Bleyer
Jakob Bleyer (* 25. Januar 1874 in Tscheb/Dunacséb, Königreich Ungarn, Österreich-Ungarn (heute Čelarevo, Serbien); † 5. Dezember 1933 in Budapest) war ein ungarischer Germanist, Literaturwissenschaftler und Abgeordneter ungarndeutscher Herkunft und in den Jahren 1919 bis 1920 ungarischer M... | null | null | null |
[EN Wikipedia] Lina (surname)
Lina is a surname. Notable people with the surname include: Dace Lina (born 1981), Latvian marathon runner Joey Lina (born 1951), Filipino lawyer, businessman, and politician Méddy Lina (born 1986), Guadeloupean footballer Ria Lina (born 1989), British comedian, actress, and writer | null | null | null |
null | Create a class called Person with two variables, name and age, and two methods, getName() and setAge(). | class Person: def __init__(self, name, age): self.name = name self.age = age def getName(self): return self.name def setAge(self, age): self.age = age | |
null | Write a Python code snippet to generate a list of the first five powers of the number 2. | [2**0, 2**1, 2**2, 2**3, 2**4] | |
null | Create a Python program which reads a list of numbers and stores them in an array. | [1, 2, 3, 4, 5] | my_list = [1, 2, 3, 4, 5]
my_array = []
for number in my_list:
my_array.append(number)
print(my_array) |
null | Create a query that displays the employees who are completed more than 20 years in the company. | SELECT * FROM employees WHERE years_in_company > 20; | |
null | Create a GUI application in C# that displays a welcome message when the program is launched. | using System.Windows.Forms; public static class Program { static void Main() { Application.EnableVisualStyles(); Application.Run(new Form1()); } } public class Form1 : Form { public Form1() { MessageBox.Show("Welcome!"); } } | |
null | Output an array of even numbers from 0 to 20 using a for loop in Python. | even_nums = [] for num in range(0, 21): if num % 2 == 0: even_nums.append(num) print(even_nums) | |
null | Identify an ideal algorithm to find the longest palindrome in a given string. | The Manacher’s Algorithm is an ideal algorithm to find the longest palindrome in a given string. This algorithm utilizes dynamic programming to find the longest palindrome in linear time complexity by iterating through the string and checking whether a substring is a palindrome or not. | |
null | Create a Javascript function that will loop through an array and push each item into a new array. | function loopThroughArray(arr) { let newArr = []; for(let i = 0; i < arr.length; i++) { newArr.push(arr[i]); } return newArr; } | |
[DE Wikipedia] Reichenbach
Reichenbach steht für: Reichenbach (Familienname) – zu Namensträgern siehe dort Reichenbach (Mondkrater) Reichenbach-Werkstätte in München, siehe Mathematisch-Feinmechanisches Institut Porzellanmanufaktur Reichenbach in Reichenbach (Thüringen) Reichenbach ist der Name folgender geographische... | null | null | null |
null | Write a SQL query to list the names and salaries of the employees who work in the finance department | SELECT name, salary FROM employee WHERE department = 'finance'; | |
null | Create a SQL query to find the first name, last name, and the total number of orders placed for all customers, sorted by Number of orders in descending order. | SELECT c.first_name, c.last_name, COUNT(o.customer_id) as num_orders FROM customers c JOIN orders o WHERE c.id = o.customer_id GROUP BY c.id ORDER BY num_orders DESC; | |
null | Create a basic UI in HTML/CSS for a shopping cart website. | <!DOCTYPE html> <html> <head> <title>Shopping Cart</title> <style> body { margin: 0px; } #container { width: 100%; height: 100%; display: flex; flex-direction: column; } #header { height: 100px; background-color: #eee; display: flex; align-items: center; justify-content: center; } #content { flex: 1; background-color: ... | |
null | Create an array of the numbers from 1 to 10. | let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | |
[EN Wikipedia] NCIS (soundtrack)
NCIS: The Official TV Soundtrack is a series of soundtrack albums featuring music used in the CBS television series NCIS. The first volume in the series, released on February 10, 2009, received attention for its method of compiling music for the album; show producers and writers were p... | null | null | null |
[CS Wikipedia] Shazad Latif
Shazad Latif (* 3. července 1988 Londýn) je britský herec. Je pákistánsko-anglicko-skotského původu. V letech 2009–2011 hrál v televizním seriálu MI5, mezi lety 2013 a 2015 působil v seriálu Toast of London. Ve filmu debutoval v roce 2015 ve snímku Muž, který poznal nekonečno. Roku 2016 se ... | null | null | null |
null | Create an array containing the alphabet in lowercase in Python. | Using the string.ascii_lowercase constant, an array containing the alphabet in lowercase can be created. Example: import string alphabet_array = list(string.ascii_lowercase) print("Array containing the alphabet in lowercase:", alphabet_array) # Output: Array containing the alphabet in lowercase: ['a', 'b', 'c', 'd', 'e... | |
null | Using a while loop, write a Python program to reverse a given sentence. | "Hello there my friend" | # Initialize an empty string
revString = ""
# Set 'idx' to point to the end of the string
idx = len(sent) - 1
# Iterate in reverse through the string
while idx >= 0:
# Append each individual character to the result string
revString += sent[idx]
# Decrement the index
idx -= 1
# Output the reversed... |
[HI Wikipedia] ब्रिटेन
ब्रिटेन शब्द का प्रयोग हालाँकि आम तौर पर हिंदी में यूनाइटेड किंगडम देश का बोध करने के लिए होता है, परंतु इसका उपयोग अन्य सन्दर्भों के लिए भी हो सकता है: ग्रेट ब्रिटेन और आयरलैंड का यूनाइटेड किंगडम, अथवा यूनाइटेड किंगडम: जोकि इंग्लैंड, स्कॉटलैंड, वेल्स और उत्तरी आयरलैंड जैसे देशों का एक बहुराष्ट्... | null | null | null |
null | Inside a Python program, how would you convert a float number to a string? | str_number = str(float_number) | |
null | Write a Java code snippet for creating an array with 10 random numbers between 1 and 50. | int[] randNums = new int[10]; Random rand = new Random(); for(int i = 0; i < randNums.length; i++) { randNums[i] = rand.nextInt(50) + 1; } | |
null | Modify the following HTML to create a link that opens in a new window. | <a href="www.example.com">Example Link</a> | <a href="www.example.com" target="_blank">Example Link</a> |
null | Write a Python function that takes string input of two sentences and returns a boolean value if the sentences are anagrams or not. | sent1 = "tabe";
sent2 = "beat" | def is_anagram(sent1, sent2):
sent1 = sent1.replace(" ", "").lower()
sent2 = sent2.replace(" ", "").lower()
if len(sent1) != len(sent2):
return False
counter = {}
for letter in sent1:
if letter in counter:
counter[letter] += 1
else:
counter[letter] ... |
[EN Wikipedia] 1959–60 Norwegian 1. Divisjon season
The 1959–60 Norwegian 1. Divisjon season was the 21st season of ice hockey in Norway. Eight teams participated in the league, and Valerenga Ishockey won the championship. First round Second round Final round Relegation round External links Norwegian Ice Hockey Federa... | null | null | null |
[CS Wikipedia] Henri Vallienne
Henri Vallienne (19. listopadu 1854 – 1. prosince 1908) byl francouzský lékař, esperantista. Dílo Původní tvorba KASTELO DE PRELONGO - rozsáhlý původní román, plný dobrodružství, záhad, intrik a justičních omylů ĈU LI - román, stylově revidován K. Kalocsayem Překlady do esperanta Manon L... | null | null | null |
null | Compose a Python program for finding the median value of an unsorted array. | [4, 5, 6, 7, 8, 1, 2] | def median(arr):
# Sort the array
arr.sort()
# Calculate length
n = len(arr)
# Check if n is even
if n % 2 == 0:
median1 = arr[n // 2]
median2 = arr[n // 2 - 1]
median = (median1 + median2) / 2
else:
median = arr[n // 2]
return median
arr = [4, 5, 6, 7... |
[DE Wikipedia] Rotachtal Bodensee
Das Gebiet Rotachtal Bodensee ist ein durch das Regierungspräsidium Tübingen nach der Richtlinie 92/43/EWG (Fauna-Flora-Habitat-Richtlinie) ausgewiesenes Schutzgebiet (SG-Nummer DE-8222342) im Südosten des deutschen Bundeslandes Baden-Württemberg. Lage Das rund 466 Hektar (ha) große S... | null | null | null |
null | Write a Ruby program to search for a specific item in an array of strings. | array = ["Apple","Banana","Mango","Orange"] | def search_array(array, item) return array.include?(item) end puts search_array(array, "Mango") #true |
null | Create a React component for a navigation bar with a logo and two menu items named "Home" and "About". | import React from 'react'; const Navbar = () => { return ( <nav> <div className="logo"> Logo </div> <ul> <li>Home</li> <li>About</li> </ul> </nav> ) } export default Navbar; | |
null | Generate a Python program to compare two strings and return the largest string. | def largest_string(str1, str2):
if len(str1) >= len(str2):
return str1
else:
return str2 | |
[HI Wikipedia] कश्मीरी
कश्मीरी का अर्थ हो सकता हैः कश्मीरी भाषा जो कि भारत और पाकिस्तान की एक प्रमुख भाषा है। कश्मीरी लोग यानि भारतीय उपमहाद्वीप के जम्मू कश्मीर राज्य के रहवासी | null | null | null |
null | Design the code for a Python program that takes a sentence as input and returns the longest word from the sentence. | The quick brown fox jumps over the lazy dog. | def longest_word(sentence):
words = sentence.split()
max_len = len(words[0])
longest_word = words[0]
for word in words[1:]:
if len(word) > max_len:
max_len = len(word)
longest_word = word
return longest_word
result = longest_word("The quick brown fox jumps over the l... |
null | Edit the code to create a program to print all the leap years between 1900 and 2000. | for year in range(1900, 2001): # TODO | for year in range(1900, 2001): if year % 4 == 0 and year % 100 != 0 or year % 400 == 0: print(year) |
[DE Wikipedia] Kurt Weidner (Schauspieler)
Kurt Weidner (* 21. Februar 1907 in Oberhof, Thüringen, Deutsches Reich; † nach 1978) war ein deutscher Tänzer und Schauspieler bei Bühne und Fernsehen. Leben Weidner erhielt eine Ausbildung zum Tänzer und Schauspieler und begann seine Laufbahn 1931 als Balletttänzer in Gotha... | null | null | null |
null | Create a Java program that print the Fibonacci sequence in the given range. | min = 0, max = 10 | public class Fibonacci { public static void main(String[] args) { int min = 0, max = 10; int prev = 0, next = 1; System.out.print("Fibonacci Sequence in the given range:"); for (int i = 0; i <= max; i++) { if (i >= min) { System.out.print(" " + prev); } int sum = prev + next; prev = next; next = sum; } } } |
null | Create a function in JavaScript that removes all vowels from a string. | function removeVowels(str) { let result = ""; for (let i = 0; i < str.length; i++) { if ((str[i] !== 'a') && (str[i] !== 'e') && (str[i] !== 'i') && (str[i] !== 'o') && (str[i] !== 'u')) { result += str[i]; } } return result; } | |
null | Create a coding program that sorts a given list of numbers into ascending order. | [4, 3, 2, 5, 9, 1, 8] | def ascending_order(arr): # Bubble sort algorithm. 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 element if arr[j] > arr[j+1] : arr[j], arr... |
null | Generate a Python script that will extract all URLs from the given text. | The websites I like to visit are https://www.google.com and https://www.facebook.com | import re
text = "The websites I like to visit are https://www.google.com and https://www.facebook.com"
url_list = re.findall(r'(https?://\S+)', text)
print(url_list) |
null | Write a method in Python to print each element in a given dictionary. | {
"Alice": 23,
"Bob": 30,
"John": 27
} | def printDict(dictionary):
for key in dictionary:
print("{}: {}".format(key, dictionary[key]))
dict = {
"Alice": 23,
"Bob": 30,
"John": 27
}
printDict(dict) |
null | Write an algorithm that sorts the following list of integers in ascending order | [15, 5, 8, 0, 42] | def sort_list(lst): for i in range(len(lst)): for j in range(i+1, len(lst)): if lst[i] > lst[j]: lst[i], lst[j] = lst[j], lst[i] return lst |
[CS Wikipedia] Nanuk (mytologie)
Nanuk, též Nanuq (grónsky též Nanoq) je postava z inuitské mytologie (Inuité). Výraz znamená v inuitštině medvěd. V mytologii představuje pána medvědů, který rozhoduje o tom, zda lovci činili dle všech aplikovatelných tabu, a zda si zaslouží úspěch při lovu medvědů. Odkazy Reference So... | null | null | null |
null | In Python, parse a JSON string and return the value associated with a particular key | JSON String: { "key1": "value1", "key2": "value2" }
Key: "key2" | import json
# Create a json object from the string
json_obj = json.loads('{"key1": "value1", "key2": "value2"}')
#get the value for a particular key
value = json_obj["key2"] |
[CS Wikipedia] Áron Bulharský
Áron Bulharský (, zemřel 14. června 976) byl bulharský šlechtic v desátém století našeho letopočtu, jeden z komitopulů, čtyř bratrů, kteří společně vládli Bulharské říši a bojovali s Byzantskou říší. Byl třetím synem Nikoly, významného šlechtice z dvora bulharského cara Petra I. a správce... | null | null | null |
null | Using the input string, create a new string that contains all the characters in even indices. | my_string = "abcdefghi" | # Create an empty string new_string = "" # Iterate over the even indices for i in range(0, len(my_string), 2): new_string += my_string[i] # Print the new string print(new_string) # prints 'acegi' |
null | Write a C++ program to separate digits and characters from a string | Input string: ab123cde | #include <iostream> using namespace std; int main() { string str = "ab123cde"; string digit; string alpha; for (int i = 0; i < str.length(); i++) { if (isdigit(str[i])) { digit.push_back(str[i]); } else { alpha.push_back(str[i]); } } cout << digit << endl; cout << alpha << endl; return 0; } |
null | Create a Python script that parses a JSON string and complete the following tasks: (1) convert the string to an object, (2) sort the object by keys, and (3) print the object in a formatted way. | {"a": 3, "b": 1, "c": 2} | import json
# Convert the string to an object
data = json.loads('{"a": 3, "b": 1, "c": 2}')
# Sort the object by keys
sorted_data = {k: data[k] for k in sorted(data.keys())}
# Print the object in a formatted way
print(json.dumps(sorted_data, indent=4)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.