text
stringlengths
141
2.89k
⌀
instruction
stringlengths
19
1.5k
⌀
input
stringlengths
0
800
⌀
output
stringlengths
1
2.5k
⌀
null
Generate a Python script to detect if a linked list contains a loop
def contains_loop(head): slow_pointer = head fast_pointer = head while slow_pointer and fast_pointer and fast_pointer.next: slow_pointer = slow_pointer.next fast_pointer = fast_pointer.next.next if slow_pointer == fast_pointer: return True return False
null
Construct a Python program to sort a list of strings by their length in ascending order.
def sort_by_length(string_list): return sorted(string_list, key=len)
[DE Wikipedia] Les Collières Les Collières, im Oberlauf Torrent de Combet, im Unterlauf Les Claires, ist ein kleiner Nebenfluss der Rhône von 21,7 km Länge im französischen Département Drôme. Zwei Kilometer vor der Mündung nimmt er den über 60 km langen Wasserlauf aus Rival, Raille und Oron auf. Verlauf Der als Oberla...
null
null
null
null
What command should be added to the function to make sure the input list is sorted?
def remove_duplicates(list): # TODO: add command new_list = [] for element in list: if element not in new_list: new_list.append(element) return new_list
def remove_duplicates(list): # sort the list list.sort() new_list = [] for element in list: if element not in new_list: new_list.append(element) return new_list
[DE Wikipedia] Susanne Hartmann (Filmeditorin) Susanne Hartmann (* vor 1970 in Bad Kissingen) ist eine deutsche Filmeditorin. Seit Ende der 1970er-Jahre ist sie als Editorin tätig und war inzwischen bei mehr als 40 Langfilmen sowie einigen Serien-Episoden für die Montage verantwortlich. Ihr Schwerpunkt liegt dabei auf...
null
null
null
null
Modify the given HTML code to create a form element with two text boxes and a submit button.
<h2>My Form</h2>
<h2>My Form</h2> <form> <label for="name">Name:</label><br> <input type="text" name="name"><br> <label for="email">Email:</label><br> <input type="text" name="email"><br> <input type="submit" value="Submit"> </form>
null
Re-write this algorithm in pseudo-code.
def checkEven(number): if(number % 2 == 0): return True else: return False
function checkEven(number) if number modulo 2 = 0 return true else return false end function
null
Edit the given SQL statement to select the top 3 entries with lowest price.
SELECT * FROM products
SELECT * FROM products ORDER BY price ASC LIMIT 3;
null
Rewrite the following code snippet in PHP.
def find_max(arr): max = arr[0] for i in range(1, len(arr)): if arr[i] > max: max = arr[i] return max
function find_max($arr) { $max = $arr[0]; for ($i = 1; $i < count($arr); $i++) { if ($arr[$i] > $max) { $max = $arr[$i]; } } return $max; }
null
Given a function to calculate the distance between two points, how would you write a Python program to compute the closest pair of points from a set?
Set of 7 points: [ (-2.2, 12.5), (-8.7, 8.6), (1.1, 10.1), (2.2, 4.2), (-7.3, 5.4), (-3.4, 2.2), (0.4, 9.1) ]
def findClosestPoints(points): # initialize the distance closest_distance = float('inf') closest_points = None for i, point1 in enumerate(points): for j, point2 in enumerate(points): if i != j: distance = calculateDistance(points[i], points[j]) ...
null
Find all character positions in the given string
String: abracadabra
Character Positions: a: 0, 3, 5, 7, 10 b: 1, 8 c: 2 d: 4 r: 6, 9
null
Create an array of numbers using python, only using the number 0
# Create an array of 10 zeros arr = [0 for i in range(10)] # Create an array of 20 zeros arr = [0 for i in range(20)] # Create a 3x3 array of zeros arr = [[0 for i in range(3)] for j in range(3)] # Create a 5x5 array of zeros arr = [[0 for i in range(5)] for j in range(5)]
null
Create an array of strings containing the names of your relatives
relatives = ['John', 'Adam', 'Sarah', 'Paul', 'Emily']
null
Create a CSS class that changes font color to blue.
.blue-text { color: blue; }
null
Given a list of integers, write a Python program to find the maximum value in the array and display its index.
[3, 2, 5, 8, 6]
mylist = [3, 2, 5, 8, 6] # initialize maximum value and index maxval = 0 maxindex = 0 # iterate through list for i, val in enumerate(mylist): # check if the current value is greater than the maximum value if val > maxval: maxval = val maxindex = i # print the result print('Maximum value:', maxval) print('Index...
[HI Wikipedia] पियेर सिमों लाप्लास पियेर सिमों लाप्लास (Pierre Simon Laplace, १७४९ ई. - १८२७ ई.) फ्रांसीसी गणितज्ञ, भौतिकशास्त्री तथा खगोलविद थे। लाप्लास का जन्म २८ मार्च १७४९ ई., को एक दरिद्र किसान के परिवार में हुआ। इनकी शिक्षा धनी पड़ोसियों की सहायता से हुई। कार्य इन्होंने खगोलविज्ञान एवं गणित की अनेक शाखाओं पर महत...
null
null
null
null
Design a web scraper using Python’s BeautifulSoup library. This web scraper should extract the title, content and author of posts from a specified article page in ```https://example.com```.
Not applicable
import requests from bs4 import BeautifulSoup # make request to get response response = requests.get('https://example.com/article-page') # parse text from response soup = BeautifulSoup(response.text, 'html.parser') # extract the title title = soup.find('h1').text # extract the content content = soup.find('p').text ...
[EN Wikipedia] 1952–53 Norwegian 1. Divisjon season The 1952–53 Norwegian 1. Divisjon season was the 14th season of ice hockey in Norway. Eight teams participated in the league, and Gamlebyen won the championship. Regular season External links Norwegian Ice Hockey Federation Nor Eliteserien (ice hockey) seasons 1952 i...
null
null
null
null
Analyze the input provided and generate a function in Python that returns "Invalid input" if the input is not a valid integer number, or returns the number of digits in the input number otherwise.
212
def count_digits(inp): if not isinstance(inp, int): return "Invalid input" else: return len(str(inp))
null
Develop a Python program that calculates the maximum and minimum of a given list.
nums = [2, 3, 5, 10, 12]
def get_min_max(nums): min_value = min(nums) max_value = max(nums) return (min_value, max_value)
null
Create a REST API in Python Flask for a simple blog application with endpoints for creating a post, getting a post, and updating a post.
Not applicable
from flask import Flask, request, jsonify app = Flask(__name__) posts = [] @app.route('/posts',methods=['POST']) def create_post(): data = request.get_json() post = { 'title': data['title'], 'content': data['content'] } posts.append(post) return jsonify(post) @app.route('/posts/<string:title>', methods=['GET...
null
Suggest a better approach to sort the given array.
[4, 3, 8, 6, 7, 9, 2, 1]
def quick_sort(arr): if len(arr) <= 1: return arr pivot = arr[0] left = [] right = [] for i in range (1, len(arr)): if arr[i] < pivot: left.append(arr[i]) else: right.append(arr[i]) left = quick_sort(left) right = quick_sort(right) return left + [pivot] + right
null
Create a function to generate a random string with the given length.
Length = 8
import string import random def generate_random_string(length): char_list = "".join(random.sample(string.ascii_letters, length)) return char_list
null
Create a function in Python to split a list into sublists of given length x.
def split_list(list, x): return [list[i * x:(i + 1) * x] for i in range((len(list) + x - 1) // x )]
null
Edit the following Java program to add a method printMyName. The method should print your name.
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!"); printMyName(); } public static void printMyName(){ System.out.println("John Doe"); } }
[CS Wikipedia] Česko-polská státní hranice Česko-polská státní hranice (polsky Granica polsko-czeska) je státní hranice mezi Českem a Polskem. Její délka ke dni 20. března 2013 oficiálně činí 795,9103 km, a nachází se na ní nejvýchodnější i nejvyšší bod Česka – Sněžka. Zeměpisné vymezení Na polské straně představuje h...
null
null
null
null
Convert the following python code which uses sets to one which uses lists.
s = set([2, 3, 4]) for n in s: print(n)
l = [2, 3, 4] for n in l: print(n)
null
Generate a Python script that takes any number of integer arguments and returns their sum.
3 5 7
def sum_ints(*args): total = 0 for num in args: total += num return total print(sum_ints(3, 5, 7))
null
Multiply two vectors of size 5 and return the output.
a = [1, 2, 3, 4, 5] b = [5, 4, 3, 2, 1]
[5, 8, 9, 8, 5]
null
Update the python program by including a function that finds the shortest word in a list.
my_list = ["hello", "world", "this", "is", "a", "test"]
def find_shortest(input_list): shortest = input_list[0] for word in input_list: if len(word) < len(shortest): shortest = word return shortest shortest_word = find_shortest(my_list) print(shortest_word)
[DE Wikipedia] Im Körper des Freundes Im Körper des Freundes (Originaltitel: The Prisoner of Benda) ist eine Episode der US-amerikanischen Science-Fiction-Zeichentrickserie Futurama. Ihre Erstausstrahlung war am 19. August 2010 beim US-Sender Comedy Central; die deutsche Synchronfassung wurde am 31. Dezember 2011 bei ...
null
null
null
null
Construct an object-oriented code for a Book class.
class Book: def __init__(self, title, author, year): self.title = title self.author = author self.year = year def get_title(self): return self.title def get_author(self): return self.author def get_year(self): return self.year def set_title(self, new_title): self.title = new_title def set_author(self, new_author): self...
null
Describe the algorithm to find the height of a binary tree in Python, using recursion.
Tree: 5 / \ 2 8 / \ / \ 1 4 6 10
def getHeight(root): if not root: return 0 else: # Compute using recurssion leftHeight = getHeight(root.left) rightHeight = getHeight(root.right) # Return the overall height return max(leftHeight, rightHeight) + 1
null
Design a Python module that prints out a table of squares for input ranging from 0 to 10.
def print_table(): print(" x | x^2") print("-----------") for i in range(11): answer = i * i print(f" {i} | {answer}") print_table()
null
Refactor the following code in C++ to incorporate dynamic memory allocation.
#include <stdio.h> int main() { int a[20]; int n = 20; for (int i=0; i<n; i++) scanf("%d", &a[i]); return 0; }
#include <stdio.h> #include <stdlib.h> int main() { int* a; int n = 20; a = (int *)malloc(n * sizeof(int)); for (int i=0; i<n; i++) scanf("%d", &a[i]); free(a); return 0; }
null
In C#, write a code snippet to print all numbers between 1 and 10 (inclusive).
for (int i = 1; i <= 10; i++) { Console.Write(i + " "); } Console.WriteLine();
null
Predict the output of this JavaScript function.
function divideThree(x) { return x / 3; } console.log(divideThree(9));
The output of this function is 3.
[CS Wikipedia] Dějiny koncernu Baťa Dějiny koncernu Baťa se oficiálně započaly dne 21. září 1894, když bylo na jméno Antonína Bati úřady vydáno příslušné živnostenské povolení. V květnu 1931 se z dosavadní veřejné obchodní společnosti stala akciová společnost, jediným akcionářem byl Tomáš Baťa a po jeho tragické smrti...
null
null
null
null
Design a function in Python that takes a string as an input and prints all of the permutations of the string.
string = "ABC"
def permutation(string): if len(string) == 1: return [string] perm_list = [] for i in range(len(string)): m = string[i] rem_string = string[:i] + string[i+1:] for perm in permutation(rem_string): perm_list.append(m + perm) return perm_list s...
null
Create an algorithm in Python toimplement quick sort.
[8, 2, 6, 4, 5, 1]
def quick_sort(arr): if len(arr) < 2: return arr else: pivot = arr[0] less_than_pivot = [i for i in arr[1:] if i <= pivot] greater_than_pivot = [i for i in arr[1:] if i > pivot] return quick_sort(less_than_pivot) + [pivot] + quick_sort(greater_than_pivot)
null
Write a Python program that prints the first 10 prime numbers
def get_prime_numbers(n): prime_nums = [] i = 2 while len(prime_nums) < n: isPrime = True for num in prime_nums: if i % num == 0: isPrime = False break if isPrime: prime_nums.append(i) i += 1 return prime_nums if __...
null
Create an AI model in Python to classify whether a given text is in English or not.
Not applicable
import pandas as pd from sklearn import preprocessing from sklearn.model_selection import train_test_split from sklearn.feature_extraction.text import CountVectorizer from sklearn.naive_bayes import MultinomialNB # Load the datasets df_en = pd.read_csv('english.csv') df_non_en = pd.read_csv('non_english.csv') # Encod...
null
Write a Python program that uses a template engine to generate HTML web page. The program should define a template for a simple website and generate the webpage from that template.
Not applicable
from string import Template mytemplate = Template('<html><body><title>$title</title><h1>$heading</h1>$content</body></html>') data = { 'title':'My Website', 'heading':'Hello World!', 'content': 'This is my website!' } html = mytemplate.substitute(data) print(html)
null
Create a Python class to represent a student's name and GPA.
class Student: def __init__(self, name, gpa): self.name = name self.gpa = gpa def get_name(self): return self.name def get_gpa(self): return self.gpa
[HI Wikipedia] कोसतास मरताकिस कोन्सटान्टीनोस "कोसतास" मरताकिस () यूनानी गायक और मॉडल हैं। मरताकिस ने 2006 में अल्फ़ा टीवी पर प्रसारित हुए प्रतिभा कार्यक्रम ड्रीम शो में भाग लिया तथा इसके द्वारा इन्हें ख्याति प्राप्त हुई। कार्यक्रम में अपनी भागीदारी के पश्चात् इन्होंने तीन स्टूडियो एल्बम रिलीज़ किए तथा यूरोविज़न गीत प्...
null
null
null
[EN Wikipedia] William Mowse William Mowse (Mouse, Mosse) (died 12 August 1588) was an English lawyer and Master of Trinity Hall, Cambridge. Life He graduated LL.B. at Cambridge in 1538, took holy orders, and in 1552 proceeded LL.D. In the latter year, through the interest of Thomas Cranmer and William Cecil, he obtai...
null
null
null
[HI Wikipedia] मरक्युरी मरक्युरी (अंग्रेज़ी : :en:Mercury (mythology), लातिनी : Mercurius मेर्कूरिउस ) प्राचीन रोमन धर्म के प्रमुख देवताओं में से एक थे। वो वाणिज्य और व्यापार के देवता थे। वो अन्य देवताओं के देवदूत भीथे। उनके समतुल्य प्राचीन यूनानी धर्म के देवता थे हरमीस। रोम के देवी-देवता रोमन धर्म
null
null
null
null
Implement the bubble sort algorithm for a linked list.
link_list = [10->9->8->7->6]
class Node: # initialization of node def __init__(self, data): self.data = data self.next = None # bubble sort of linked_list def bubble_sort(head): # Store last node end = None while end != head.next: p = head while p.next != end: q = p.next if p.data > q.data: p.data, q.data = q.data, p.data p = p.next end = p # driv...
null
Write a Python program to convert a list into a dictionary.
[1, 2, 3, 4]
input_list = [1, 2, 3, 4] output_dict = {} for item in input_list: output_dict[item] = None print(output_dict)
null
Given a text string modify it by capitalizing the letters after a period.
hello world. this is from gpt
hello world. This is from GPT
null
What is the purpose of declaring an enum in Java?
The purpose of declaring an enum in Java is to clearly identify a set of related constants that can be tracked. Enums are used to define a special type that contains a fixed set of constants. Enums provide type safety and make the code more self-documenting. They also make it easier for the compiler to check for correc...
[CS Wikipedia] Francesca Cacciniová Francesca Cacciniová (18. září 1587 – po 1641) byla italská skladatelka, zpěvačka, loutnistka, básnířka a učitelka hudby z počátku barokní éry. Florenťané ji přezdívali La Cecchina, což je pravděpodobně zdrobnělina jména Francesca. Jejím otcem byl Giulio Caccini. Jediná její práce, ...
null
null
null
[HI Wikipedia] भाषाविज्ञान भाषाविज्ञान भाषा के अध्ययन की वह शाखा है जिसमें भाषा की उत्पत्ति, स्वरूप, विकास आदि का वैज्ञानिक एवं विश्लेषणात्मक अध्ययन किया जाता है। भाषाविज्ञान, भाषा के स्वरूप, अर्थ और सन्दर्भ का विश्लेषण करता है। भाषा के दस्तावेजीकरण और विवेचन का सबसे प्राचीन कार्य ६ठी शताब्दी के महान भारतीय वैयाकरण पा...
null
null
null
null
Write an HTML page to calculate the area of a circle given its radius.
<!DOCTYPE html> <html> <head> <title>Area of Circle</title> <script> // get radius from user var radius = prompt("Enter the radius of Circle"); // calculate area var area = 3.14 * radius * radius; // print the area document.write("Area of Circle : " + area); </script> </head> <body> </body> </html>
[CS Wikipedia] Karel Mareš (starosta) Karel Mareš (28. ledna 1872 Hostomice – 2. června 1952 Olomouc) byl soudce a první český starosta Olomouce. Život Po maturitě na berounském gymnáziu studoval právnickou fakultu české univerzity v Praze, kde roku 1891 získal titul doktora práv. Poté získával praxi na okresních soud...
null
null
null
null
Write an SQL query to find the names of all students with a score higher than 75.
SELECT name FROM students WHERE score > 75;
[HI Wikipedia] 100 दिन 100 दिन () हिन्दी भाषा की 1991 में बनी फ़िल्म है। फ़िल्म में मुख्य भूमिका में माधुरी दीक्षित, जैकी श्रॉफ और जावेद जाफ़री हैं। फ़िल्म एक रहस्य रोमांचक है जिसकी पटकथा अतिरिक्त संवेदी बोध वाली महिला के इर्दगिर्द घूमती है। यह ऐसी फ़िल्म है जिसमें रहस्य जैसी कोई चीज नहीं थी, लेकिन फ़िर भी उसमें एक ऐस...
null
null
null
[HI Wikipedia] संपत पाल संपत पाल देवी (जन्म:1960) एक सामाजिक कार्यकर्ता तथा गुलाबी गैंग नामक संस्था की संस्थापक है। सन्दर्भ विविध सामाजिक कार्यकर्ता जीवित लोग उत्तर प्रदेश के लोग 1960 में जन्मे लोग
null
null
null
null
Write an algorithm to find the smallest missing positive number from a given list of integers.
[3, 4, -10, -2, 9, 8, 1]
def findSmallestMissing(arr): smallest_missing = 1 for num in arr: if (num == smallest_missing): smallest_missing += 1 return smallest_missing
null
Develop a Python program for converting feet to meters.
def feet_to_meters(feet): return feet * 0.3048 feet = 10 meters = feet_to_meters(feet) print('{} feet is equal to {} meters.'.format(feet, meters))
null
Develop a Python program to reverse a list of numbers.
[1, 2, 3, 4, 5]
def reverse_list(nums): """Function to reverse a list of numbers. Parameters ---------- nums : list List of numbers to be reversed. Returns ------- reversed_list : list Reversed list of numbers. """ reversed_list = nums[::-1] return reversed_list
null
Construct a Swift program to display 'Hello World!'.
print("Hello World!")
null
Create a function that takes in an input string and a delimiter, and spits out a list of words that were seperated by a given delimiter.
"This_is_a_sentence" delimiter = "_"
def split_words(string, delimiter): return string.split(delimiter)
null
Create a NumPy array with all the elements set to 0.
import numpy as np arr = np.zeros(shape=(10, 10))
null
Sort the following list in descending order.
my_list = [1, 5, 3, 7]
my_list.sort(reverse=True)
null
Write a Python program to generate a password with a given length and characters.
length = 10 characters = alphanumeric
import random def generate_password(length, characters): password = '' for i in range(length): password += random.choice(characters) return password print(generate_password(10, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'))
null
Write a code to add two matrices of any size.
[[1, 2, 3], [4, 5, 6]] + [[7, 8, 9], [10, 11, 12]]
def matrix_addition(mat1, mat2): # check whether two matrices are of same size if(len(mat1) != len(mat2)): return 'Not possible to add matrices' else: # adding elements of mat1 and mat2 result = [[0 for col in range(len(mat1[0]))] for row in range(len(mat1))] for i in range(len(mat1)): for j in range(len(mat1[0])): res...
null
Develop a Python script that can automate the task of fetching the titles of 500 web pages.
List of 500 URLs
import requests from bs4 import BeautifulSoup # store URLs in a list urls = [500 URLs] titles = [] for url in urls: response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') title = soup.find('title') if title: titles.append(title.get_text()) else: titles.appe...
[HI Wikipedia] पाकिस्तानी मानक समय पाकिस्तानी मानक समय ( ; देवनागरीकृत : पाकिस्तान मे'यारी वक़्त ) (अंग्रेजी: Pakistan Standard Time ; देवनागरीकृत : पाकिस्तान स्टैण्डर्ड टाइम ), पाकिस्तान का समय मण्डल है। यह ग्रीनविच मानक समय से पाँच घण्टे आगे है, अर्थात् यूटीसी +05:00 में पड़ता है। यह भारतीय मानक समय से आधा घण्टा पीछ...
null
null
null
null
Create a python script that filters out all negative numbers from the given matrix
[[-1, 2, -3], [-4, 5, 6], [-7, 8, 9]]
import numpy as np def filter_out_negative(matrix): # Convert matrix to numpy array matrix = np.array(matrix) # Find all negative numbers and set them to 0 matrix[matrix < 0] = 0 return matrix result = filter_out_negative([[-1, 2, -3], [-4, 5, 6], [-7, 8, 9]]) print(result)
null
Write a function to print an array without duplicate elements.
[4,3,6,5,4,7]
def remove_duplicates(arr): seen = set() for x in arr: if x not in seen: seen.add(x) print(x)
null
Develop an algorithm in Python for finding the maximum index of an array's sub-array.
arr = [2, 3, 4, 5, 7, 9, 11]
def findMaxIndex(arr): """This function finds the maximum index of an array's sub-array.""" maxIndex = 0 currentMax = 0 for i in range(1, len(arr)): if arr[i] > arr[currentMax]: maxIndex = i currentMax = i return maxIndex arr = [2, 3, 4, 5, 7, 9, 11] maxIndex = findM...
null
Implement a Python function to calculate the Gini coefficient of a given dataset.
[2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,21]
def gini(x): """Calculate Gini Coefficient of a given dataset.""" # calculate the frequency of each item in x x_value_counts = x.value_counts().sort_index() # calculate the cumulative sum of x_value_counts x_cum_sum = x_value_counts.cumsum() # calculate the Lorenz values n = len(x) lo...
[CS Wikipedia] Vesmírný závod Vesmírný závod (někdy též vesmírné závody) je pojem, který se používá k označení neoficiálního soupeření mezi Sovětským svazem a Spojenými státy o vědecko-technickou převahu v oblasti dobývání a výzkumu kosmického prostoru během studené války. Toto soupeření probíhalo v zásadě od roku 195...
null
null
null
null
Create a class in Python to extend object class
class MyClass(object): pass
null
How can we use try…except blocks in Python to handle errors?
Try...except blocks are used in Python to handle errors gracefully. They provide a way for Python to execute a code block and gracefully handle any errors that may occur. The code block inside the try is executed first and if an error occurs, it will be caught by the except block and handled. For example, if we have a ...
null
Implement a class-level decorator in Python to time the execution of a method.
class timed_method(object): def __init__(self,func): self.func = func def __call__(self, *args, **kwargs): start_time = time.time() try: result = self.func(*args, **kwargs) except Exception as e: raise e end_time = time.time() ...
null
Create an array from elements 0 to 10 in JavaScript.
const array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
null
Convert the given expression from infix notation to postfix notation.
A + B * (C - D)
ABCD-*+
null
Create a Python program to parse a given XML document and extract specific elements.
XML Document: <books> <book> <title>The Hobbit</title> <author>J.R.R Tolkein</author> </book> <book> <title>Harry Potter and the Sorcerers Stone</title> <author>J.K Rowling</author> </book> </books>
import xml.etree.ElementTree as ET xml_file_path = 'books.xml' tree = ET.parse(xml_file_path) root = tree.getroot() for book in root.findall('book'): title = book.find('title').text author = book.find('author').text print('Title: ', title) print('Author: ', author)
null
Write a JavaScript program to calculate the sum of each individual index value from two given arrays of equal length.
let array1 = [1, 0, 2, 3, 4]; let array2 = [3, 5, 2, 1, 4];
let sumArray = []; for (let i = 0; i < array1.length; i++) { sumArray.push(array1[i] + array2[i]); } console.log(sumArray); // Output: [4, 5, 4, 4, 8]
[EN Wikipedia] Leightonite Leightonite is a rare sulfate mineral with formula of K2Ca2Cu(SO4)4•2H2O. Crystal class Leightonite forms flattened to elongated bladed crystals of variously interpreted crystal structure. Its crystal system is reported as triclinic morphologically, but also as pseudo-orthorhombic due to int...
null
null
null
null
Write a function that takes a list of numbers and returns their sum.
def sum_list(list_nums): total = 0 for num in list_nums: total += num return total
null
Code a Python program to calculate the permutation of a given string.
String = "ABC"
def permutations(string): if len(string) == 0: return [] if len(string) == 1: return [string] perm_list = [] for c in string: for perm in permutations(string.replace(c, '')): perm_list.append(c + perm) return perm_list string = "ABC" print(permutations(string))
null
Create a SQL query to find the names of all students who have scored at least 80 points in Maths and Science.
SELECT s.name FROM student s WHERE s.math > 80 AND s.science > 80
null
You need to write a script in Java to reverse a given list of Strings.
list = ["John", "Alice", "Bob"]
public class ReverseList { public static void reverseList(List<String> list) { if (list.size() > 1) { String temp = list.get(0); list.remove(0); reverseList(list); list.add(temp); } } public static void main(String[] args) { List<String> list = new ArrayList<String>(Arrays.asList("John", "Alice", "Bob")); reverseList(l...
[CS Wikipedia] Aigrefeuille-d'Aunis Aigrefeuille-d'Aunis je francouzská obec v departementu Charente-Maritime v regionu Poitou-Charentes. V roce 2010 zde žilo 3 707 obyvatel. Je centrem kantonu Aigrefeuille-d'Aunis. Vývoj počtu obyvatel Související články Seznam obcí v departementu Charente-Maritime Externí odkazy Ref...
null
null
null
[CS Wikipedia] Římskokatolická farnost Odry Římskokatolická farnost Odry je farnost Římskokatolické církve v děkanátu Bílovec ostravsko-opavské diecéze. Historie farnosti Farnost v Odrách je zmiňována poprvé roku 1373; tehdy se připomíná jako svědek v listině olomoucké biskupské kanceláře oderský farář Jan, zřejmě šle...
null
null
null
[EN Wikipedia] Badminton at the 2019 SEA Games – Women's team The badminton women's team tournament at the 2019 SEA Games in Manila will be held from 1 to 3 December at the Muntinlupa Sports Complex, Metro Manila, Philippines. Schedule All times are Philippines Standard Time (UTC+08:00) Results Quarter-finals Semi-fin...
null
null
null
null
Generate a predictive model in Python to predict the number of employees will leave in a given year based on the age, job position and current salary.
""" Generate a predictive model in Python to predict the number of employees will leave in a given year based on the age, job position and current salary. """ import pandas as pd import matplotlib.pyplot as plt import numpy as np from sklearn.linear_model import LinearRegression # Load the data data = pd.read_csv("da...
[CS Wikipedia] Avon Avon je kosmetická společnost ze Spojených států amerických, která se řadí k největším světovým firmám v tomto oboru. Své zboží prodává formou přímého prodeje, kdy se o zákazníky stará konkrétní zaměstnanec společnosti. Společnost pořádá také Avon pochody, jež mají podporovat boj proti rakovině prs...
null
null
null
null
Generate a Python Fibonacci sequence of length n
n = 7
def fibonacci_sequence(n): nums = [] a, b = 0,1 for i in range(n): nums.append(a) a, b = b, a + b return nums print(fibonacci_sequence(7))
[DE Wikipedia] Kim Jong-boo Kim Jong-boo (* 13. Januar 1965 in Tongyeong, Gyeongsangnam-do) ist ein ehemaliger südkoreanischer Fußballspieler und heutiger -trainer. Er verbrachte seine Karriere in Südkorea, zuletzt spielte er bei Daewoo Royals. Als Trainer war er von 1997 bis 2015 in verschiedenen Positionen bei versc...
null
null
null
[HI Wikipedia] राजमहल महल या प्रासाद, भव्य गृह को कहते हैं। किन्तु विशेष रूप से राजा या राज्य के सर्वोच्च सत्ताधीश के गृह को महल कहा जाता है। बहुत से ऐतिहासिक महलों का उपयोग आजकल संसद, संग्रहालय, होटल या कार्यालय के रूप में किया जा रहा है। भारत की प्राचीन वास्तुविद्या के अनुसार 'प्रासाद' लंबा, चौड़ा, ऊँचा और कई भूमियो...
null
null
null
null
Can you write a Python3 program to calculate the number of times a character appears in a given string?
"Hello World!"
str1 = "Hello World!" char = 'l' count = 0 for i in str1: if i == char: count = count + 1 # Print the result print (f'The character {char} appears {count} times in the string {str1}')
null
Write a Python program to remove all instances of a given value from a given list.
[1, 2, 3, 2, 3, 4], 2
def remove_value(nums, val): res = [] for num in nums: if num != val: res.append(num) return res
null
Make a function "convert_time" that would convert seconds to minutes
def convert_time(seconds): minutes = seconds / 60 return minutes
null
Classify the following sentence into one of the seven categories.
Sentence: My cat came home late last night
Animal
null
Create a JavaScript class for a circle that calculates its area and returns the result.
class Circle { constructor(radius) { this.radius = radius; } get area() { return Math.PI * this.radius * this.radius; } }
[CS Wikipedia] Hans Getzinger Hans Getzinger, také Hanns Gezinger, Hanuš Götzinger (15. století, Haslach, Rakouské arcivévodství – 1512) byl rakouský stavitel, kameník, architekt a mistr jihočeské pozdní gotiky. Původem byl z hornorakouského Haslachu, kde jako člen kamenické a stavitelské rodiny zřejmě vedl stavbu měs...
null
null
null